okx-sdk


Nameokx-sdk JSON
Version 5.5.812 PyPI version JSON
download
home_pagehttps://github.com/burakoner/okx-sdk
SummaryUp-to-date, most-complete, well-organized, well-documented, easy-to-use OKX Exchange Rest and Websocket API SDK for Python
upload_time2025-08-11 10:47:17
maintainerNone
docs_urlNone
authorBurak Öner
requires_pythonNone
licenseNone
keywords okx crypto exchange api sdk stream websocket ws python bitcoin btc spot futures trade
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OKX V5 API Python SDK

## Overview

**okx-sdk** is up-to-date, most-complete, well-organized, well-documented, easy-to-use OKX Exchange Rest and Websocket API SDK for Python.

### Links

Documentation: [https://www.okx.com/docs-v5/en](https://www.okx.com/docs-v5/en)  
Github: [https://github.com/burakoner/okx-sdk](https://github.com/burakoner/okx-sdk)  
PyPI: [https://pypi.org/project/okx-sdk](https://pypi.org/project/okx-sdk)

### Features

- Implementation of all Rest API endpoints.
- Private and Public Websocket implementation
- Testnet Support
- Websocket handling with reconnection and multiplexed connections

### Quick Start

#### Prerequisites

```python
python version>=3.9
```

#### Installation

Use your terminal to install okx-sdk

```python
pip install okx-sdk
```

#### Using Rest API

Import library as below

```python
from okx import *
# or
from okx import OkxRestClient
# or
from okx import OkxRestClient, OkxSocketClient
```

Build your API Client. You can use OKX API public endpoints without credentials. If you need to use private endpoints you need to provide credentials as below.

```python
api = OkxRestClient()
# or
api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
```

Call your request method

```python
api.public.get_tickers(instType="SPOT")
```

Here is a complete code example:

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
tickers = api.public.get_tickers(instType="SPOT")
print(tickers)

balances = api.account.get_account_balance()
print(balances)
```

There are several sections and hundreds of methods in Rest API Client. Please refer to all methods signatures list below for more information.

```python
api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.account.*       # Trading Account Client
api.funding.*       # Funding Account Client
api.subaccount.*    # Sub-Account Client
api.publicdata.*    # Public Data Client
api.marketdata.*    # Order Book Trading → Market Data Client
api.trade.*         # Order Book Trading → Trade Client
api.algotrade.*     # Order Book Trading → Algo Trading Client
api.gridtrade.*     # Order Book Trading → Grid Trading Client
api.signalbot.*     # Order Book Trading → Signal Bot Trading Client
api.recurring.*     # Order Book Trading → Recuring Buy Client
api.copytrade.*     # Order Book Trading → Copy Trading Client
api.blocktrade.*    # Block Trading Client
api.spreadtrade.*   # Spread Trading Client
api.rubik.*         # Trading Statistics Client
api.onchain_earn.*  # Financial Products → On-Chain Earn Client
api.eth_staking.*   # Financial Products → ETH Staking Client
api.sol_staking.*   # Financial Products → SOL Staking Client
api.simple_earn.*   # Financial Products → Simple Earn Flexible Client
api.flexible_loan.* # Financial Products → Flexible Loan Client
api.affiliate.*     # Affiliate Client
api.publicdata.*    # Status Endpoints are listed in PublicDataClient
api.publicdata.*    # Announcement Endpoints are listed in PublicDataClient
api.dmabroker.*     # DMA Broker Client
api.fdbroker.*      # Fully-Disclosed Broker Client
```

#### Using WebSocket API

Import library as below

```python
from okx import *
# or
from okx import OkxSocketClient
# or
from okx import OkxRestClient, OkxSocketClient
```

You can define WebScoket API Client as below

```python
ws = OkxSocketClient()
# or
ws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
```

There are 3 sections "public", "private" and "business" as described in [https://www.okx.com/docs-v5/en/#overview-production-trading-services](https://www.okx.com/docs-v5/en/#overview-production-trading-services). Every section has different streams. So you have to be sure that you are connecting right section.

```python
api = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.public.*        # Public WebSocket Client
api.private.*       # Private WebSocket Client
api.business.*      # Business WebSocket Client
```

Prepare your callback method and subscribe

```python
ws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
await ws.public.start()
await ws.public.subscribe([{'channel': "tickers", 'instId': "BTC-USDT"}], callback=ws_handler)
```

Here is a fully working OKX WebSocket API Demo

```python
import asyncio
import json
from okx import *

def ws_handler(s):
    data = json.loads(s)

    if("event" in data):
        if(data["event"] == "subscribe"):
            print("Subscribed")
            return
        if(data["event"] == "unsubscribe"):
            print("Unsubscribed")
            return

    if("arg" in data and "channel" in data["arg"]):
        channel = data["arg"]["channel"]
        symbol = data["arg"]["instId"]
        if(channel == "tickers"):
            ticker = data["data"][0]
            print("[TICKER] Symbol:"+ ticker["instId"] +" Open:"+ ticker["open24h"] +" High:"+ ticker["high24h"] +" Low:"+ ticker["low24h"] +" Last:"+ ticker["last"] +" Volume:"+ ticker["vol24h"])
        elif(channel == "trades"):
            trade = data["data"][0]
            print("[TRADE] Symbol:"+ trade["instId"] +" Price:"+ trade["px"] + " Quantity:"+ trade["sz"])
        elif(channel.startswith("candle")):
            candle = data["data"][0]
            print("[CANDLE] Symbol:"+ symbol +" Open:"+ candle[1] +" High:"+ candle[2] +" Low:"+ candle[3] +" Close:"+ candle[4] +" Volume:"+ candle[5])
        else:
            print(f"[UNKNOWN] {text}")

async def tickers():
    ws = OkxSocketClient()
    await ws.public.start()
    await ws.public.subscribe([{'channel': "tickers", 'instId': "BTC-USDT"}], callback=ws_handler)

async def trades():
    ws = OkxSocketClient()
    await ws.public.start()
    await ws.public.subscribe([{'channel': "trades", 'instId': "BTC-USDT"}], callback=ws_handler)

async def multiple():
    ws = OkxSocketClient()
    await ws.public.start()
    await ws.public.subscribe([{'channel': "tickers", 'instId': "BTC-USDT"}, {'channel': "trades", 'instId': "BTC-USDT"}], callback=ws_handler)

async def candles():
    ws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
    await ws.business.start()
    await ws.business.subscribe([{'channel': "candle1H", 'instId': "BTC-USDT"}], callback=ws_handler)

asyncio.run(tickers())
# asyncio.run(trades())
# asyncio.run(candles())
# asyncio.run(multiple())
```

### Rest API Method Signatures

#### Trading Account Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.account.get_instruments(instType, instFamily='', instId=''):
api.account.get_balance(ccy=''):
api.account.get_positions(instType='', instId='', posId=''):
api.account.get_positions_history(instType='', instId='', mgnMode='', type='', posId='', after='', before='', limit=''):
api.account.get_position_risk(instType=''):
api.account.get_bills(instType='', instId='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', begin='', end='', limit=''):
api.account.get_bills_archive(instType='', instId='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', begin='', end='', limit=''):
api.account.apply_bills_history_archive(year, quarter):
api.account.get_bills_history_archive(year, quarter):
api.account.get_account_config(self):
api.account.set_position_mode(posMode):
api.account.set_leverage(lever, mgnMode, instId='', ccy='', posSide=''):
api.account.get_max_order_size(instId, tdMode, ccy='', px='', leverage='', tradeQuoteCcy=''):
api.account.get_max_avail_size(instId, tdMode, ccy='', reduceOnly='', px='', tradeQuoteCcy=''):
api.account.adjust_margin(instId, posSide, type, amt, ccy='')
api.account.get_leverage(mgnMode, instId='', ccy='')
api.account.get_leverage_estimated_info(instType, mgnMode, lever, instId='', ccy='', posSide='')
api.account.get_max_loan(mgnMode, instId, ccy='', mgnCcy='')
api.account.get_fee_rates(ruleType, instType, instId='', instFamily='')
api.account.get_interest_accrued(type='', ccy='', instId='', mgnMode='', after='', before='', limit='')
api.account.get_interest_rate(ccy='')
api.account.set_greeks(greeksType)
api.account.set_isolated_mode(isoMode, type)
api.account.get_max_withdrawal(ccy='')
api.account.get_account_risk_state()
api.account.get_interest_limits(type='', ccy='')
api.account.get_manual_borrow_repay(ccy, side, amt)
api.account.set_auto_repay(autoRepay)
api.account.get_borrow_repay_history(ccy='', type='', after='', before='', limit='')
api.account.position_builder(acctLv='', inclRealPosAndEq=True, lever='', simPos=[], simAsset=[], greeksType='', idxVol='')
api.account.position_builder_graph(inclRealPosAndEq='', simPos=[], simAsset=[], type='', mmrConfig={})
api.account.set_risk_offset_amount(ccy, clSpotInUseAmt)
api.account.get_greeks(ccy='')
api.account.get_position_tiers(instType='', instFamily='')
api.account.activate_option()
api.account.set_auto_loan(autoLoan=True):
api.account.preset_account_level_switch(acctLv, lever='')
api.account.precheck_account_level_switch(acctLv)
api.account.set_account_level(acctLv):
api.account.set_collateral_assets(type, collateralEnabled, ccyList)
api.account.get_collateral_assets(ccy, collateralEnabled)
api.account.reset_mmp_status(instFamily, instType='')
api.account.set_mmp_config(instFamily, timeInterval, frozenInterval, qtyLimit)
api.account.get_mmp_config(instFamily='')
api.account.move_positions(fromAcct, toAcct, legs, clientId)
api.account.get_move_positions_history(blockTdId='', clientId='', beginTs='', endTs='', limit='', state='')
api.account.set_auto_earn(ccy, action, apr='')
```

#### Funding Account Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.funding.get_currencies(ccy='')
api.funding.get_balances(ccy='')
api.funding.get_non_tradable_assets(ccy='')
api.funding.get_asset_valuation(ccy='')
api.funding.funds_transfer(ccy, amt, from_, to,  type='0', subAcct='', loanTrans=False, omitPosRisk=False, clientId='')
api.funding.get_transfer(transId, clientId='', type='')
api.funding.get_bills(ccy='', type='', clientId='', after='', before='', limit='', pagingType='1')
api.funding.get_bills_history(ccy='', type='', clientId='', after='', before='', limit='', pagingType='1')
api.funding.get_deposit_address(ccy)
api.funding.get_deposit_history(ccy='', depId='', fromWdId='', txId='', type='', state='', after='', before='', limit='')
api.funding.withdraw(ccy, amt, dest, toAddr, toAddrType='', chain='', areaCode='', rcvrInfo=None, clientId='')
api.funding.cancel_withdrawal(wdId='')
api.funding.get_withdrawal_history(ccy='', wdId='', clientId='', txId='', type='', state='', after='', before='', limit='')
api.funding.get_deposit_withdraw_status(wdId='', txId='', ccy='', to='', chain='')
api.funding.get_exchange_list()
api.funding.apply_monthly_statement(month)
api.funding.get_monthly_statement(month)
api.funding.get_convert_currencies()
api.funding.get_convert_currency_pair(fromCcy, toCcy)
api.funding.estimate_quote(baseCcy, quoteCcy, side, rfqSz, rfqSzCcy, clQReqId='')
api.funding.convert_trade(quoteId, baseCcy, quoteCcy, side, sz, szCcy, clTReqId='')
api.funding.get_convert_history(clTReqId='', after='', before='', limit='')
api.funding.get_fiat_deposit_payment_methods(ccy)
api.funding.get_fiat_withdrawal_payment_methods(ccy)
api.funding.fiat_withdraw(paymentAcctId, ccy, amt, paymentMethod, clientId)
api.funding.cancel_fiat_withdrawal(ordId)
api.funding.get_fiat_withdrawal_history(ccy='', paymentMethod='', state='', after='', before='', limit='')
api.funding.get_fiat_withdrawal_details(ordId)
api.funding.get_fiat_deposit_history(ccy='', paymentMethod='', state='', after='', before='', limit='')
api.funding.get_fiat_deposit_details(ordId)
api.funding.fiat_buy_sell_currencies()
api.funding.fiat_buy_sell_currency_pairs(fromCcy, toCcy)
api.funding.get_fiat_buy_sell_quote(side, fromCcy, toCcy, rfqAmt, rfqCcy)
api.funding.fiat_buy_sell_trade(quoteId, side, fromCcy, toCcy, rfqAmt, rfqCcy, paymentMethod, clOrdId)
api.funding.get_fiat_buy_sell_history(ordId='', clOrdId='', state='', begin='', end='', limit='')
```

#### Sub-Account Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.subaccount.get_subaccounts(enable='', subAcct='', after='', before='', limit='')
api.subaccount.create_subaccount(subAcct, type, label='', pwd='')
api.subaccount.create_apikey(subAcct, label, passphrase, perm='', ip='')
api.subaccount.get_apikey(subAcct, apiKey='')
api.subaccount.set_apikey(subAcct, apiKey, label='', perm='', ip='')
api.subaccount.delete_apikey(subAcct, apiKey)
api.subaccount.get_trading_balance(subAcct)
api.subaccount.get_funding_balance(subAcct='', ccy='')
api.subaccount.get_max_withdrawal(subAcct, ccy='')
api.subaccount.get_transfer_history(ccy='', type='', subAcct='', after='', before='', limit='')
api.subaccount.get_managed_transfer_history(ccy='', type='', subAcct='', subUid='', after='', before='', limit='')
api.subaccount.transfer(ccy, amt, from_, to, fromSubAccount, toSubAccount, loanTrans='false', omitPosRisk='false')
api.subaccount.set_permission_transfer_out(subAcct, canTransOut='')
api.subaccount.get_entrust_subaccounts(subAcct='')
```

#### Public Data Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient()
api.publicdata.get_time()
api.publicdata.get_status(state='')
api.publicdata.get_announcements(annType='', page='')
api.publicdata.get_announcement_types()
api.publicdata.get_instruments(instType, instId='', instFamily='')
api.publicdata.get_estimated_price(instId)
api.publicdata.get_delivery_exercise_history(instType, instFamily, after='', before='', limit='')
api.publicdata.get_estimated_settlement_info(instId)
api.publicdata.get_settlement_history(instFamily, after='', before='', limit='')
api.publicdata.get_funding_rate(instId)
api.publicdata.funding_rate_history(instId, after='', before='', limit='')
api.publicdata.get_open_interest(instType, instId='', instFamily='')
api.publicdata.get_price_limit(instId)
api.publicdata.get_option_summary(expTime='', instFamily='')
api.publicdata.discount_rate_interest_free_quota(ccy='')
api.publicdata.get_mark_price(instType, instId='', instFamily='')
api.publicdata.get_position_tiers(instType, tdMode, instFamily='', instId='', ccy='', tier='')
api.publicdata.get_interest_rate_loan_quota(payload)
api.publicdata.get_underlying(instType='')
api.publicdata.get_insurance_fund(instType='', type='', instFamily='', ccy='', before='', after='', limit='')
api.publicdata.unit_convert(type='', instId='', sz='', px='', unit='', opType='')
api.publicdata.get_option_tick_bands(instType, instFamily='')
api.publicdata.get_premium_history(instId, after='', before='', limit='')
api.publicdata.get_index_tickers(quoteCcy='', instId='')
api.publicdata.get_index_candlesticks(instId, bar='', after='', before='', limit='')
api.publicdata.get_index_candlesticks_history(instId, bar='', after='', before='', limit='')
api.publicdata.get_mark_price_candlesticks(instId, bar='', after='', before='', limit='')
api.publicdata.get_mark_price_candlesticks_history(instId, bar='', after='', before='', limit='')
api.publicdata.get_exchange_rate()
api.publicdata.get_index_components(index)
api.publicdata.get_economic_calendar(region='', importance='', before='', after='', limit='')
```

#### Market Data Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient()
api.marketdata.get_tickers(instType, instFamily='')
api.marketdata.get_ticker(instId)
api.marketdata.get_orderbook(instId, sz='')
api.marketdata.get_full_orderbook(instId, sz='')
api.marketdata.get_candlesticks(instId, bar='', after='', before='', limit='')
api.marketdata.get_history_candlesticks(instId,  bar='', after='', before='', limit='')
api.marketdata.get_trades(instId, limit='')
api.marketdata.get_trades_history(instId='', type='', after='', before='', limit='')
api.marketdata.get_option_trades_by_family(instFamily='')
api.marketdata.get_option_trades(instId='', instFamily='', optType='')
api.marketdata.get_volume()
api.marketdata.get_call_auction_details(instId)
```

#### Order Book Trading → Trade Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.trade.place_order(instId, tdMode, side, ordType, sz, ccy='', clOrdId='', posSide='', px='', pxUsd='', pxVol='', reduceOnly='', tgtCcy='', banAmend=False, tradeQuoteCcy='', stpMode='', attachAlgoOrds=None)
api.trade.place_multiple_orders(orders_data)
api.trade.cancel_order(instId, ordId='', clOrdId='')
api.trade.cancel_multiple_orders(orders_data)
api.trade.amend_order(instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newPxUsd='', newPxVol='', attachAlgoOrds=None)
api.trade.amend_multiple_orders(orders_data)
api.trade.close_positions(instId, mgnMode, posSide='', ccy='', autoCxl='', clOrdId='')
api.trade.get_order(instId, ordId='', clOrdId='')
api.trade.get_order_list(instType='', instFamily='', instId='', ordType='', state='', after='', before='', limit='')
api.trade.get_orders_history(instType, instFamily='', instId='', ordType='', state='', category='', after='', before='', begin='', end='', limit='')
api.trade.get_orders_history_archive(instType, instFamily='', instId='', ordType='', state='', category='', after='', before='', begin='', end='', limit='')
api.trade.get_fills(instType='', instFamily='', instId='', ordId='', subType='', after='', before='',  begin='', end='', limit='')
api.trade.get_fills_history(instType, instFamily='', instId='', ordId='',  subType='', after='', before='', begin='', end='', limit='')
api.trade.get_easy_convert_currency_list(source='')
api.trade.easy_convert(fromCcy=[], toCcy='', source='')
api.trade.get_easy_convert_history(before='', after='', limit='')
api.trade.get_oneclick_repay_list(debtType='')
api.trade.oneclick_repay(debtCcy=[], repayCcy='')
api.trade.oneclick_repay_history(after='', before='', limit='')
api.trade.get_oneclick_repay_currency_list_v2()
api.trade.oneclick_repay_v2(debtCcy, repayCcyList)
api.trade.oneclick_repay_history_v2(after='', before='', limit='')
api.trade.cancel_all_orders(instType, instFamily, lockInterval='')
api.trade.cancel_all_after(timeOut)
api.trade.get_account_rate_limit()
api.trade.order_precheck(instId, tdMode, side, ordType, sz, px='', posSide='', reduceOnly='', tgtCcy='', attachAlgoOrds=[])
```

#### Order Book Trading → Algo Trading Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.algotrade.place_order(instId, tdMode, side, ordType, ccy='', posSide='', sz='', tgtCcy='', algoClOrdId='', closeFraction='', tradeQuoteCcy='')
api.algotrade.cancel_order(payload=[])
api.algotrade.amend_order(instId='', algoId='', algoClOrdId='', cxlOnFail='', reqId='', newSz='', newTpTriggerPx='', newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='', newTriggerPx='', newOrdPx='', newTriggerPxType='', attachAlgoOrds=[])
api.algotrade.get_order(algoId='', algoClOrdId='')
api.algotrade.get_pending_orders(ordType='', algoId='', instType='', instId='', after='', before='', limit='')
api.algotrade.get_order_history(ordType, state='', algoId='', instType='', instId='', after='', before='', limit='')
```

#### Order Book Trading → Grid Trading Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.gridtrade.place_order(instId, algoOrdType, maxPx, minPx, gridNum, runType='', tpTriggerPx='', slTriggerPx='', algoClOrdId='', profitSharingRatio='', triggerParams=[], quoteSz='', baseSz='', sz='', direction='', lever='', basePos='', tpRatio='', slRatio='')
api.gridtrade.amend_order(algoId, instId, slTriggerPx='', tpTriggerPx='', tpRatio='', slRatio='', triggerParams=[])
api.gridtrade.stop_order(algoId, instId, algoOrdType, stopType)
api.gridtrade.close_position(algoId, mktClose, sz='', px='')
api.gridtrade.cancel_close_position_order(algoId, ordId)
api.gridtrade.instant_trigger_order(algoId)
api.gridtrade.get_pending_orders(algoOrdType='', algoId='', instId='', instType='', after='', before='', limit='')
api.gridtrade.get_orders_history(algoOrdType='', algoId='', instId='', instType='', after='', before='', limit='')
api.gridtrade.get_order_details(algoOrdType='', algoId='')
api.gridtrade.get_sub_orders(algoId='', algoOrdType='', type='', groupId='', after='', before='', limit='')
api.gridtrade.get_positions(algoOrdType, algoId)
api.gridtrade.withdraw_income(algoId)
api.gridtrade.compute_margin_balance(algoId, type, amt='')
api.gridtrade.adjust_margin_balance(algoId, type, amt='', percent='')
api.gridtrade.add_investment(algoId,  amt, allowReinvestProfit='')
api.gridtrade.get_ai_param(algoOrdType='', instId='', direction='', duration='')
api.gridtrade.compute_min_investment(instId, algoOrdType, maxPx, minPx, gridNum, runType, direction='', lever='', basePos='', investmentType='', triggerStrategy='', investmentData=[])
api.gridtrade.get_rsi_back_testing(instId, timeframe, thold, timePeriod, triggerCond='', duration='')
api.gridtrade.get_max_grid_quantity(instId, runType, algoOrdType, maxPx, minPx, lever='')
```

#### Order Book Trading → Signal Bot Trading Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.signalbot.create_signal(signalChanName, signalChanDesc='')
api.signalbot.get_signals(signalSourceType, signalChanId='', after='', before='', limit='')
api.signalbot.create(signalChanId, lever, investAmt, subOrdType, includeAll='', instIds='', ratio='', entrySettingParam={},exitSettingParam={})
api.signalbot.cancel(algoId)
api.signalbot.adjust_margin_balance(algoId, type, amt, allowReinvest=False)
api.signalbot.amend_tpsl(algoId, exitSettingParam={})
api.signalbot.set_instruments(algoId, instIds=[], includeAll=False)
api.signalbot.get_order(algoOrdType, algoId)
api.signalbot.get_active(algoOrdType, algoId, after='', before='', limit='')
api.signalbot.get_history(algoOrdType, algoId, after='', before='', limit='')
api.signalbot.get_positions(algoOrdType, algoId)
api.signalbot.get_position_history(algoId='', instId='', after='', before='', limit='')
api.signalbot.close_position(algoId, instId)
api.signalbot.place_sub_order(algoId, instId, side, ordType, sz, px='', reduceOnly=False)
api.signalbot.cancel_sub_order(algoId, instId, signalOrdId)
api.signalbot.get_sub_orders(algoId, algoOrdType, state='', signalOrdId='', after='', before='', begin='', end='', limit='',type='', clOrdId='')
api.signalbot.get_bot_events(algoId, after='', before='', limit='')
```

#### Order Book Trading → Recuring Buy Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.recurring.place_order(self, stgyName, recurringList, period, recurringDay='', recurringHour='',recurringTime='', timeZone='', amt='', investmentCcy='', tdMode='', algoClOrdId='')
api.recurring.amend_order(self, algoId='', stgyName='')
api.recurring.stop_order(self, algoId)
api.recurring.get_order_list(self, algoId='', after='', before='', limit='')
api.recurring.get_order_history(self, algoId='', after='', before='', limit='')
api.recurring.get_order_details(self, algoId)
api.recurring.get_sub_orders(self, algoId, ordId='', after='', before='', limit='')
```

#### Order Book Trading → Copy Trading Client Methods

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.copytrade.get_current_subpositions(instType='', instId='', after='', before='', limit='')
api.copytrade.get_subpositions_history(instType='', instId='', after='', before='', limit='')
api.copytrade.place_order(subPosId, instType='', tpTriggerPx='', slTriggerPx='', tpOrdPx='', slOrdPx='', tpTriggerPxType='', slTriggerPxType='')
api.copytrade.close_subposition(subPosId, instType='', ordType='', px='')
api.copytrade.get_leading_instruments(instType='')
api.copytrade.set_leading_instruments(instId, instType='')
api.copytrade.get_profit_sharing_details(instType='', after='', before='', limit='')
api.copytrade.get_total_profit_sharing(instType='')
api.copytrade.get_unrealized_profit_sharing_details(instType='')
api.copytrade.get_total_unrealized_profit_sharing(instType='')
api.copytrade.set_profit_sharing_ratio(profitSharingRatio, instType='')
api.copytrade.get_account_configuration(self)
api.copytrade.first_copy_settings(uniqueCode, copyMgnMode, copyInstIdType,  instType='', instId='', copyMode='',copyTotalAmt='', copyAmt='', copyRatio='', tpRatio='', slRatio='', slTotalAmt='', subPosCloseType='')
api.copytrade.set_copy_settings(uniqueCode, copyMgnMode, copyInstIdType, instType='', instId='', copyMode='',copyTotalAmt='',copyAmt='', copyRatio='', tpRatio='', slRatio='', slTotalAmt='', subPosCloseType='')
api.copytrade.stop_copying(uniqueCode, subPosCloseType, instType='')
api.copytrade.get_copy_settings(uniqueCode, instType='')
api.copytrade.get_my_lead_traders(instType='')
api.copytrade.get_public_config(instType='')
api.copytrade.get_public_lead_traders(instType='', sortType='', state='', minLeadDays='', minAssets='', maxAssets='', minAum='', maxAum='', dataVer='', page='', limit='')
api.copytrade.get_public_weekly_pnl(uniqueCode, instType='')
api.copytrade.get_public_daily_pnl(uniqueCode, lastDays, instType='')
api.copytrade.get_public_stats(uniqueCode, lastDays, instType='')
api.copytrade.get_public_preference_currency(uniqueCode, instType='')
api.copytrade.get_public_current_subpositions(uniqueCode, instType='', after='', before='', limit='')
api.copytrade.get_public_subpositions_history(uniqueCode, instType='', after='', before='', limit='')
api.copytrade.get_public_copy_traders(uniqueCode, instType='', limit='')
```

#### Block Trading Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.blocktrade.get_counterparties(self)
api.blocktrade.create_rfq(counterparties=[], anonymous=False, clRfqId='', allowPartialExecution=False, legs=[])
api.blocktrade.cancel_rfq(rfqId='', clRfqId='')
api.blocktrade.cancel_batch_rfqs(rfqIds=[], clRfqIds=[])
api.blocktrade.cancel_all_rfqs(self)
api.blocktrade.execute_quote(rfqId='', quoteId='', legs=[])
api.blocktrade.get_quote_products(self)
api.blocktrade.set_quote_products(payload=[])
api.blocktrade.reset_mmp(self)
api.blocktrade.set_mmp_config(timeInterval, frozenInterval, countLimit)
api.blocktrade.get_mmp_config(timeInterval='', frozenInterval='', countLimit='', mmpFrozen='', mmpFrozenUntil='')
api.blocktrade.create_quote(rfqId='', clQuoteId='',anonymous=False,  quoteSide='', expiresIn='', legs=[])
api.blocktrade.cancel_quote(quoteId='', clQuoteId='', rfqId='')
api.blocktrade.cancel_batch_quotes(quoteIds=[], clQuoteIds=[])
api.blocktrade.cancel_all_quotes(self)
api.blocktrade.cancel_all_after(timeOut)
api.blocktrade.get_rfqs(rfqId='', clRfqId='', state='', beginId='', endId='', limit='')
api.blocktrade.get_quotes(rfqId='', clRfqId='', quoteId='', clQuoteId='', state='', beginId='', endId='', limit='')
api.blocktrade.get_trades(rfqId='', clRfqId='', quoteId='', blockTdId='', clQuoteId='', beginId='', endId='', beginTs='', endTs='', limit='', isSuccessful=False)
api.blocktrade.get_block_tickers(instType, instFamily='')
api.blocktrade.get_block_ticker(instId)
api.blocktrade.get_public_trades(beginId='', endId='', limit='')
api.blocktrade.get_public_block_trades(instId)
```

#### Spread Trading Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.spreadtrade.place_order(sprdId, side, ordType, sz, px, clOrdId='')
api.spreadtrade.cancel_order(ordId='', clOrdId='')
api.spreadtrade.cancel_all_orders(sprdId='')
api.spreadtrade.amend_order(ordId='', clOrdId='', reqId='', newSz='', newPx='')
api.spreadtrade.get_order_details(ordId='', clOrdId='')
api.spreadtrade.get_active_orders(sprdId='', ordType='', state='', beginId='', endId='', limit='')
api.spreadtrade.get_orders_history(sprdId='', ordType='', state='', beginId='', endId='', begin='', end='', limit='')
api.spreadtrade.get_orders_archive(sprdId='', ordType='', state='', instType='', instFamily='', beginId='', endId='', begin='', end='', limit='')
api.spreadtrade.get_trades(sprdId='', tradeId='', ordId='', beginId='', endId='', begin='', end='', limit='')
api.spreadtrade.get_spreads(baseCcy='', instId='', sprdId='', state='')
api.spreadtrade.get_order_book(sprdId, sz='')
api.spreadtrade.get_ticker(sprdId)
api.spreadtrade.get_public_trades(sprdId='')
api.spreadtrade.get_candles(sprdId, bar='', after='', before='', limit='')
api.spreadtrade.get_candles_history(sprdId, bar='', after='', before='', limit='')
api.spreadtrade.cancel_all_after(timeOut)
```

#### Trading Statistics Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.rubik.get_support_coin()
api.rubik.get_open_interest_history(instId, period='', begin='', end='', limit='')
api.rubik.get_taker_volume(ccy, instType, period='', begin='', end='')
api.rubik.get_contract_taker_volume(instId, period='', unit='', begin='', end='', limit='')
api.rubik.get_margin_loan_ratio(ccy, period='', begin='', end='')
api.rubik.get_top_traders_contracts_long_short_ratio_by_account(instId, period='', begin='', end='', limit='')
api.rubik.get_top_traders_contracts_long_short_ratio_by_position(instId, period='', begin='', end='', limit='')
api.rubik.get_contracts_long_short_ratio(instId, period='', begin='', end='', limit='')
api.rubik.get_long_short_ratio(ccy, period='', begin='', end='')
api.rubik.get_contracts_interest_volume(ccy, period='', begin='', end='')
api.rubik.get_options_interest_volume(ccy, period='')
api.rubik.get_put_call_ratio(ccy, period='')
api.rubik.get_interest_volume_expiry(ccy, period='')
api.rubik.get_interest_volume_strike(ccy, expTime, period='')
api.rubik.get_taker_block_volume(ccy, period='')
```

#### Financial Products → On-Chain Earn Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.onchain_earn.get_offers(productId='', protocolType='', ccy='')
api.onchain_earn.purchase(productId, investData, term='')
api.onchain_earn.redeem(ordId, protocolType, allowEarlyRedeem=False)
api.onchain_earn.cancel(ordId, protocolType)
api.onchain_earn.get_active_orders(productId='', protocolType='', ccy='', state='')
api.onchain_earn.get_orders_history(productId='', protocolType='', ccy='', after='', before='', limit='')
```

#### Financial Products → ETH Staking Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.eth_staking.product_info(self)
api.eth_staking.purchase(amt)
api.eth_staking.redeem(amt)
api.eth_staking.get_balance(self)
api.eth_staking.get_purchase_redeem_history(type='', status='', after='', before='', limit='')
api.eth_staking.apy_history(days)
```

#### Financial Products → SOL Staking Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.sol_staking.product_info(self)
api.sol_staking.purchase(amt)
api.sol_staking.redeem(amt)
api.sol_staking.get_balance(self)
api.sol_staking.get_purchase_redeem_history(type='', status='', after='', before='', limit='')
api.sol_staking.apy_history(days)
```

#### Financial Products → Simple Earn Flexible Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.simple_earn.get_balance(ccy='')
api.simple_earn.purchase_redemption(ccy, amt, side, rate='')
api.simple_earn.set_lending_rate(ccy, rate)
api.simple_earn.get_lending_history(ccy='', after='', before='', limit='')
api.simple_earn.get_public_borrow_info(ccy='')
api.simple_earn.get_public_borrow_history(ccy='', after='', before='', limit='')
```

#### Financial Products → Flexible Loan Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.flexible_loan.get_currencies(self)
api.flexible_loan.get_collateral_assets(ccy='')
api.flexible_loan.get_max_loan(borrowCcy, supCollateral=[])
api.flexible_loan.get_max_collateral_redeem_amount(ccy)
api.flexible_loan.get_adjust_collateral(type, collateralCcy, collateralAmt)
api.flexible_loan.get_loan_info(self)
api.flexible_loan.get_loan_history(type='', after='', before='', limit='')
api.flexible_loan.get_interest_accrued(ccy='', after='', before='', limit='')
```

#### Affiliate Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.affiliate.get_invitee_details(uid):
```

#### DMA Broker Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.dmabroker.get_subaccount_list(subAcct='', uid='', page='', limit='')
api.dmabroker.get_subaccount_fee_rates(subAcct='', uid='', page='', limit='')
api.dmabroker.create_subaccount_apikey(subAcct, label, passphrase, ip='', perm='')
api.dmabroker.get_subaccount_apikey(subAcct, apiKey='')
api.dmabroker.get_trading_data_link(type, begin='', end='')
api.dmabroker.generate_trades_download_link(begin='', end='')
```

#### Fully-Disclosed Broker Client

```python
from okx import OkxRestClient

api = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')
api.fdbroker.get_rebate_details_download_link(type='', begin='', end='')
api.fdbroker.generate_rebate_details_download_link(begin='', end='')
api.fdbroker.get_users_broker_rebate_information(apiKey, brokerType)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/burakoner/okx-sdk",
    "name": "okx-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "okx, crypto, exchange, api, sdk, stream, websocket, ws, python, bitcoin, btc, spot, futures, trade",
    "author": "Burak \u00d6ner",
    "author_email": "info@burakoner.com",
    "download_url": "https://files.pythonhosted.org/packages/52/16/7f21fb2f71ab4b1192617f1193cba05cd58362fdce9456249a53d8d65a08/okx_sdk-5.5.812.tar.gz",
    "platform": null,
    "description": "# OKX V5 API Python SDK\r\n\r\n## Overview\r\n\r\n**okx-sdk** is up-to-date, most-complete, well-organized, well-documented, easy-to-use OKX Exchange Rest and Websocket API SDK for Python.\r\n\r\n### Links\r\n\r\nDocumentation: [https://www.okx.com/docs-v5/en](https://www.okx.com/docs-v5/en)  \r\nGithub: [https://github.com/burakoner/okx-sdk](https://github.com/burakoner/okx-sdk)  \r\nPyPI: [https://pypi.org/project/okx-sdk](https://pypi.org/project/okx-sdk)\r\n\r\n### Features\r\n\r\n- Implementation of all Rest API endpoints.\r\n- Private and Public Websocket implementation\r\n- Testnet Support\r\n- Websocket handling with reconnection and multiplexed connections\r\n\r\n### Quick Start\r\n\r\n#### Prerequisites\r\n\r\n```python\r\npython version>=3.9\r\n```\r\n\r\n#### Installation\r\n\r\nUse your terminal to install okx-sdk\r\n\r\n```python\r\npip install okx-sdk\r\n```\r\n\r\n#### Using Rest API\r\n\r\nImport library as below\r\n\r\n```python\r\nfrom okx import *\r\n# or\r\nfrom okx import OkxRestClient\r\n# or\r\nfrom okx import OkxRestClient, OkxSocketClient\r\n```\r\n\r\nBuild your API Client. You can use OKX API public endpoints without credentials. If you need to use private endpoints you need to provide credentials as below.\r\n\r\n```python\r\napi = OkxRestClient()\r\n# or\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\n```\r\n\r\nCall your request method\r\n\r\n```python\r\napi.public.get_tickers(instType=\"SPOT\")\r\n```\r\n\r\nHere is a complete code example:\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\ntickers = api.public.get_tickers(instType=\"SPOT\")\r\nprint(tickers)\r\n\r\nbalances = api.account.get_account_balance()\r\nprint(balances)\r\n```\r\n\r\nThere are several sections and hundreds of methods in Rest API Client. Please refer to all methods signatures list below for more information.\r\n\r\n```python\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.account.*       # Trading Account Client\r\napi.funding.*       # Funding Account Client\r\napi.subaccount.*    # Sub-Account Client\r\napi.publicdata.*    # Public Data Client\r\napi.marketdata.*    # Order Book Trading \u2192 Market Data Client\r\napi.trade.*         # Order Book Trading \u2192 Trade Client\r\napi.algotrade.*     # Order Book Trading \u2192 Algo Trading Client\r\napi.gridtrade.*     # Order Book Trading \u2192 Grid Trading Client\r\napi.signalbot.*     # Order Book Trading \u2192 Signal Bot Trading Client\r\napi.recurring.*     # Order Book Trading \u2192 Recuring Buy Client\r\napi.copytrade.*     # Order Book Trading \u2192 Copy Trading Client\r\napi.blocktrade.*    # Block Trading Client\r\napi.spreadtrade.*   # Spread Trading Client\r\napi.rubik.*         # Trading Statistics Client\r\napi.onchain_earn.*  # Financial Products \u2192 On-Chain Earn Client\r\napi.eth_staking.*   # Financial Products \u2192 ETH Staking Client\r\napi.sol_staking.*   # Financial Products \u2192 SOL Staking Client\r\napi.simple_earn.*   # Financial Products \u2192 Simple Earn Flexible Client\r\napi.flexible_loan.* # Financial Products \u2192 Flexible Loan Client\r\napi.affiliate.*     # Affiliate Client\r\napi.publicdata.*    # Status Endpoints are listed in PublicDataClient\r\napi.publicdata.*    # Announcement Endpoints are listed in PublicDataClient\r\napi.dmabroker.*     # DMA Broker Client\r\napi.fdbroker.*      # Fully-Disclosed Broker Client\r\n```\r\n\r\n#### Using WebSocket API\r\n\r\nImport library as below\r\n\r\n```python\r\nfrom okx import *\r\n# or\r\nfrom okx import OkxSocketClient\r\n# or\r\nfrom okx import OkxRestClient, OkxSocketClient\r\n```\r\n\r\nYou can define WebScoket API Client as below\r\n\r\n```python\r\nws = OkxSocketClient()\r\n# or\r\nws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\n```\r\n\r\nThere are 3 sections \"public\", \"private\" and \"business\" as described in [https://www.okx.com/docs-v5/en/#overview-production-trading-services](https://www.okx.com/docs-v5/en/#overview-production-trading-services). Every section has different streams. So you have to be sure that you are connecting right section.\r\n\r\n```python\r\napi = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.public.*        # Public WebSocket Client\r\napi.private.*       # Private WebSocket Client\r\napi.business.*      # Business WebSocket Client\r\n```\r\n\r\nPrepare your callback method and subscribe\r\n\r\n```python\r\nws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\nawait ws.public.start()\r\nawait ws.public.subscribe([{'channel': \"tickers\", 'instId': \"BTC-USDT\"}], callback=ws_handler)\r\n```\r\n\r\nHere is a fully working OKX WebSocket API Demo\r\n\r\n```python\r\nimport asyncio\r\nimport json\r\nfrom okx import *\r\n\r\ndef ws_handler(s):\r\n    data = json.loads(s)\r\n\r\n    if(\"event\" in data):\r\n        if(data[\"event\"] == \"subscribe\"):\r\n            print(\"Subscribed\")\r\n            return\r\n        if(data[\"event\"] == \"unsubscribe\"):\r\n            print(\"Unsubscribed\")\r\n            return\r\n\r\n    if(\"arg\" in data and \"channel\" in data[\"arg\"]):\r\n        channel = data[\"arg\"][\"channel\"]\r\n        symbol = data[\"arg\"][\"instId\"]\r\n        if(channel == \"tickers\"):\r\n            ticker = data[\"data\"][0]\r\n            print(\"[TICKER] Symbol:\"+ ticker[\"instId\"] +\" Open:\"+ ticker[\"open24h\"] +\" High:\"+ ticker[\"high24h\"] +\" Low:\"+ ticker[\"low24h\"] +\" Last:\"+ ticker[\"last\"] +\" Volume:\"+ ticker[\"vol24h\"])\r\n        elif(channel == \"trades\"):\r\n            trade = data[\"data\"][0]\r\n            print(\"[TRADE] Symbol:\"+ trade[\"instId\"] +\" Price:\"+ trade[\"px\"] + \" Quantity:\"+ trade[\"sz\"])\r\n        elif(channel.startswith(\"candle\")):\r\n            candle = data[\"data\"][0]\r\n            print(\"[CANDLE] Symbol:\"+ symbol +\" Open:\"+ candle[1] +\" High:\"+ candle[2] +\" Low:\"+ candle[3] +\" Close:\"+ candle[4] +\" Volume:\"+ candle[5])\r\n        else:\r\n            print(f\"[UNKNOWN] {text}\")\r\n\r\nasync def tickers():\r\n    ws = OkxSocketClient()\r\n    await ws.public.start()\r\n    await ws.public.subscribe([{'channel': \"tickers\", 'instId': \"BTC-USDT\"}], callback=ws_handler)\r\n\r\nasync def trades():\r\n    ws = OkxSocketClient()\r\n    await ws.public.start()\r\n    await ws.public.subscribe([{'channel': \"trades\", 'instId': \"BTC-USDT\"}], callback=ws_handler)\r\n\r\nasync def multiple():\r\n    ws = OkxSocketClient()\r\n    await ws.public.start()\r\n    await ws.public.subscribe([{'channel': \"tickers\", 'instId': \"BTC-USDT\"}, {'channel': \"trades\", 'instId': \"BTC-USDT\"}], callback=ws_handler)\r\n\r\nasync def candles():\r\n    ws = OkxSocketClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\n    await ws.business.start()\r\n    await ws.business.subscribe([{'channel': \"candle1H\", 'instId': \"BTC-USDT\"}], callback=ws_handler)\r\n\r\nasyncio.run(tickers())\r\n# asyncio.run(trades())\r\n# asyncio.run(candles())\r\n# asyncio.run(multiple())\r\n```\r\n\r\n### Rest API Method Signatures\r\n\r\n#### Trading Account Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.account.get_instruments(instType, instFamily='', instId=''):\r\napi.account.get_balance(ccy=''):\r\napi.account.get_positions(instType='', instId='', posId=''):\r\napi.account.get_positions_history(instType='', instId='', mgnMode='', type='', posId='', after='', before='', limit=''):\r\napi.account.get_position_risk(instType=''):\r\napi.account.get_bills(instType='', instId='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', begin='', end='', limit=''):\r\napi.account.get_bills_archive(instType='', instId='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', begin='', end='', limit=''):\r\napi.account.apply_bills_history_archive(year, quarter):\r\napi.account.get_bills_history_archive(year, quarter):\r\napi.account.get_account_config(self):\r\napi.account.set_position_mode(posMode):\r\napi.account.set_leverage(lever, mgnMode, instId='', ccy='', posSide=''):\r\napi.account.get_max_order_size(instId, tdMode, ccy='', px='', leverage='', tradeQuoteCcy=''):\r\napi.account.get_max_avail_size(instId, tdMode, ccy='', reduceOnly='', px='', tradeQuoteCcy=''):\r\napi.account.adjust_margin(instId, posSide, type, amt, ccy='')\r\napi.account.get_leverage(mgnMode, instId='', ccy='')\r\napi.account.get_leverage_estimated_info(instType, mgnMode, lever, instId='', ccy='', posSide='')\r\napi.account.get_max_loan(mgnMode, instId, ccy='', mgnCcy='')\r\napi.account.get_fee_rates(ruleType, instType, instId='', instFamily='')\r\napi.account.get_interest_accrued(type='', ccy='', instId='', mgnMode='', after='', before='', limit='')\r\napi.account.get_interest_rate(ccy='')\r\napi.account.set_greeks(greeksType)\r\napi.account.set_isolated_mode(isoMode, type)\r\napi.account.get_max_withdrawal(ccy='')\r\napi.account.get_account_risk_state()\r\napi.account.get_interest_limits(type='', ccy='')\r\napi.account.get_manual_borrow_repay(ccy, side, amt)\r\napi.account.set_auto_repay(autoRepay)\r\napi.account.get_borrow_repay_history(ccy='', type='', after='', before='', limit='')\r\napi.account.position_builder(acctLv='', inclRealPosAndEq=True, lever='', simPos=[], simAsset=[], greeksType='', idxVol='')\r\napi.account.position_builder_graph(inclRealPosAndEq='', simPos=[], simAsset=[], type='', mmrConfig={})\r\napi.account.set_risk_offset_amount(ccy, clSpotInUseAmt)\r\napi.account.get_greeks(ccy='')\r\napi.account.get_position_tiers(instType='', instFamily='')\r\napi.account.activate_option()\r\napi.account.set_auto_loan(autoLoan=True):\r\napi.account.preset_account_level_switch(acctLv, lever='')\r\napi.account.precheck_account_level_switch(acctLv)\r\napi.account.set_account_level(acctLv):\r\napi.account.set_collateral_assets(type, collateralEnabled, ccyList)\r\napi.account.get_collateral_assets(ccy, collateralEnabled)\r\napi.account.reset_mmp_status(instFamily, instType='')\r\napi.account.set_mmp_config(instFamily, timeInterval, frozenInterval, qtyLimit)\r\napi.account.get_mmp_config(instFamily='')\r\napi.account.move_positions(fromAcct, toAcct, legs, clientId)\r\napi.account.get_move_positions_history(blockTdId='', clientId='', beginTs='', endTs='', limit='', state='')\r\napi.account.set_auto_earn(ccy, action, apr='')\r\n```\r\n\r\n#### Funding Account Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.funding.get_currencies(ccy='')\r\napi.funding.get_balances(ccy='')\r\napi.funding.get_non_tradable_assets(ccy='')\r\napi.funding.get_asset_valuation(ccy='')\r\napi.funding.funds_transfer(ccy, amt, from_, to,  type='0', subAcct='', loanTrans=False, omitPosRisk=False, clientId='')\r\napi.funding.get_transfer(transId, clientId='', type='')\r\napi.funding.get_bills(ccy='', type='', clientId='', after='', before='', limit='', pagingType='1')\r\napi.funding.get_bills_history(ccy='', type='', clientId='', after='', before='', limit='', pagingType='1')\r\napi.funding.get_deposit_address(ccy)\r\napi.funding.get_deposit_history(ccy='', depId='', fromWdId='', txId='', type='', state='', after='', before='', limit='')\r\napi.funding.withdraw(ccy, amt, dest, toAddr, toAddrType='', chain='', areaCode='', rcvrInfo=None, clientId='')\r\napi.funding.cancel_withdrawal(wdId='')\r\napi.funding.get_withdrawal_history(ccy='', wdId='', clientId='', txId='', type='', state='', after='', before='', limit='')\r\napi.funding.get_deposit_withdraw_status(wdId='', txId='', ccy='', to='', chain='')\r\napi.funding.get_exchange_list()\r\napi.funding.apply_monthly_statement(month)\r\napi.funding.get_monthly_statement(month)\r\napi.funding.get_convert_currencies()\r\napi.funding.get_convert_currency_pair(fromCcy, toCcy)\r\napi.funding.estimate_quote(baseCcy, quoteCcy, side, rfqSz, rfqSzCcy, clQReqId='')\r\napi.funding.convert_trade(quoteId, baseCcy, quoteCcy, side, sz, szCcy, clTReqId='')\r\napi.funding.get_convert_history(clTReqId='', after='', before='', limit='')\r\napi.funding.get_fiat_deposit_payment_methods(ccy)\r\napi.funding.get_fiat_withdrawal_payment_methods(ccy)\r\napi.funding.fiat_withdraw(paymentAcctId, ccy, amt, paymentMethod, clientId)\r\napi.funding.cancel_fiat_withdrawal(ordId)\r\napi.funding.get_fiat_withdrawal_history(ccy='', paymentMethod='', state='', after='', before='', limit='')\r\napi.funding.get_fiat_withdrawal_details(ordId)\r\napi.funding.get_fiat_deposit_history(ccy='', paymentMethod='', state='', after='', before='', limit='')\r\napi.funding.get_fiat_deposit_details(ordId)\r\napi.funding.fiat_buy_sell_currencies()\r\napi.funding.fiat_buy_sell_currency_pairs(fromCcy, toCcy)\r\napi.funding.get_fiat_buy_sell_quote(side, fromCcy, toCcy, rfqAmt, rfqCcy)\r\napi.funding.fiat_buy_sell_trade(quoteId, side, fromCcy, toCcy, rfqAmt, rfqCcy, paymentMethod, clOrdId)\r\napi.funding.get_fiat_buy_sell_history(ordId='', clOrdId='', state='', begin='', end='', limit='')\r\n```\r\n\r\n#### Sub-Account Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.subaccount.get_subaccounts(enable='', subAcct='', after='', before='', limit='')\r\napi.subaccount.create_subaccount(subAcct, type, label='', pwd='')\r\napi.subaccount.create_apikey(subAcct, label, passphrase, perm='', ip='')\r\napi.subaccount.get_apikey(subAcct, apiKey='')\r\napi.subaccount.set_apikey(subAcct, apiKey, label='', perm='', ip='')\r\napi.subaccount.delete_apikey(subAcct, apiKey)\r\napi.subaccount.get_trading_balance(subAcct)\r\napi.subaccount.get_funding_balance(subAcct='', ccy='')\r\napi.subaccount.get_max_withdrawal(subAcct, ccy='')\r\napi.subaccount.get_transfer_history(ccy='', type='', subAcct='', after='', before='', limit='')\r\napi.subaccount.get_managed_transfer_history(ccy='', type='', subAcct='', subUid='', after='', before='', limit='')\r\napi.subaccount.transfer(ccy, amt, from_, to, fromSubAccount, toSubAccount, loanTrans='false', omitPosRisk='false')\r\napi.subaccount.set_permission_transfer_out(subAcct, canTransOut='')\r\napi.subaccount.get_entrust_subaccounts(subAcct='')\r\n```\r\n\r\n#### Public Data Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient()\r\napi.publicdata.get_time()\r\napi.publicdata.get_status(state='')\r\napi.publicdata.get_announcements(annType='', page='')\r\napi.publicdata.get_announcement_types()\r\napi.publicdata.get_instruments(instType, instId='', instFamily='')\r\napi.publicdata.get_estimated_price(instId)\r\napi.publicdata.get_delivery_exercise_history(instType, instFamily, after='', before='', limit='')\r\napi.publicdata.get_estimated_settlement_info(instId)\r\napi.publicdata.get_settlement_history(instFamily, after='', before='', limit='')\r\napi.publicdata.get_funding_rate(instId)\r\napi.publicdata.funding_rate_history(instId, after='', before='', limit='')\r\napi.publicdata.get_open_interest(instType, instId='', instFamily='')\r\napi.publicdata.get_price_limit(instId)\r\napi.publicdata.get_option_summary(expTime='', instFamily='')\r\napi.publicdata.discount_rate_interest_free_quota(ccy='')\r\napi.publicdata.get_mark_price(instType, instId='', instFamily='')\r\napi.publicdata.get_position_tiers(instType, tdMode, instFamily='', instId='', ccy='', tier='')\r\napi.publicdata.get_interest_rate_loan_quota(payload)\r\napi.publicdata.get_underlying(instType='')\r\napi.publicdata.get_insurance_fund(instType='', type='', instFamily='', ccy='', before='', after='', limit='')\r\napi.publicdata.unit_convert(type='', instId='', sz='', px='', unit='', opType='')\r\napi.publicdata.get_option_tick_bands(instType, instFamily='')\r\napi.publicdata.get_premium_history(instId, after='', before='', limit='')\r\napi.publicdata.get_index_tickers(quoteCcy='', instId='')\r\napi.publicdata.get_index_candlesticks(instId, bar='', after='', before='', limit='')\r\napi.publicdata.get_index_candlesticks_history(instId, bar='', after='', before='', limit='')\r\napi.publicdata.get_mark_price_candlesticks(instId, bar='', after='', before='', limit='')\r\napi.publicdata.get_mark_price_candlesticks_history(instId, bar='', after='', before='', limit='')\r\napi.publicdata.get_exchange_rate()\r\napi.publicdata.get_index_components(index)\r\napi.publicdata.get_economic_calendar(region='', importance='', before='', after='', limit='')\r\n```\r\n\r\n#### Market Data Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient()\r\napi.marketdata.get_tickers(instType, instFamily='')\r\napi.marketdata.get_ticker(instId)\r\napi.marketdata.get_orderbook(instId, sz='')\r\napi.marketdata.get_full_orderbook(instId, sz='')\r\napi.marketdata.get_candlesticks(instId, bar='', after='', before='', limit='')\r\napi.marketdata.get_history_candlesticks(instId,  bar='', after='', before='', limit='')\r\napi.marketdata.get_trades(instId, limit='')\r\napi.marketdata.get_trades_history(instId='', type='', after='', before='', limit='')\r\napi.marketdata.get_option_trades_by_family(instFamily='')\r\napi.marketdata.get_option_trades(instId='', instFamily='', optType='')\r\napi.marketdata.get_volume()\r\napi.marketdata.get_call_auction_details(instId)\r\n```\r\n\r\n#### Order Book Trading \u2192 Trade Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.trade.place_order(instId, tdMode, side, ordType, sz, ccy='', clOrdId='', posSide='', px='', pxUsd='', pxVol='', reduceOnly='', tgtCcy='', banAmend=False, tradeQuoteCcy='', stpMode='', attachAlgoOrds=None)\r\napi.trade.place_multiple_orders(orders_data)\r\napi.trade.cancel_order(instId, ordId='', clOrdId='')\r\napi.trade.cancel_multiple_orders(orders_data)\r\napi.trade.amend_order(instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newPxUsd='', newPxVol='', attachAlgoOrds=None)\r\napi.trade.amend_multiple_orders(orders_data)\r\napi.trade.close_positions(instId, mgnMode, posSide='', ccy='', autoCxl='', clOrdId='')\r\napi.trade.get_order(instId, ordId='', clOrdId='')\r\napi.trade.get_order_list(instType='', instFamily='', instId='', ordType='', state='', after='', before='', limit='')\r\napi.trade.get_orders_history(instType, instFamily='', instId='', ordType='', state='', category='', after='', before='', begin='', end='', limit='')\r\napi.trade.get_orders_history_archive(instType, instFamily='', instId='', ordType='', state='', category='', after='', before='', begin='', end='', limit='')\r\napi.trade.get_fills(instType='', instFamily='', instId='', ordId='', subType='', after='', before='',  begin='', end='', limit='')\r\napi.trade.get_fills_history(instType, instFamily='', instId='', ordId='',  subType='', after='', before='', begin='', end='', limit='')\r\napi.trade.get_easy_convert_currency_list(source='')\r\napi.trade.easy_convert(fromCcy=[], toCcy='', source='')\r\napi.trade.get_easy_convert_history(before='', after='', limit='')\r\napi.trade.get_oneclick_repay_list(debtType='')\r\napi.trade.oneclick_repay(debtCcy=[], repayCcy='')\r\napi.trade.oneclick_repay_history(after='', before='', limit='')\r\napi.trade.get_oneclick_repay_currency_list_v2()\r\napi.trade.oneclick_repay_v2(debtCcy, repayCcyList)\r\napi.trade.oneclick_repay_history_v2(after='', before='', limit='')\r\napi.trade.cancel_all_orders(instType, instFamily, lockInterval='')\r\napi.trade.cancel_all_after(timeOut)\r\napi.trade.get_account_rate_limit()\r\napi.trade.order_precheck(instId, tdMode, side, ordType, sz, px='', posSide='', reduceOnly='', tgtCcy='', attachAlgoOrds=[])\r\n```\r\n\r\n#### Order Book Trading \u2192 Algo Trading Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.algotrade.place_order(instId, tdMode, side, ordType, ccy='', posSide='', sz='', tgtCcy='', algoClOrdId='', closeFraction='', tradeQuoteCcy='')\r\napi.algotrade.cancel_order(payload=[])\r\napi.algotrade.amend_order(instId='', algoId='', algoClOrdId='', cxlOnFail='', reqId='', newSz='', newTpTriggerPx='', newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='', newTriggerPx='', newOrdPx='', newTriggerPxType='', attachAlgoOrds=[])\r\napi.algotrade.get_order(algoId='', algoClOrdId='')\r\napi.algotrade.get_pending_orders(ordType='', algoId='', instType='', instId='', after='', before='', limit='')\r\napi.algotrade.get_order_history(ordType, state='', algoId='', instType='', instId='', after='', before='', limit='')\r\n```\r\n\r\n#### Order Book Trading \u2192 Grid Trading Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.gridtrade.place_order(instId, algoOrdType, maxPx, minPx, gridNum, runType='', tpTriggerPx='', slTriggerPx='', algoClOrdId='', profitSharingRatio='', triggerParams=[], quoteSz='', baseSz='', sz='', direction='', lever='', basePos='', tpRatio='', slRatio='')\r\napi.gridtrade.amend_order(algoId, instId, slTriggerPx='', tpTriggerPx='', tpRatio='', slRatio='', triggerParams=[])\r\napi.gridtrade.stop_order(algoId, instId, algoOrdType, stopType)\r\napi.gridtrade.close_position(algoId, mktClose, sz='', px='')\r\napi.gridtrade.cancel_close_position_order(algoId, ordId)\r\napi.gridtrade.instant_trigger_order(algoId)\r\napi.gridtrade.get_pending_orders(algoOrdType='', algoId='', instId='', instType='', after='', before='', limit='')\r\napi.gridtrade.get_orders_history(algoOrdType='', algoId='', instId='', instType='', after='', before='', limit='')\r\napi.gridtrade.get_order_details(algoOrdType='', algoId='')\r\napi.gridtrade.get_sub_orders(algoId='', algoOrdType='', type='', groupId='', after='', before='', limit='')\r\napi.gridtrade.get_positions(algoOrdType, algoId)\r\napi.gridtrade.withdraw_income(algoId)\r\napi.gridtrade.compute_margin_balance(algoId, type, amt='')\r\napi.gridtrade.adjust_margin_balance(algoId, type, amt='', percent='')\r\napi.gridtrade.add_investment(algoId,  amt, allowReinvestProfit='')\r\napi.gridtrade.get_ai_param(algoOrdType='', instId='', direction='', duration='')\r\napi.gridtrade.compute_min_investment(instId, algoOrdType, maxPx, minPx, gridNum, runType, direction='', lever='', basePos='', investmentType='', triggerStrategy='', investmentData=[])\r\napi.gridtrade.get_rsi_back_testing(instId, timeframe, thold, timePeriod, triggerCond='', duration='')\r\napi.gridtrade.get_max_grid_quantity(instId, runType, algoOrdType, maxPx, minPx, lever='')\r\n```\r\n\r\n#### Order Book Trading \u2192 Signal Bot Trading Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.signalbot.create_signal(signalChanName, signalChanDesc='')\r\napi.signalbot.get_signals(signalSourceType, signalChanId='', after='', before='', limit='')\r\napi.signalbot.create(signalChanId, lever, investAmt, subOrdType, includeAll='', instIds='', ratio='', entrySettingParam={},exitSettingParam={})\r\napi.signalbot.cancel(algoId)\r\napi.signalbot.adjust_margin_balance(algoId, type, amt, allowReinvest=False)\r\napi.signalbot.amend_tpsl(algoId, exitSettingParam={})\r\napi.signalbot.set_instruments(algoId, instIds=[], includeAll=False)\r\napi.signalbot.get_order(algoOrdType, algoId)\r\napi.signalbot.get_active(algoOrdType, algoId, after='', before='', limit='')\r\napi.signalbot.get_history(algoOrdType, algoId, after='', before='', limit='')\r\napi.signalbot.get_positions(algoOrdType, algoId)\r\napi.signalbot.get_position_history(algoId='', instId='', after='', before='', limit='')\r\napi.signalbot.close_position(algoId, instId)\r\napi.signalbot.place_sub_order(algoId, instId, side, ordType, sz, px='', reduceOnly=False)\r\napi.signalbot.cancel_sub_order(algoId, instId, signalOrdId)\r\napi.signalbot.get_sub_orders(algoId, algoOrdType, state='', signalOrdId='', after='', before='', begin='', end='', limit='',type='', clOrdId='')\r\napi.signalbot.get_bot_events(algoId, after='', before='', limit='')\r\n```\r\n\r\n#### Order Book Trading \u2192 Recuring Buy Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.recurring.place_order(self, stgyName, recurringList, period, recurringDay='', recurringHour='',recurringTime='', timeZone='', amt='', investmentCcy='', tdMode='', algoClOrdId='')\r\napi.recurring.amend_order(self, algoId='', stgyName='')\r\napi.recurring.stop_order(self, algoId)\r\napi.recurring.get_order_list(self, algoId='', after='', before='', limit='')\r\napi.recurring.get_order_history(self, algoId='', after='', before='', limit='')\r\napi.recurring.get_order_details(self, algoId)\r\napi.recurring.get_sub_orders(self, algoId, ordId='', after='', before='', limit='')\r\n```\r\n\r\n#### Order Book Trading \u2192 Copy Trading Client Methods\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.copytrade.get_current_subpositions(instType='', instId='', after='', before='', limit='')\r\napi.copytrade.get_subpositions_history(instType='', instId='', after='', before='', limit='')\r\napi.copytrade.place_order(subPosId, instType='', tpTriggerPx='', slTriggerPx='', tpOrdPx='', slOrdPx='', tpTriggerPxType='', slTriggerPxType='')\r\napi.copytrade.close_subposition(subPosId, instType='', ordType='', px='')\r\napi.copytrade.get_leading_instruments(instType='')\r\napi.copytrade.set_leading_instruments(instId, instType='')\r\napi.copytrade.get_profit_sharing_details(instType='', after='', before='', limit='')\r\napi.copytrade.get_total_profit_sharing(instType='')\r\napi.copytrade.get_unrealized_profit_sharing_details(instType='')\r\napi.copytrade.get_total_unrealized_profit_sharing(instType='')\r\napi.copytrade.set_profit_sharing_ratio(profitSharingRatio, instType='')\r\napi.copytrade.get_account_configuration(self)\r\napi.copytrade.first_copy_settings(uniqueCode, copyMgnMode, copyInstIdType,  instType='', instId='', copyMode='',copyTotalAmt='', copyAmt='', copyRatio='', tpRatio='', slRatio='', slTotalAmt='', subPosCloseType='')\r\napi.copytrade.set_copy_settings(uniqueCode, copyMgnMode, copyInstIdType, instType='', instId='', copyMode='',copyTotalAmt='',copyAmt='', copyRatio='', tpRatio='', slRatio='', slTotalAmt='', subPosCloseType='')\r\napi.copytrade.stop_copying(uniqueCode, subPosCloseType, instType='')\r\napi.copytrade.get_copy_settings(uniqueCode, instType='')\r\napi.copytrade.get_my_lead_traders(instType='')\r\napi.copytrade.get_public_config(instType='')\r\napi.copytrade.get_public_lead_traders(instType='', sortType='', state='', minLeadDays='', minAssets='', maxAssets='', minAum='', maxAum='', dataVer='', page='', limit='')\r\napi.copytrade.get_public_weekly_pnl(uniqueCode, instType='')\r\napi.copytrade.get_public_daily_pnl(uniqueCode, lastDays, instType='')\r\napi.copytrade.get_public_stats(uniqueCode, lastDays, instType='')\r\napi.copytrade.get_public_preference_currency(uniqueCode, instType='')\r\napi.copytrade.get_public_current_subpositions(uniqueCode, instType='', after='', before='', limit='')\r\napi.copytrade.get_public_subpositions_history(uniqueCode, instType='', after='', before='', limit='')\r\napi.copytrade.get_public_copy_traders(uniqueCode, instType='', limit='')\r\n```\r\n\r\n#### Block Trading Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.blocktrade.get_counterparties(self)\r\napi.blocktrade.create_rfq(counterparties=[], anonymous=False, clRfqId='', allowPartialExecution=False, legs=[])\r\napi.blocktrade.cancel_rfq(rfqId='', clRfqId='')\r\napi.blocktrade.cancel_batch_rfqs(rfqIds=[], clRfqIds=[])\r\napi.blocktrade.cancel_all_rfqs(self)\r\napi.blocktrade.execute_quote(rfqId='', quoteId='', legs=[])\r\napi.blocktrade.get_quote_products(self)\r\napi.blocktrade.set_quote_products(payload=[])\r\napi.blocktrade.reset_mmp(self)\r\napi.blocktrade.set_mmp_config(timeInterval, frozenInterval, countLimit)\r\napi.blocktrade.get_mmp_config(timeInterval='', frozenInterval='', countLimit='', mmpFrozen='', mmpFrozenUntil='')\r\napi.blocktrade.create_quote(rfqId='', clQuoteId='',anonymous=False,  quoteSide='', expiresIn='', legs=[])\r\napi.blocktrade.cancel_quote(quoteId='', clQuoteId='', rfqId='')\r\napi.blocktrade.cancel_batch_quotes(quoteIds=[], clQuoteIds=[])\r\napi.blocktrade.cancel_all_quotes(self)\r\napi.blocktrade.cancel_all_after(timeOut)\r\napi.blocktrade.get_rfqs(rfqId='', clRfqId='', state='', beginId='', endId='', limit='')\r\napi.blocktrade.get_quotes(rfqId='', clRfqId='', quoteId='', clQuoteId='', state='', beginId='', endId='', limit='')\r\napi.blocktrade.get_trades(rfqId='', clRfqId='', quoteId='', blockTdId='', clQuoteId='', beginId='', endId='', beginTs='', endTs='', limit='', isSuccessful=False)\r\napi.blocktrade.get_block_tickers(instType, instFamily='')\r\napi.blocktrade.get_block_ticker(instId)\r\napi.blocktrade.get_public_trades(beginId='', endId='', limit='')\r\napi.blocktrade.get_public_block_trades(instId)\r\n```\r\n\r\n#### Spread Trading Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.spreadtrade.place_order(sprdId, side, ordType, sz, px, clOrdId='')\r\napi.spreadtrade.cancel_order(ordId='', clOrdId='')\r\napi.spreadtrade.cancel_all_orders(sprdId='')\r\napi.spreadtrade.amend_order(ordId='', clOrdId='', reqId='', newSz='', newPx='')\r\napi.spreadtrade.get_order_details(ordId='', clOrdId='')\r\napi.spreadtrade.get_active_orders(sprdId='', ordType='', state='', beginId='', endId='', limit='')\r\napi.spreadtrade.get_orders_history(sprdId='', ordType='', state='', beginId='', endId='', begin='', end='', limit='')\r\napi.spreadtrade.get_orders_archive(sprdId='', ordType='', state='', instType='', instFamily='', beginId='', endId='', begin='', end='', limit='')\r\napi.spreadtrade.get_trades(sprdId='', tradeId='', ordId='', beginId='', endId='', begin='', end='', limit='')\r\napi.spreadtrade.get_spreads(baseCcy='', instId='', sprdId='', state='')\r\napi.spreadtrade.get_order_book(sprdId, sz='')\r\napi.spreadtrade.get_ticker(sprdId)\r\napi.spreadtrade.get_public_trades(sprdId='')\r\napi.spreadtrade.get_candles(sprdId, bar='', after='', before='', limit='')\r\napi.spreadtrade.get_candles_history(sprdId, bar='', after='', before='', limit='')\r\napi.spreadtrade.cancel_all_after(timeOut)\r\n```\r\n\r\n#### Trading Statistics Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.rubik.get_support_coin()\r\napi.rubik.get_open_interest_history(instId, period='', begin='', end='', limit='')\r\napi.rubik.get_taker_volume(ccy, instType, period='', begin='', end='')\r\napi.rubik.get_contract_taker_volume(instId, period='', unit='', begin='', end='', limit='')\r\napi.rubik.get_margin_loan_ratio(ccy, period='', begin='', end='')\r\napi.rubik.get_top_traders_contracts_long_short_ratio_by_account(instId, period='', begin='', end='', limit='')\r\napi.rubik.get_top_traders_contracts_long_short_ratio_by_position(instId, period='', begin='', end='', limit='')\r\napi.rubik.get_contracts_long_short_ratio(instId, period='', begin='', end='', limit='')\r\napi.rubik.get_long_short_ratio(ccy, period='', begin='', end='')\r\napi.rubik.get_contracts_interest_volume(ccy, period='', begin='', end='')\r\napi.rubik.get_options_interest_volume(ccy, period='')\r\napi.rubik.get_put_call_ratio(ccy, period='')\r\napi.rubik.get_interest_volume_expiry(ccy, period='')\r\napi.rubik.get_interest_volume_strike(ccy, expTime, period='')\r\napi.rubik.get_taker_block_volume(ccy, period='')\r\n```\r\n\r\n#### Financial Products \u2192 On-Chain Earn Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.onchain_earn.get_offers(productId='', protocolType='', ccy='')\r\napi.onchain_earn.purchase(productId, investData, term='')\r\napi.onchain_earn.redeem(ordId, protocolType, allowEarlyRedeem=False)\r\napi.onchain_earn.cancel(ordId, protocolType)\r\napi.onchain_earn.get_active_orders(productId='', protocolType='', ccy='', state='')\r\napi.onchain_earn.get_orders_history(productId='', protocolType='', ccy='', after='', before='', limit='')\r\n```\r\n\r\n#### Financial Products \u2192 ETH Staking Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.eth_staking.product_info(self)\r\napi.eth_staking.purchase(amt)\r\napi.eth_staking.redeem(amt)\r\napi.eth_staking.get_balance(self)\r\napi.eth_staking.get_purchase_redeem_history(type='', status='', after='', before='', limit='')\r\napi.eth_staking.apy_history(days)\r\n```\r\n\r\n#### Financial Products \u2192 SOL Staking Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.sol_staking.product_info(self)\r\napi.sol_staking.purchase(amt)\r\napi.sol_staking.redeem(amt)\r\napi.sol_staking.get_balance(self)\r\napi.sol_staking.get_purchase_redeem_history(type='', status='', after='', before='', limit='')\r\napi.sol_staking.apy_history(days)\r\n```\r\n\r\n#### Financial Products \u2192 Simple Earn Flexible Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.simple_earn.get_balance(ccy='')\r\napi.simple_earn.purchase_redemption(ccy, amt, side, rate='')\r\napi.simple_earn.set_lending_rate(ccy, rate)\r\napi.simple_earn.get_lending_history(ccy='', after='', before='', limit='')\r\napi.simple_earn.get_public_borrow_info(ccy='')\r\napi.simple_earn.get_public_borrow_history(ccy='', after='', before='', limit='')\r\n```\r\n\r\n#### Financial Products \u2192 Flexible Loan Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.flexible_loan.get_currencies(self)\r\napi.flexible_loan.get_collateral_assets(ccy='')\r\napi.flexible_loan.get_max_loan(borrowCcy, supCollateral=[])\r\napi.flexible_loan.get_max_collateral_redeem_amount(ccy)\r\napi.flexible_loan.get_adjust_collateral(type, collateralCcy, collateralAmt)\r\napi.flexible_loan.get_loan_info(self)\r\napi.flexible_loan.get_loan_history(type='', after='', before='', limit='')\r\napi.flexible_loan.get_interest_accrued(ccy='', after='', before='', limit='')\r\n```\r\n\r\n#### Affiliate Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.affiliate.get_invitee_details(uid):\r\n```\r\n\r\n#### DMA Broker Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.dmabroker.get_subaccount_list(subAcct='', uid='', page='', limit='')\r\napi.dmabroker.get_subaccount_fee_rates(subAcct='', uid='', page='', limit='')\r\napi.dmabroker.create_subaccount_apikey(subAcct, label, passphrase, ip='', perm='')\r\napi.dmabroker.get_subaccount_apikey(subAcct, apiKey='')\r\napi.dmabroker.get_trading_data_link(type, begin='', end='')\r\napi.dmabroker.generate_trades_download_link(begin='', end='')\r\n```\r\n\r\n#### Fully-Disclosed Broker Client\r\n\r\n```python\r\nfrom okx import OkxRestClient\r\n\r\napi = OkxRestClient('---API-KEY---', '---API-SECRET---', '---PASS-PHRASE---')\r\napi.fdbroker.get_rebate_details_download_link(type='', begin='', end='')\r\napi.fdbroker.generate_rebate_details_download_link(begin='', end='')\r\napi.fdbroker.get_users_broker_rebate_information(apiKey, brokerType)\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Up-to-date, most-complete, well-organized, well-documented, easy-to-use OKX Exchange Rest and Websocket API SDK for Python",
    "version": "5.5.812",
    "project_urls": {
        "Homepage": "https://github.com/burakoner/okx-sdk"
    },
    "split_keywords": [
        "okx",
        " crypto",
        " exchange",
        " api",
        " sdk",
        " stream",
        " websocket",
        " ws",
        " python",
        " bitcoin",
        " btc",
        " spot",
        " futures",
        " trade"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e2a38c399b5ede09bd195109e3760c9af0c22d17f441f1f93c26aae9cb14541c",
                "md5": "7fa55a3e0d81497b55e7df28ff37db14",
                "sha256": "54255b618b733828af1e2fcbe3e37a4319ee389d7770dbce8ddfabfc51060c20"
            },
            "downloads": -1,
            "filename": "okx_sdk-5.5.812-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7fa55a3e0d81497b55e7df28ff37db14",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 49885,
            "upload_time": "2025-08-11T10:47:16",
            "upload_time_iso_8601": "2025-08-11T10:47:16.763871Z",
            "url": "https://files.pythonhosted.org/packages/e2/a3/8c399b5ede09bd195109e3760c9af0c22d17f441f1f93c26aae9cb14541c/okx_sdk-5.5.812-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "52167f21fb2f71ab4b1192617f1193cba05cd58362fdce9456249a53d8d65a08",
                "md5": "268f5494e78910dfd5719c6710daff55",
                "sha256": "66888a33fe7b73f68cbed07ff33cb4647cd7bdf6a2c73ce2d86ae9ec8ab597b5"
            },
            "downloads": -1,
            "filename": "okx_sdk-5.5.812.tar.gz",
            "has_sig": false,
            "md5_digest": "268f5494e78910dfd5719c6710daff55",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 51236,
            "upload_time": "2025-08-11T10:47:17",
            "upload_time_iso_8601": "2025-08-11T10:47:17.802721Z",
            "url": "https://files.pythonhosted.org/packages/52/16/7f21fb2f71ab4b1192617f1193cba05cd58362fdce9456249a53d8d65a08/okx_sdk-5.5.812.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-11 10:47:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "burakoner",
    "github_project": "okx-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "okx-sdk"
}
        
Elapsed time: 1.79301s