PrivateRESTConnection¶
- class base.MarketConnection.PrivateRESTConnection(credentials: dict, use_server_time=False, simulate_flag=False, cn_flag=False)¶
Bases:
base.NetworkHandler.RESTHandler
通过REST api向市场发出请求
可用的各类操作可以参见 https://www.ouyi.cc/docs-v5/zh/#rest-api
- 基本包含几类api
Trading (常用)
Account (不常用)
Funding (不常用)
Market Data (不常用 - 使用
base.MarketConnection.PublicDataConnection
)Public Basic (不常用)
System Status (不常用)
Sub-Account (不常用)
- Parameters
credentials – 包含api信息的字典, 其应包含以下key: api_key, api_secret_key, passphrase
use_server_time – 是否使用服务器时间请求, 会极大增加时间开销, 应设为False
simulate_flag – 是否发送到模拟盘
cn_flag – 是否通过代理发送请求(默认使用ss代理的1080端口)
Methods Summary
Adjustment_margin
(instId, posSide, type, amt)amend_multiple_orders
(orders_data)amend_order
(instId[, cxlOnFail, ordId, …])balances
(subAcct)bills
([ccy, type, subAcct, after, before, limit])cancel_algo_order
(params)cancel_multiple_orders
(orders_data)cancel_order
(instId[, ordId, clOrdId])close_positions
(instId, mgnMode[, posSide, ccy])coin_withdraw
(ccy, amt, dest, toAddr, pwd, fee)control_transfer
(ccy, amt, froms, to, …)create
(pwd, subAcct, label, Passphrase[, …])delete
(pwd, subAcct, apiKey)discount_interest_free_quota
([ccy])funding_rate_history
(instId[, after, …])funds_transfer
(ccy, amt, froms, to[, type, …])get_account
([ccy])get_balances
([ccy])get_bills
(ccy[, type, after, before, limit])get_bills_detail_3_months
([instType, ccy, …])get_bills_detail_7_days
([instType, ccy, …])get_candlesticks
(instId[, after, before, …])get_deliver_history
(instType, uly[, after, …])get_deposit_address
(ccy)get_deposit_history
([ccy, state, after, …])get_estimated_price
(instId)get_fee_rates
(instType[, instId, uly, category])get_fills
([instType, uly, instId, ordId, …])get_funding_rate
(instId)get_history_candlesticks
(instId[, after, …])get_index_candlesticks
(instId[, after, …])get_index_ticker
([quoteCcy, instId])get_instruments
(instType[, uly, instId])get_interest_accrued
([instId, ccy, mgnMode, …])get_leverage
(instId, mgnMode)get_liquidation_orders
(instType[, mgnMode, …])get_mark_price
(instType[, uly, instId])get_markprice_candlesticks
(instId[, after, …])get_max_avail_size
(instId, tdMode[, ccy, …])get_max_load
(instId, mgnMode, mgnCcy)get_max_withdrawal
([ccy])get_maximum_trade_size
(instId, tdMode[, ccy, px])get_open_interest
(instType[, uly, instId])get_opt_summary
(uly[, expTime])get_order_book
(instId[, sz])get_order_list
([instType, uly, instId, …])get_orders
(instId[, ordId, clOrdId])get_orders_history
(instType[, uly, instId, …])get_position_mode
(posMode)get_positions
([instType, instId])get_price_limit
(instId)get_ticker
(instId)get_tickers
(instType[, uly])get_trades
(instId[, limit])get_withdrawal_history
([ccy, state, after, …])order_algos_history
(ordType[, state, …])order_algos_list
(ordType[, algoId, …])orders_history_archive
(instType[, uly, …])place_algo_order
(instId, tdMode, side, …)place_multiple_orders
(orders_data)place_order
(instId, tdMode, side, ordType, sz)purchase_redempt
(ccy, amt, side)reset
(pwd, subAcct, label, apiKey, perm[, ip])set_greeks
(greeksType)set_leverage
(lever, mgnMode[, instId, ccy, …])status
([state])view_list
([enable, subAcct, after, before, …])Methods Documentation
- Adjustment_margin(instId, posSide, type, amt)¶
- amend_multiple_orders(orders_data)¶
- amend_order(instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='')¶
- balances(subAcct)¶
- bills(ccy='', type='', subAcct='', after='', before='', limit='')¶
- cancel_algo_order(params)¶
- cancel_multiple_orders(orders_data)¶
- cancel_order(instId, ordId='', clOrdId='')¶
- close_positions(instId, mgnMode, posSide='', ccy='')¶
- coin_withdraw(ccy, amt, dest, toAddr, pwd, fee)¶
- control_transfer(ccy, amt, froms, to, fromSubAccount, toSubAccount)¶
- create(pwd, subAcct, label, Passphrase, perm='', ip='')¶
- delete(pwd, subAcct, apiKey)¶
- discount_interest_free_quota(ccy='')¶
- funding_rate_history(instId, after='', before='', limit='')¶
- funds_transfer(ccy, amt, froms, to, type='0', subAcct='', instId='', toInstId='')¶
- get_account(ccy='')¶
- get_account_config()¶
- get_balances(ccy='')¶
- get_bills(ccy, type='', after='', before='', limit='')¶
- get_bills_detail_3_months(instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', limit='')¶
- get_bills_detail_7_days(instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', limit='')¶
- get_candlesticks(instId, after='', before='', bar='', limit='')¶
- get_currency()¶
- get_deliver_history(instType, uly, after='', before='', limit='')¶
- get_deposit_address(ccy)¶
- get_deposit_history(ccy='', state='', after='', before='', limit='')¶
- get_estimated_price(instId)¶
- get_fee_rates(instType, instId='', uly='', category='')¶
- get_fills(instType='', uly='', instId='', ordId='', after='', before='', limit='')¶
- get_funding_rate(instId)¶
- get_history_candlesticks(instId, after='', before='', bar='', limit='')¶
- get_index_candlesticks(instId, after='', before='', bar='', limit='')¶
- get_index_ticker(quoteCcy='', instId='')¶
- get_instruments(instType, uly='', instId='')¶
- get_interest_accrued(instId='', ccy='', mgnMode='', after='', before='', limit='')¶
- get_leverage(instId, mgnMode)¶
- get_liquidation_orders(instType, mgnMode='', instId='', ccy='', uly='', alias='', state='', before='', after='', limit='')¶
- get_mark_price(instType, uly='', instId='')¶
- get_markprice_candlesticks(instId, after='', before='', bar='', limit='')¶
- get_max_avail_size(instId, tdMode, ccy='', reduceOnly='')¶
- get_max_load(instId, mgnMode, mgnCcy)¶
- get_max_withdrawal(ccy='')¶
- get_maximum_trade_size(instId, tdMode, ccy='', px='')¶
- get_open_interest(instType, uly='', instId='')¶
- get_opt_summary(uly, expTime='')¶
- get_order_book(instId, sz='')¶
- get_order_list(instType='', uly='', instId='', ordType='', state='', after='', before='', limit='')¶
- get_orders(instId, ordId='', clOrdId='')¶
- get_orders_history(instType, uly='', instId='', ordType='', state='', after='', before='', limit='')¶
- get_position_mode(posMode)¶
- get_positions(instType='', instId='')¶
- get_price_limit(instId)¶
- get_system_time()¶
- get_ticker(instId)¶
- get_tickers(instType, uly='')¶
- get_trades(instId, limit='')¶
- get_withdrawal_history(ccy='', state='', after='', before='', limit='')¶
- order_algos_history(ordType, state='', algoId='', instType='', instId='', after='', before='', limit='')¶
- order_algos_list(ordType, algoId='', instType='', instId='', after='', before='', limit='')¶
- orders_history_archive(instType, uly='', instId='', ordType='', state='', after='', before='', limit='')¶
- place_algo_order(instId, tdMode, side, ordType, sz, ccy='', posSide='', reduceOnly='', tpTriggerPx='', tpOrdPx='', slTriggerPx='', slOrdPx='', triggerPx='', orderPx='')¶
- place_multiple_orders(orders_data)¶
- place_order(instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='', reduceOnly='')¶
- purchase_redempt(ccy, amt, side)¶
- reset(pwd, subAcct, label, apiKey, perm, ip='')¶
- set_greeks(greeksType)¶
- set_leverage(lever, mgnMode, instId='', ccy='', posSide='')¶
- status(state='')¶
- view_list(enable='', subAcct='', after='', before='', limit='')¶