diff --git a/pyokx/Account.py b/pyokx/Account.py index 56d700f..91556bb 100644 --- a/pyokx/Account.py +++ b/pyokx/Account.py @@ -35,7 +35,7 @@ def get_positions( ) -> APIReturn: """ Get positions - Retrieve information on your positions. When the account is in net mode, net positions will be displayed, and when the account is in long/short mode, long or short positions will be displayed. + Retrieve information on your positions. When the account is in net mode, net positions will be displayed, and when the account is in long/short mode, long or short positions will be displayed. Return in reverse chronological order using ctime. Rate Limit: 10 requests per 2 seconds Rate limit rule: UserID """ @@ -227,14 +227,21 @@ def set_leverage( use_proxy: bool = False, ) -> APIReturn: """ - Set leverage - The following are the setting leverage cases for an instrument: - Set leverage for isolated MARGIN at pairs level. - Set leverage for cross MARGIN in Single-currency margin at pairs level. - Set leverage for cross MARGIN in Multi-currency margin at currency level. - Set leverage for cross/isolated FUTURES/SWAP at underlying/contract level. - Rate Limit: 20 requests per 2 seconds - Rate limit rule: UserID + Set leverage + There are 9 different scenarios for leverage setting: + 1. Set leverage for MARGIN instruments under isolated-margin trade mode at pairs level. + 2. Set leverage for MARGIN instruments under cross-margin trade mode and Single-currency margin account mode at pairs level. + 3. Set leverage for MARGIN instruments under cross-margin trade mode and Multi-currency margin at currency level. + 4. Set leverage for FUTURES instruments under cross-margin trade mode at underlying level. + 5. Set leverage for FUTURES instruments under isolated-margin trade mode and buy/sell position mode at contract level. + 6. Set leverage for FUTURES instruments under isolated-margin trade mode and long/short position mode at contract and position side level. + 7. Set leverage for SWAP instruments under cross-margin trade at contract level. + 8. Set leverage for SWAP instruments under isolated-margin trade mode and buy/sell position mode at contract level. + 9. Set leverage for SWAP instruments under isolated-margin trade mode and long/short position mode at contract and position side level. + Note that the request parameter posSide is only required when margin mode is isolated in long/short position mode for FUTURES/SWAP instruments (see scenario 6 and 9 above). + Please refer to the request examples on the right side for each case. + Rate Limit: 20 requests per 2 seconds + Rate limit rule: UserID """ kwargs = { k: v @@ -253,10 +260,10 @@ def get_maximum_buy_sell_amount_or_open_amount( self, instId: str, tdMode: str, - ccy: str = None, px: str = None, leverage: str = None, unSpotOffset: bool = None, + ccy: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -284,9 +291,9 @@ def get_maximum_available_tradable_amount( self, instId: str, tdMode: str, - ccy: str = None, reduceOnly: bool = None, unSpotOffset: bool = None, + ccy: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -610,6 +617,7 @@ def position_builder( self, instType: str = None, inclRealPos: bool = None, + spotOffsetType: str = None, simPos: list = None, instId: str = None, pos: str = None, diff --git a/pyokx/Funding.py b/pyokx/Funding.py index f2e3493..89d6280 100644 --- a/pyokx/Funding.py +++ b/pyokx/Funding.py @@ -74,11 +74,11 @@ def funds_transfer( amt: str, from_: str, to: str, - subAcct: str = None, type: str = None, loanTrans: bool = None, clientId: str = None, omitPosRisk: str = None, + subAcct: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -107,9 +107,9 @@ def funds_transfer( def get_funds_transfer_state( self, + type: str = None, transId: str = None, clientId: str = None, - type: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -241,6 +241,7 @@ def withdrawal( toAddr: str, fee: str, chain: str = None, + areaCode: str = None, clientId: str = None, use_proxy: bool = False, ) -> APIReturn: diff --git a/pyokx/Gridtrading.py b/pyokx/Gridtrading.py index e624e46..7722434 100644 --- a/pyokx/Gridtrading.py +++ b/pyokx/Gridtrading.py @@ -20,7 +20,7 @@ def place_grid_algo_order( Place grid algo order Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -75,7 +75,7 @@ def stop_grid_algo_order( A maximum of 10 orders can be canceled per request. Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -291,8 +291,8 @@ def get_grid_ai_parameter_public( self, algoOrdType: str, instId: str, - direction: str = None, duration: str = None, + direction: str = None, use_proxy: bool = False, ) -> APIReturn: """ diff --git a/pyokx/Marketdata.py b/pyokx/Marketdata.py index 22c7691..4d3f1c6 100644 --- a/pyokx/Marketdata.py +++ b/pyokx/Marketdata.py @@ -287,7 +287,7 @@ def get_trades( """ Get trades Retrieve the recent transactions of an instrument. - Rate Limit: 20 requests per 2 seconds + Rate Limit: 100 requests per 2 seconds Rate limit rule: IP """ kwargs = { diff --git a/pyokx/Publicdata.py b/pyokx/Publicdata.py index 3292149..aff4211 100644 --- a/pyokx/Publicdata.py +++ b/pyokx/Publicdata.py @@ -6,9 +6,9 @@ class Publicdata(APIComponent): def get_instruments( self, instType: str, + instId: str = None, uly: str = None, instFamily: str = None, - instId: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -33,11 +33,11 @@ def get_instruments( def get_delivery_exercise_history( self, instType: str, - uly: str = None, - instFamily: str = None, after: str = None, before: str = None, limit: str = None, + uly: str = None, + instFamily: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -62,9 +62,9 @@ def get_delivery_exercise_history( def get_open_interest( self, instType: str, + instId: str = None, uly: str = None, instFamily: str = None, - instId: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -155,9 +155,9 @@ def get_limit_price(self, instId: str, use_proxy: bool = False) -> APIReturn: def get_option_market_data( self, + expTime: str = None, uly: str = None, instFamily: str = None, - expTime: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -246,9 +246,6 @@ def get_system_time(self, use_proxy: bool = False) -> APIReturn: def get_liquidation_orders( self, instType: str, - uly: str = None, - instFamily: str = None, - alias: str = None, mgnMode: str = None, instId: str = None, ccy: str = None, @@ -256,6 +253,9 @@ def get_liquidation_orders( before: str = None, after: str = None, limit: str = None, + uly: str = None, + instFamily: str = None, + alias: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -309,11 +309,11 @@ def get_position_tiers( self, instType: str, tdMode: str, + tier: str = None, uly: str = None, instFamily: str = None, instId: str = None, ccy: str = None, - tier: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -398,13 +398,13 @@ def get_underlying(self, instType: str, use_proxy: bool = False) -> APIReturn: def get_insurance_fund( self, instType: str, - uly: str = None, - instFamily: str = None, - ccy: str = None, type: str = None, before: str = None, after: str = None, limit: str = None, + uly: str = None, + instFamily: str = None, + ccy: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -430,9 +430,9 @@ def unit_convert( self, instId: str, sz: str, - px: str = None, type: str = None, unit: str = None, + px: str = None, use_proxy: bool = False, ) -> APIReturn: """ diff --git a/pyokx/Trade.py b/pyokx/Trade.py index fe436bf..6243431 100644 --- a/pyokx/Trade.py +++ b/pyokx/Trade.py @@ -10,14 +10,14 @@ def place_order( side: str, ordType: str, sz: str, - posSide: str = None, - px: str = None, ccy: str = None, clOrdId: str = None, tag: str = None, reduceOnly: bool = None, tgtCcy: str = None, banAmend: bool = None, + posSide: str = None, + px: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -25,7 +25,7 @@ def place_order( You can place an order only if you have sufficient funds. Rate Limit: 60 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -47,14 +47,14 @@ def place_multiple_orders( side: str, ordType: str, sz: str, - posSide: str = None, - px: str = None, ccy: str = None, clOrdId: str = None, tag: str = None, reduceOnly: bool = None, tgtCcy: str = None, banAmend: bool = None, + posSide: str = None, + px: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -62,7 +62,7 @@ def place_multiple_orders( Place orders in batches. Maximum 20 orders can be placed per request. Request parameters should be passed in the form of an array. Rate Limit: 300 orders per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Place order`. @@ -92,7 +92,7 @@ def cancel_order( Cancel an incomplete order. Rate Limit: 60 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -119,7 +119,7 @@ def cancel_multiple_orders( Cancel incomplete orders in batches. Maximum 20 orders can be canceled per request. Request parameters should be passed in the form of an array. Rate Limit: 300 orders per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Cancel order`. @@ -140,12 +140,12 @@ def cancel_multiple_orders( def amend_order( self, instId: str, + cxlOnFail: bool = None, + reqId: str = None, ordId: str = None, clOrdId: str = None, newSz: str = None, newPx: str = None, - cxlOnFail: bool = None, - reqId: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -153,7 +153,7 @@ def amend_order( Amend an incomplete order. Rate Limit: 60 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -171,12 +171,12 @@ def amend_order( def amend_multiple_orders( self, instId: str, + cxlOnFail: bool = None, + reqId: str = None, ordId: str = None, clOrdId: str = None, newSz: str = None, newPx: str = None, - cxlOnFail: bool = None, - reqId: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -184,7 +184,7 @@ def amend_multiple_orders( Amend incomplete orders in batches. Maximum 20 orders can be amended per request. Request parameters should be passed in the form of an array. Rate Limit: 300 orders per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID Unlike other endpoints, the rate limit of this endpoint is determined by the number of orders. If there is only one order in the request, it will consume the rate limit of `Amend order`. @@ -206,11 +206,11 @@ def close_positions( self, instId: str, mgnMode: str, - posSide: str = None, - ccy: str = None, autoCxl: bool = None, clOrdId: str = None, tag: str = None, + posSide: str = None, + ccy: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -218,7 +218,7 @@ def close_positions( Close all positions of an instrument via a market order. Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -245,7 +245,7 @@ def get_order_details( Retrieve order details. Rate Limit: 60 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -435,12 +435,12 @@ def place_algo_order( side: str, ordType: str, sz: str, - posSide: str = None, ccy: str = None, tag: str = None, reduceOnly: bool = None, tgtCcy: str = None, clOrdId: str = None, + posSide: str = None, use_proxy: bool = False, ) -> APIReturn: """ @@ -448,7 +448,7 @@ def place_algo_order( The algo order includes trigger order, oco order, conditional order,iceberg order, twap order and trailing order. Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -471,7 +471,7 @@ def cancel_algo_order( Cancel unfilled algo orders (not including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array. Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -494,7 +494,7 @@ def cancel_advance_algo_order( Cancel unfilled algo orders (including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array. Rate Limit: 20 requests per 2 seconds Derivatives rate limit rule: UserID + (instrumentType + underlying) - Spot & Margin rate limit rule: UserID + (instrumentType + instrumentID) + Spot & Margin rate limit rule: UserID + instrumentID """ kwargs = { k: v @@ -543,13 +543,13 @@ def get_algo_order_list( def get_algo_order_history( self, ordType: str, - state: str = None, - algoId: str = None, instType: str = None, instId: str = None, after: str = None, before: str = None, limit: str = None, + state: str = None, + algoId: str = None, use_proxy: bool = False, ) -> APIReturn: """ diff --git a/pyproject.toml b/pyproject.toml index 95124c9..7fd1d68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "pyokx" -version = "0.4.0" +version = "0.4.1" description = "Unofficial python wrapper for the OKX V5 API" authors = ["nicelgueta"] license = "MIT"