Repository navigation
Conversation
Add client.perp (ticker, candles, funding settlements) and client.perp.isolated (all isolated trade routes) with typed models that take the market key (instrument + pair), plus client.get_markets(). Deprecate the client.futures methods that have a perp replacement. Fix the request signature for bodies with nested whole floats.
CaoKha
force-pushed
the
khanguyen/lnm-675-add-v3perp-routes-to-typescript-and-python-sdks
branch
from
October 29, 2026 14:40
5cc8af9 to
a28aa8c
Compare
CaoKha
deleted the
khanguyen/lnm-675-add-v3perp-routes-to-typescript-and-python-sdks
branch
October 29, 2026 14:40
Contributor
Author
|
Replaced by the PR from branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The REST v3 API has a multi-market perp API under
/v3/perp/*, plusGET /v3/markets. This PR adds them to the SDK.client.get_markets():GET /marketsclient.perp:get_ticker(),get_candles(),get_funding_settlements()client.perp.isolated:new_trade(),cancel(),cancel_all(),close(),add_margin(),cash_in(),update_stoploss(),update_takeprofit(),remove_stoploss(),remove_takeprofit(),get_open_trades(),get_running_trades(),get_closed_trades(),get_canceled_trades(),get_funding_fees()The models are in
models/perp.pyandmodels/markets.py. They follow the v3 API contract:instrument+pair). GET and DELETE send it in the query. POST and PUT send it in the body.quanto_adjustment_rate,quanto_adjustment_fee,sum_quanto_adjustment_fees), the notional fields andmark.PerpOrder.stoplossis an object{mode, value}, as in the API. The old futures route usesstoploss+stoploss_mode.{value, id}). The client sends it ascursor[value]andcursor[id]in the query, and signs that exact query.get_markets()sign the request when the client has credentials, so early-access markets work.Deprecations
client.futures.get_ticker(),get_candles(),get_funding_settlements()and everyclient.futures.isolatedmethod raise aDeprecationWarning. The warning names theclient.perpmethod to use withinstrument='inverse_perp', pair='btc_usd'. The methods still work.client.futures.get_leaderboard()andclient.futures.crossare not deprecated, because there is no perp route for them yet.Fixes found on the way
prepare_paramsturned64000.0into64000only for top-level fields. A nested value such asstoploss.valuewas sent as64000.0. The server signsJSON.stringify(body), which writes64000, so the signature did not match (401 Signature is not valid). The conversion now also handles nested values.printinfutures.isolated.update_takeprofit().Docs
quanto_perp+xau_usdt). It also shows pagination and how to move off the deprecated methods.examples/rest_v3.pynow usesclient.perp. It picks a market other than BTC/USD fromget_markets()when the API key has access to one.0.3.0.Tests
ruff check,pyright: 0 errors.pytest: 62 passed, 12 skipped. The skips come from the signet account state (tier limit, low margin) and also happen onmain.quanto_perp:xau_usdt: it opened the trade, set and removed the take profit, the stop loss and the trailing stop, then closed it.After merge
Publish
0.3.0to PyPI.