okxv5 1.8.11__py3-none-any.whl → 1.8.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,915 @@
1
+ Metadata-Version: 2.1
2
+ Name: okxv5
3
+ Version: 1.8.12
4
+ Summary: okx RestAPI
5
+ Home-page:
6
+ Author:
7
+ Author-email:
8
+ License: Apache-2.0
9
+ Keywords: okx,v5,RestAPI
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: requests
12
+ Requires-Dist: PyYAML
13
+ Requires-Dist: numpy
14
+ Requires-Dist: pandas
15
+
16
+ ### okx RestAPI如何使用?python
17
+
18
+ `python版本:3.6 - 3.10`
19
+
20
+
21
+ #### 第一步:配置个人信息
22
+
23
+ 2.1 如果还未有API,可[点击](https://www.okx.com/account/users/myApi)前往官网进行申请
24
+ api_key = ""
25
+ secret_key = ""
26
+ passphrase = ""
27
+
28
+ #### 第二步:调用接口
29
+ * RestAPI
30
+ * 解开相应方法的注释传参调用各接口即可
31
+
32
+ import json
33
+ import okxv5.Account_api as Account
34
+ import okxv5.Funding_api as Funding
35
+ import okxv5.Market_api as Market
36
+ import okxv5.Public_api as Public
37
+ import okxv5.Trade_api as Trade
38
+ import okxv5.status_api as Status
39
+ import okxv5.subAccount_api as SubAccount
40
+ import okxv5.TradingData_api as TradingData
41
+ import okxv5.Broker_api as Broker
42
+ import okxv5.Convert_api as Convert
43
+ import okxv5.FDBroker_api as FDBroker
44
+ import okxv5.Rfq_api as Rfq
45
+ import okxv5.TradingBot_api as TradingBot
46
+ import okxv5.Finance_api as Finance
47
+ import okxv5.Copytrading_api as Copytrading
48
+ import okxv5.Recurring_api as Recurring
49
+ import okxv5.SprdApi_api as Sprd
50
+ import okxv5.Singal_api as Signal
51
+
52
+ if __name__ == '__main__':
53
+ api_key = ""
54
+ secret_key = ""
55
+ passphrase = ""
56
+
57
+ # flag是实盘与模拟盘的切换参数 flag is the key parameter which can help you to change between demo and real trading.
58
+ # flag = '1' # 模拟盘 demo trading
59
+ # flag = '0' # 实盘 real trading
60
+
61
+ # account api
62
+ # accountAPI = Account.AccountAPI(api_key, secret_key, passphrase, False, flag)
63
+ # 获取交易产品基础信息
64
+ # result = accountAPI.get_account_instruments(instType = 'SWAP', uly = '', instFamily = '', instId = '')
65
+ # 查看账户持仓风险 GET Position_risk
66
+ # result = accountAPI.get_position_risk('SWAP')
67
+ # 查看账户余额 Get Balance
68
+ #result = accountAPI.get_account('USDT')
69
+ # 查看持仓信息 Get Positions
70
+ # result = accountAPI.get_positions('FUTURES', 'BTC-USD-210402')
71
+ # 查看历史持仓信息
72
+ # result = accountAPI.get_positions_history(instType = '', instId = '', mgnMode = '', type = '', after = '', before = '', limit = '', posId = '359410150083538946')
73
+ # 账单流水查询(近七天) Get Bills Details (recent 7 days)
74
+ # result = accountAPI.get_bills_detail(instType = 'SWAP', ccy = 'BTC', mgnMode = 'cross', instId = 'BTC-USDT-SWAP')
75
+ # 账单流水查询(近三个月) Get Bills Details (recent 3 months)
76
+ # result = accountAPI.get_bills_details('FUTURES', 'BTC', 'cross')
77
+ # 查看账户配置 Get Account Configuration
78
+ # result = accountAPI.get_account_config()
79
+ # 设置持仓模式 Set Position mode
80
+ # result = accountAPI.get_position_mode('long_short_mode')
81
+ # 设置杠杆倍数 Set Leverage
82
+ # result = accountAPI.set_leverage(instId='BTC-USD-210402', lever='10', mgnMode='cross')
83
+ # 获取最大可交易数量 Get Maximum Tradable Size For Instrument
84
+ # result = accountAPI.get_maximum_trade_size(instId='BTC-USDT-SWAP', tdMode='cross',ccy='',px='',leverage='10',unSpotOffset='false')
85
+ # 获取最大可用数量 Get Maximum Available Tradable Amount
86
+ # result = accountAPI.get_max_avail_size(instId='BTC-USDT-SWAP', tdMode='isolated', ccy='BTC', reduceOnly='', unSpotOffset='false',quickMgnType='')
87
+ # 调整保证金 Increase/Decrease margint
88
+ # result = accountAPI.Adjustment_margin('BTC-USDT-210409', 'long', 'add', '100')
89
+ # 获取杠杆倍数 Get Leverage
90
+ # result = accountAPI.get_leverage(instId = 'BTC-USDT-SWAP', mgnMode = 'isolated', ccy = '')
91
+ # 获取交易产品最大可借 Get the maximum loan of instrument
92
+ # result = accountAPI.get_max_load('BTC-USDT', 'cross', 'BTC')
93
+ # 获取当前账户交易手续费费率 Get Fee Rates
94
+ # result = accountAPI.get_fee_rates(instType = 'FUTURES',instId = '', category='1',instFamily = '',ruleType = '')
95
+ # 获取计息记录 Get interest-accrued
96
+ # result = accountAPI.get_interest_accrued('BTC-USDT', 'BTC', 'isolated', '', '', '10', '')
97
+ # 获取用户当前杠杆借币利率 Get interest rate
98
+ # result = accountAPI.get_interest_rate()
99
+ # 期权希腊字母PA / BS切换 Set Greeks (PA/BS)
100
+ # result = accountAPI.set_greeks('BS')
101
+ # 逐仓交易设置 Set Isolated Mode
102
+ # result = accountAPI.set_isolated_mode()
103
+ # 查看账户最大可转余额 Get Maximum Withdrawals
104
+ # result = accountAPI.get_max_withdrawal('')
105
+ # 查看账户特定风险状态 Get account risk state (Only applicable to Portfolio margin account)
106
+ # result = accountAPI.get_account_risk()
107
+ # 一键借币模式手动借币还币
108
+ # result = accountAPI.quick_margin_borrow_repay(instId='BTC-USDT', ccy='BTC', side='borrow', amt='1')
109
+ # 获取一键借币还币历史
110
+ # result = accountAPI.quick_margin_borrow_repay_history(instId='', ccy='', side='', after='', before='', begin='', end='', limit='')
111
+ # 尊享借币还币 GET Enjoy borrowing and returning money
112
+ # result = accountAPI.borrow_repay(ccy = 'BTC', side = 'borrow', amt = '10', ordId = '')
113
+ # 获取尊享借币还币历史 Get the privileged currency borrowing and repayment history
114
+ # result = accountAPI.get_borrow_repay_history(ccy = '', after = '', before = '', limit = '')
115
+ # 获取尊享借币计息记录
116
+ # result = accountAPI.vip_interest_accrued(ccy = '', ordId = '', after = '', before = '', limit = '')
117
+ # 获取尊享借币扣息记录
118
+ # result = accountAPI.vip_interest_deducted(ordId = '', ccy = '', after = '', before = '', limit = '')
119
+ # 尊享借币订单列表
120
+ # result = accountAPI.vip_loan_order_list(ordId = '', state = '', ccy = '', after = '', before = '', limit = '')
121
+ # 尊享借币订单详情
122
+ # result = accountAPI.vip_loan_order_detail(ordId = '123', ccy = '', after = '', before = '', limit = '')
123
+ # 设置子账户尊享借币比率 POST SET LOAN ALLOCATION
124
+ # result = accountAPI.set_loan_allocation(enable = 'true',subAcct = '',loanAlloc = '')
125
+ # 获取子账户借币利率与限额 GET INTEREST LIMITS
126
+ # result = accountAPI.insterst_limits(subAcct = '',ccy = '')
127
+ # 获取借币利率与限额 GET Obtain borrowing rate and limit
128
+ # result = accountAPI.get_interest_limits(type = '2', ccy = 'ETH')
129
+ # 组合保证金的虚拟持仓保证金计算 POST Simulated Margin
130
+ # result = accountAPI.get_simulated_margin(instType = '', inclRealPos = '', spotOffsetType = '', simPos = [{"instId":"BTC-USDT-SWAP","pos":"1"}])
131
+ # 查看账户Greeks GET GREEKS
132
+ # result = accountAPI.get_greeks()
133
+ # 获取组合保证金模式全仓限制
134
+ # result = accountAPI.position_tiers(instType = 'SWAP', uly = 'BTC-USDT')
135
+ # 设置组合保证金账户风险对冲模式
136
+ # result = accountAPI.set_riskOffset_type(type = '1')
137
+ # 开通期权交易
138
+ # result = accountAPI.activate_option()
139
+ # 设置自动借币
140
+ # result = accountAPI.set_auto_loan(autoLoan = '')
141
+ # 预设置账户模式切换 POST /api/v5/account/account-level-switch-preset
142
+ # result = accountAPI.account_level_switch_preset(acctLv = '', lever = '', riskOffsetType = '')
143
+ # 预检查账户模式切换 GET /api/v5/account/set-account-switch-precheck
144
+ # result = accountAPI.set_account_switch_precheck(acctLv = '')
145
+ # 重置 MMP 状态
146
+ # result = accountAPI.mmp_reset()
147
+ # 设置MMP
148
+ # result = accountAPI.mmp_config(instFamily='',timeInterval='',frozenInterval='',qtyLimit='')
149
+ # 查看 MMP 配置
150
+ # result = accountAPI.mmp(instFamily='')
151
+ # 设置账户模式 POST /api/v5/account/set-account-level
152
+ # result = accountAPI.set_account_level(acctLv='')
153
+ # 仓位创建器 POST /api/v5/account/position-builder
154
+ # result = accountAPI.position_builder()
155
+ # 设置现货对冲占用 POST /api/v5/account/set-riskOffset-amt
156
+ # result = accountAPI.set_riskOffset_amt(ccy = 'BTC', clSpotInUseAmt = '0.01')
157
+ # 获取固定借币限额 GET /api/v5/account/fixed-loan/borrowing-limit
158
+ # result = accountAPI.get_fixed_loan_borrowing_limit()
159
+ # 获取固定借币询价 GET /api/v5/account/fixed-loan/borrowing-quote
160
+ # result = accountAPI.get_fixed_loan_borrowing_quote(type = '', ccy = '', amt = '', maxRate = '', term = '', ordId = '')
161
+ # 固定借币下单 POST /api/v5/account/fixed-loan/borrowing-order
162
+ # result = accountAPI.fixed_loan_borrowing_order(ccy = '', amt = '', maxRate = '', term = '', reborrow = '', reborrowRate = '')
163
+ # 修改固定借币订单 POST /api/v5/account/fixed-loan/amend-borrowing-order
164
+ # result = accountAPI.fixed_loan_amend_borrowing_order(ordId = '111111111111', reborrow = '', renewMaxRate = '')
165
+ # 固定借币手动续借 POST /api/v5/account/fixed-loan/manual-reborrow
166
+ # result = accountAPI.fixed_loan_manual_reborrow(ordId = '111111111111', maxRate = '0.01')
167
+ # 固定借币手动还币 POST /api/v5/account/fixed-loan/repay-borrowing-order
168
+ # result = accountAPI.fixed_loan_repay_borrowing_order(ordId = '111111111111')
169
+ # 固定借币转市场借币 POST /api/v5/account/fixed-loan/convert-to-market-loan
170
+ # result = accountAPI.convert_to_market_loan(ordId = '')
171
+ # 固定借币减少负债
172
+ # result = accountAPI.reduce_liabilities(ordId = '1', pendingRepay = '')
173
+ # 获取固定借币订单信息 GET /api/v5/account/fixed-loan/borrowing-orders-list
174
+ # result = accountAPI.get_fixed_loan_borrowing_orders_list(ordId = '', ccy = '', state = '', after = '', before = '', limit = '', term = '')
175
+ # 手动借/还币 POST /api/v5/account/spot-manual-borrow-repay
176
+ # result = accountAPI.spot_manual_borrow_repay(ccy = 'BTC', side = 'borrow', amt = '0.1')
177
+ # 设置自动还币 POST /api/v5/account/set-auto-repay
178
+ # result = accountAPI.set_auto_repay(autoRepay = 'true')
179
+ # 获取借/还币历史
180
+ # result = accountAPI.get_spot_borrow_repay_history(ccy = '', type = '', after = '', before = '', limit = '')
181
+ # 获取账户限速 GET /api/v5/trade/account-rate-limit
182
+ # result = accountAPI.account_rate_limit()
183
+ # 申请账单流水(自 2021 年)
184
+ # result = accountAPI.bills_history_archive(year = '', quarter = '')
185
+ # 获取账单流水(自 2021 年)
186
+ # result = accountAPI.get_bills_history_archive(year = '', quarter = '')
187
+
188
+ # funding api
189
+ # fundingAPI = Funding.FundingAPI(api_key, secret_key, passphrase, False, flag)
190
+ # 获取充值地址信息 Get Deposit Address
191
+ # result = fundingAPI.get_deposit_address('')
192
+ # 获取资金账户余额信息 Get Balance
193
+ # result = fundingAPI.get_balances('BTC')
194
+ # 资金划转 Funds Transfer
195
+ # result = fundingAPI.funds_transfer(ccy='USDT', amt='1', type='1', froms="6", to="18",subAcct='',loanTrans='',clientId='',omitPosRisk='')
196
+ # 获取资金划转状态 Transfer State
197
+ # result = fundingAPI.transfer_state(transId='', type='')
198
+ # 提币 Withdrawal
199
+ # result = fundingAPI.coin_withdraw(ccy='', amt='', dest='', toAddr='', fee='', chain='', areaCode='', clientId='')
200
+ # 获取充值记录 Get Deposit History
201
+ # result = fundingAPI.get_deposit_history()
202
+ # 获取币种列表 Get Currencies
203
+ # result = fundingAPI.get_currency('ETH,BTC')
204
+ # 资金流水查询 Asset Bills Details
205
+ # result = fundingAPI.get_bills()
206
+ # 闪电网络充币
207
+ # result = fundingAPI.get_deposit_lightning(ccy='BTC',amt='0.01')
208
+ # 闪电网络提币
209
+ # result = fundingAPI.withdrawal_lightning(ccy='BTC',invoice='0.01',memo='')
210
+ # 撤销提币 CANCEL_WITHDRAWAL
211
+ # result = fundingAPI.cancel_withdrawal(wdId='BTC')
212
+ # 获取提币记录 Get Withdrawal History
213
+ # result = fundingAPI.get_withdrawal_history()
214
+ # 获取充值/提现的详细状态
215
+ # result = fundingAPI.deposit_withdraw_status(wdId = '', txId = '', ccy = '', to = '', chain = '')
216
+ # 小额资产兑换CONVERT_DUST_ASSETS (已经下线)
217
+ # result = fundingAPI.convert_dust_assets()
218
+ # 获取账户资产估值 GET Obtain account asset valuation
219
+ # result = fundingAPI.get_asset_valuation(ccy = 'USDT')
220
+ # 获取市场借贷信息(公共) GET LENDING RATE HISTORY
221
+ # result = fundingAPI.get_lending_rate_history(ccy = '')
222
+ # 获取市场借贷历史(公共)GET LENDING RATE SUMMARY
223
+ # result = fundingAPI.get_lending_rate_summary(ccy = '')
224
+ # 获取交易所列表
225
+ # result = fundingAPI.exchange_list()
226
+ # 申请月结单 (近一年)
227
+ # result = fundingAPI.monthly_statement(month='')
228
+ # 获取月结单 (近一年)
229
+ # result = fundingAPI.monthly_statement(month='')
230
+
231
+ # convert api
232
+ # convertAPI = Convert.ConvertAPI(api_key, secret_key, passphrase, False, flag)
233
+ # 获取闪兑币种列表 Get Currencies
234
+ # result = convertAPI.get_currencies()
235
+ # 获取闪兑币对信息 Get Currency-pair
236
+ # result = convertAPI.get_currency_pair(fromCcy = 'USDT', toCcy = 'BTC')
237
+ # 闪兑预估询价 Estimate-quote
238
+ # result = convertAPI.estimate_quote(baseCcy = 'OKB', quoteCcy = 'USDT', side = 'sell', rfqSz = '1', rfqSzCcy = 'USDT', clQReqId = '')
239
+ # 闪兑交易 Convert-trade
240
+ # result = convertAPI.convert_trade(quoteId='quoterOKB-USDT16480319751107680', baseCcy='OKB', quoteCcy='USDT',
241
+ # side='sell', sz='1', szCcy='USDT', clTReqId='',tag='')
242
+ # 获取闪兑交易历史 Get Convert-history
243
+ # result = convertAPI.get_convert_history(after = '', before = '', limit = '')
244
+
245
+ # market api
246
+ # marketAPI = Market.MarketAPI(api_key, secret_key, passphrase, True, flag)
247
+ # 获取所有产品行情信息 Get Tickers
248
+ # result = marketAPI.get_tickers('SPOT')
249
+ # 获取单个产品行情信息 Get Ticker
250
+ # result = marketAPI.get_ticker('BTC-USDT')
251
+ # 获取指数行情 Get Index Tickers
252
+ # result = marketAPI.get_index_ticker('BTC', 'BTC-USD')
253
+ # 获取产品深度 Get Order Book
254
+ # result = marketAPI.get_orderbook('BTC-USDT-210402', '400')
255
+ # 获取产品轻量深度(该接口已下线)
256
+ # result = marketAPI.get_books_lite(instId = 'BTC-USDT')
257
+ # 获取产品完整深度 GET /api/v5/market/books-full
258
+ # result = marketAPI.books_full()
259
+ # 获取所有交易产品K线数据 Get Candlesticks
260
+ # result = marketAPI.get_candlesticks('BTC-USDT-210924', bar='1m')
261
+ # 获取交易产品历史K线数据(仅主流币实盘数据) Get Candlesticks History(top currencies in real-trading only)
262
+ # result = marketAPI.get_history_candlesticks('BTC-USDT')
263
+ # 获取指数K线数据 Get Index Candlesticks
264
+ # result = marketAPI.get_index_candlesticks('BTC-USDT')
265
+ # 获取指数历史K线数据 Get History Index Candlesticks
266
+ # result = marketAPI.get_history_index_candlesticks(instId = 'BTC-USDT', after = '', before = '', bar = '', limit = '')
267
+ # 获取标记价格K线数据 Get Mark Price Candlesticks
268
+ # result = marketAPI.get_markprice_candlesticks('BTC-USDT')
269
+ # 获取标记价格历史K线数据 Get Mark Price Candlesticks
270
+ # result = marketAPI.get_history_markprice_candlesticks(instId = 'BTC-USDT', after = '', before = '', bar = '', limit = '')
271
+ # 获取交易产品公共成交数据 Get Trades
272
+ # result = marketAPI.get_trades('BTC-USDT', '400')
273
+ # 获取期权品种公共成交数据
274
+ # result = marketAPI.instrument_family_trades(instFamily = 'BTC-USD')
275
+ # 获取平台24小时成交总量 Get Platform 24 Volume
276
+ # result = marketAPI.get_volume()
277
+ # Oracle 上链交易数据 GET Oracle
278
+ # result = marketAPI.get_oracle()
279
+ # 获取指数成分数据 GET Index Components
280
+ # result = marketAPI.get_index_components(index='')
281
+ # 获取法币汇率 GET exchange rate in legal currency
282
+ # result = marketAPI.get_exchange_rate()
283
+ # 获取交易产品公共历史成交数据
284
+ # result = marketAPI.get_history_trades(instId = 'BTC-USDT', after = '', before = '', limit = '')
285
+ # 获取大宗交易所有产品行情信息
286
+ # result = marketAPI.get_block_tickers(instType = 'SWAP', uly = 'BTC-USDT')
287
+ # 获取大宗交易单个产品行情信息
288
+ # result = marketAPI.get_block_ticker(instId = 'BTC-USDT')
289
+ # 获取大宗交易公共成交数据
290
+ # result = marketAPI.get_block_trades(instId = 'BTC-USDT')
291
+ # 集合竞价信息 GET /api/v5/market/call-auction-details
292
+ # result = marketAPI.get_call_auction_details(instId = 'BTC-USDT')
293
+
294
+ # public api
295
+ #publicAPI = Public.PublicAPI(api_key, secret_key, passphrase, False, flag)
296
+ # 获取交易产品基础信息 Get instrument
297
+ # result = publicAPI.get_instruments(instType = 'FUTURES', uly = '', instFamily = 'BTC-USDT', instId = '')
298
+ # 获取交割和行权记录 Get Delivery/Exercise History
299
+ # result = publicAPI.get_deliver_history('FUTURES', 'BTC-USD')
300
+ # 获取持仓总量 Get Open Interest
301
+ # result = publicAPI.get_open_interest('SWAP')
302
+ # 获取永续合约当前资金费率 Get Funding Rate
303
+ # result = publicAPI.get_funding_rate('BTC-USD-SWAP')
304
+ # 获取永续合约历史资金费率 Get Funding Rate History
305
+ # result = publicAPI.funding_rate_history('BTC-USD-SWAP')
306
+ # 获取限价 Get Limit Price
307
+ # result = publicAPI.get_price_limit('BTC-USD-210402')
308
+ # 获取期权定价 Get Option Market Data
309
+ # result = publicAPI.get_opt_summary('BTC-USD')
310
+ # 获取预估交割/行权价格 Get Estimated Delivery/Excercise Price
311
+ # result = publicAPI.get_estimated_price('ETH-USD-210326')
312
+ # 获取免息额度和币种折算率 Get Discount Rate And Interest-Free Quota
313
+ # result = publicAPI.discount_interest_free_quota('')
314
+ # 获取系统时间 Get System Time
315
+ # result = publicAPI.get_system_time()
316
+ # 获取平台公共爆仓单信息 Get Liquidation Orders
317
+ # result = publicAPI.get_liquidation_orders('FUTURES', uly='BTC-USDT', alias='next_quarter', state='filled')
318
+ # 获取标记价格 Get Mark Price
319
+ # result = publicAPI.get_mark_price('FUTURES')
320
+ # 获取合约衍生品仓位档位 Get Position Tiers
321
+ # result = publicAPI.get_tier(instType='MARGIN', instId='BTC-USDT', tdMode='cross')
322
+ # 获取杠杆利率和借币限额公共信息 Get Interest Rate and Loan Quota
323
+ # result = publicAPI.get_interest_loan()
324
+ # 获取合约衍生品标的指数 Get underlying
325
+ # result = publicAPI.get_underlying(instType='FUTURES')
326
+ # 获取尊享借币杠杆利率和借币限额 GET Obtain the privileged currency borrowing leverage rate and currency borrowing limit
327
+ # result = publicAPI.get_vip_interest_rate_loan_quota()
328
+ # 获取风险准备金余额
329
+ # result = publicAPI.get_insurance_fund(instType = 'SWAP', type = '', uly = 'BTC-USDT', ccy = '', before = '', after = '', limit = '')
330
+ # 张币转换
331
+ # result = publicAPI.convert_contract_coin(type = '2', instId = 'BTC-USDT-SWAP', sz = '1', px = '',
332
+ # unit = '', opType='')
333
+ # 获取期权价格梯度
334
+ # result = publicAPI.instrument_tick_bands(instType = 'OPTION', instFamily = '')
335
+ # 获取期权公共成交数据
336
+ # result = publicAPI.option_trades(instId = '', instFamily = 'BTC-USD', optType = '')
337
+
338
+ # trading data
339
+ #tradingDataAPI = TradingData.TradingDataAPI(api_key, secret_key, passphrase, False, flag)
340
+ # 获取支持币种 Get support coin
341
+ # result = tradingDataAPI.get_support_coin()
342
+ # 获取获取合约持仓量历史
343
+ # result = tradingDataAPI.get_open_interest_history(instId = 'BTC-USDT-SWAP', period = '5m', end = '1597027383085', begin = '1597027383085', limit = '')
344
+ # 获取币币或衍生品主动买入/卖出情况 Get taker volume
345
+ # result = tradingDataAPI.get_taker_volume(ccy='BTC', instType='SPOT')
346
+ # 获取合约主动买入/卖出情况
347
+ # result = tradingDataAPI.get_taker_volume_contract(instId = 'BTC-USDT-SWAP')
348
+ # 获取杠杆多空比 Get Margin lending ratio
349
+ # result = tradingDataAPI.get_margin_lending_ratio('BTC')
350
+ # 获取精英交易员合约多空持仓人数比
351
+ # result = tradingDataAPI.get_long_short_account_ratio_contract_top_trader(instId = 'BTC-USDT-SWAP', period = '', end = '', begin = '', limit = '')
352
+ # 获取精英交易员合约多空持仓仓位比
353
+ # result = tradingDataAPI.get_long_short_position_ratio_contract_top_trader(instId = 'BTC-USDT-SWAP', period = '', end = '', begin = '', limit = '')
354
+ # 获取合约多空持仓人数比
355
+ # result = tradingDataAPI.get_long_short_account_ratio_contract(instId = 'BTC-USDT-SWAP', period = '', end = '', begin = '', limit = '')
356
+ # 获取多空持仓人数比 Get Long/Short ratio
357
+ # result = tradingDataAPI.get_long_short_ratio('BTC')
358
+ # 获取持仓总量及交易量 Get contracts open interest and volume
359
+ # result = tradingDataAPI.get_contracts_interest_volume('BTC')
360
+ # 获取期权合约持仓总量及交易量 Get Options open interest and volume
361
+ # result = tradingDataAPI.get_options_interest_volume('BTC')
362
+ # 看涨/看跌期权合约 持仓总量比/交易总量比 Get Put/Call ratio
363
+ # result = tradingDataAPI.get_put_call_ratio('BTC')
364
+ # 看涨看跌持仓总量及交易总量(按到期日分) Get open interest and volume (expiry)
365
+ # result = tradingDataAPI.get_interest_volume_expiry('BTC')
366
+ # 看涨看跌持仓总量及交易总量(按执行价格分)Get open interest and volume (strike)
367
+ # result = tradingDataAPI.get_interest_volume_strike('BTC', '20210924')
368
+ # 看跌/看涨期权合约 主动买入/卖出量 Get Taker flow
369
+ # result = tradingDataAPI.get_taker_flow('BTC')
370
+
371
+ # trade api
372
+ # tradeAPI = Trade.TradeAPI(api_key, secret_key, passphrase, False, flag)
373
+ # 下单 Place Order
374
+ # result = tradeAPI.place_order(instId='BTC-USDT-SWAP', tdMode='cross', side='sell', posSide='',
375
+ # ordType='market', sz='100',tgtCcy='',banAmend='',quickMgnType='auto_borrow',
376
+ # tpTriggerPx = '1111', tpOrdPx = '1000', slTriggerPx = '', slOrdPx = '', tpTriggerPxType = '', slTriggerPxType = '')
377
+ # 批量下单 Place Multiple Orders
378
+ # result = tradeAPI.place_multiple_orders([
379
+ # {'instId': 'BTC-USD-210402', 'tdMode': 'isolated', 'side': 'buy', 'ordType': 'limit', 'sz': '1', 'px': '17400',
380
+ # 'posSide': 'long',
381
+ # 'clOrdId': 'a12344', 'tag': 'test1210','tgtCcy':''},
382
+ # {'instId': 'BTC-USD-210409', 'tdMode': 'isolated', 'side': 'buy', 'ordType': 'limit', 'sz': '1', 'px': '17359',
383
+ # 'posSide': 'long',
384
+ # 'clOrdId': 'a12344444', 'tag': 'test1211','tgtCcy':''}
385
+ # ])
386
+
387
+ # 撤单 Cancel Order
388
+ # result = tradeAPI.cancel_order('BTC-USD-201225', '257164323454332928')
389
+ # 批量撤单 Cancel Multiple Orders
390
+ # result = tradeAPI.cancel_multiple_orders([
391
+ # {"instId": "BTC-USD-210402", "ordId": "297389358169071616"},
392
+ # {"instId": "BTC-USD-210409", "ordId": "297389358169071617"}
393
+ # ])
394
+
395
+ # 修改订单 Amend Order
396
+ # result = tradeAPI.amend_order()
397
+ # 批量修改订单 Amend Multiple Orders
398
+ # result = tradeAPI.amend_multiple_orders(
399
+ # [{'instId': 'BTC-USD-201225', 'cxlOnFail': 'false', 'ordId': '257551616434384896', 'newPx': '17880'},
400
+ # {'instId': 'BTC-USD-201225', 'cxlOnFail': 'false', 'ordId': '257551616652488704', 'newPx': '17882'}
401
+ # ])
402
+
403
+ # 市价仓位全平 Close Positions
404
+ # result = tradeAPI.close_positions(instId='ADA-USDT-SWAP', posSide='', mgnMode='cross',ccy='', autoCxl='',clOrdId='',tag='')
405
+ # 获取订单信息 Get Order Details
406
+ # result = tradeAPI.get_orders('BTC-USD-201225', '257173039968825345')
407
+ # 获取未成交订单列表 Get Order List
408
+ # result = tradeAPI.get_order_list(instType = '', uly = '', instFamily = '', instId = '', ordType = '', state = '', after = '', before = '', limit = '')
409
+ # 获取历史订单记录(近七天) Get Order History (last 7 days)
410
+ # result = tradeAPI.get_orders_history(instType = 'SWAP', uly = '', instFamily = '', instId = '', ordType = '', state = '', category = '', after = '', before = '', begin = '', end = '', limit = '')
411
+ # 获取历史订单记录(近三个月) Get Order History (last 3 months)
412
+ # result = tradeAPI.orders_history_archive(instType = 'SWAP', uly = '', instFamily = '', instId = '', ordType = '', state = '', category = '', after = '', before = '', begin = '', end = '', limit = '')
413
+ # 获取成交明细(三天) Get Transaction Details
414
+ # result = tradeAPI.get_fills(instType = '', uly = '', instFamily = '', instId = '', ordId = '', after = '', before = '', begin = '', end = '', limit = '')
415
+ # 获取成交明细(三个月) Get Transaction Details History
416
+ # result = tradeAPI.get_fills_history(instType='SPOT')
417
+ # 策略委托下单 Place Algo Order
418
+ # result = tradeAPI.place_algo_order('BTC-USDT-SWAP', 'isolated', 'buy', ordType='conditional',
419
+ # sz='100',posSide='long', tpTriggerPx='60000', tpOrdPx='59999',
420
+ # tpTriggerPxType = 'last', slTriggerPxType = 'last', algoClOrdId ='123456',
421
+ # quickMgnType='', closeFraction = '1',cxlOnClosePos= '', attachAlgoClOrdId='',
422
+ # )
423
+ # 撤销策略委托订单 Cancel Algo Order
424
+ # result = tradeAPI.cancel_algo_order([{'algoId': '297394002194735104', 'instId': 'BTC-USDT-210409'}])
425
+ # 修改策略委托订单 POST AMEND ALGOS
426
+ # result = tradeAPI.amend_algos(instId = '', algoId = '', algoClOrdId = '', cxlOnFail = '', reqId = '', newSz = '',
427
+ # newTpTriggerPx = '', newTpOrdPx = '', newTpTriggerPxType = '',
428
+ # newSlTriggerPx = '', newSlOrdPx = '', newSlTriggerPxType = '',
429
+ # newTriggerPx = '', newOrdPx = '', newTriggerPxType ='',
430
+ # attachAlgoOrds = [{"newTpTriggerPx":"","newTpTriggerPxType":"","newTpOrdPx":"",
431
+ # "newSlTriggerPx":"","newSlTriggerPxType":"","newSlOrdPx":""}]
432
+ # )
433
+ # 撤销高级策略委托订单
434
+ # result = tradeAPI.cancel_advance_algos([ {"algoId":"198273485","instId":"BTC-USDT"}])
435
+ # 获取策略委托单信息
436
+ # result = tradeAPI.get_order_algo(algoId = '', algoClOrdId = '')
437
+ # 获取未完成策略委托单列表 Get Algo Order List
438
+ # result = tradeAPI.order_algos_list('conditional', instType='FUTURES')
439
+ # 获取历史策略委托单列表 Get Algo Order History
440
+ # result = tradeAPI.order_algos_history('conditional', 'canceled', instType='FUTURES')
441
+ # 获取一键兑换主流币币种列表
442
+ # result = tradeAPI.easy_convert_currency_list(source = '1')
443
+ # 一键兑换主流币交易
444
+ # result = tradeAPI.easy_convert(fromCcy = '', toCcy = '', source = '')
445
+ # 获取一键兑换主流币历史记录
446
+ # result = tradeAPI.easy_convert_history(after = '', before = '', limit = '')
447
+ # 获取一键还债币种列表
448
+ # result = tradeAPI.one_click_repay_currency_list(debtType = '')
449
+ # 一键还债交易
450
+ # result = tradeAPI.one_click_repay(debtCcy = '', repayCcy = '')
451
+ # 获取一键还债历史记录
452
+ # result = tradeAPI.one_click_repay_history(after = '', before = '', limit = '')
453
+ # 撤销 MMP 订单
454
+ # result =tradeAPI.mass_cancel(instType = '', instFamily = '', lockInterval = '')
455
+ # 倒计时全部撤单
456
+ # result = tradeAPI.cancel_all_after(timeOut = '10', tag = '')
457
+ # 申请成交明细(近两年) POST /api/v5/trade/fills-archive (已下线)
458
+ # result = tradeAPI.fills_archive()
459
+ # 获取成交明细(近两年) GET /api/v5/trade/fills-archive (已下线)
460
+ # result = tradeAPI.fills_archives()
461
+ # 订单预检查 POST /api/v5/trade/order-precheck
462
+ # result = tradeAPI.order_precheck(instid = '', tdMode = '', side = '', posSide = '', ordType = '', sz = '', px = '',
463
+ # reduceOnly = '', tgtCcy = '', attachAlgoOrds = [{"attachAlgoClOrdId":"","tpTriggerPx":"","tpOrdPx":"",
464
+ # "tpOrdKind":"","slTriggerPx":"","slOrdPx":"","tpTriggerPxType":"","slTriggerPxType":"","sz":""}])
465
+
466
+
467
+ # 价差撮合交易 SprdAPI
468
+ # sprdAPI = Sprd.SprdAPI(api_key, secret_key, passphrase, False, flag)
469
+ # 下单 POST /api/v5/sprd/order
470
+ # result = sprdAPI.place(sprdId='',clOrdId='',tag='',side='',ordType='',sz='',px='')
471
+ # 撤单 POST /api/v5/sprd/cancel-order
472
+ # result = sprdAPI.cancel_order(ordId='',clOrdId='')
473
+ # 全部撤单 POST /api/v5/sprd/mass-cancel
474
+ # result = sprdAPI.mass_cancel(sprdId='')
475
+ # 修改订单(仅适用白名单用户) POST /api/v5/sprd/amend-order
476
+ # result = sprdAPI.amend_cancel(reqId='',ordId='', clOrdId='', newSz='', newPx='')
477
+ # 获取订单信息 GET /api/v5/sprd/order
478
+ # result = sprdAPI.order(ordId='',clOrdId='')
479
+ # 获取未成交订单列表 GET /api/v5/sprd/orders-pending
480
+ # result = sprdAPI.orders_pending(sprdId='',ordType='',state='',beginId='',endId='',limit='')
481
+ # 获取历史订单记录(近21天) GET /api/v5/sprd/orders-history (按创建时间倒叙排序)
482
+ # result = sprdAPI.orders_history(sprdId='',ordType='',state='',beginId='',endId='',begin='',end='',limit='')
483
+ # 获取历史订单记录(近三月)
484
+ # result = sprdAPI.orders_history_archive(sprdId='',ordType='',state='',beginId='',endId='',begin='',end='',limit='')
485
+ # 获取历史成交数据(近七天)GET /api/v5/sprd/trades (按时间倒叙排序)
486
+ # result = sprdAPI.trades(sprdId='',tradeId='',ordId='',beginId='',endId='',begin='',end='',limit='')
487
+ # 获取Spreads(公共)GET /api/v5/sprd/spreads
488
+ # result = sprdAPI.spreads(baseCcy='',instId='',sprdId='',state='')
489
+ # 获取Spread产品深度(公共)GET /api/v5/sprd/books
490
+ # result = sprdAPI.books(sprdId='',sz='')
491
+ # 获取单个Spread产品行情信息(公共) GET /api/v5/sprd/ticker
492
+ # result = sprdAPI.ticker(sprdId='')
493
+ # 获取公共成交数据(公共)GET /api/v5/sprd/public-trades
494
+ # result = sprdAPI.public_trades(sprdId='')
495
+ # 倒计时全部撤单 POST /api/v5/sprd/cancel-all-after
496
+ # result = sprdAPI.sprd_cancel_all_after(timeOut='10')
497
+ # 获取价差交易产品K线数据 GET /api/v5/market/sprd-candles
498
+ # result = sprdAPI.get_sprd_candles(sprdId='', bar='', after='', before='', limit='')
499
+ # 获取价差交易产品历史K线数据 GET /api/v5/market/sprd-history-candles
500
+ # result = sprdAPI.get_sprd_history_candles(sprdId='', bar='', after='', before='', limit='')
501
+
502
+ # 子账户API subAccount
503
+ # subAccountAPI = SubAccount.SubAccountAPI(api_key, secret_key, passphrase, False, flag)
504
+ # 查询子账户的交易账户余额(适用于母账户) Query detailed balance info of Trading Account of a sub-account via the master account
505
+ # result = subAccountAPI.balances(subAcct='')
506
+ # 查询子账户转账记录(仅适用于母账户) History of sub-account transfer(applies to master accounts only)
507
+ # result = subAccountAPI.bills()
508
+ # 查看子账户列表(仅适用于母账户) View sub-account list(applies to master accounts only)
509
+ # result = subAccountAPI.view_list()
510
+ # 子账户间划转 Transfer between subAccounts
511
+ # result = subAccountAPI.subAccount_transfer(ccy='USDT', amt='1', froms='6', to='6', fromSubAccount='1',
512
+ # toSubAccount='2', loanTrans='', omitPosRisk='')
513
+ # 查看被托管子账户列表 entrust-subaccount-list
514
+ # result = subAccountAPI.entrust_subaccount_list(subAcct = '')
515
+ # 重置子账户的APIKey Reset the apikey of the sub account
516
+ # result = subAccountAPI.modify_apikey(subAcct = '', apiKey = '', label = '', perm = '', ip = '')
517
+ # 获取子账户资金账户余额
518
+ # result = subAccountAPI.asset_balances(subAcct = '', ccy = '')
519
+ # 获取用户的节点返佣信息
520
+ # result = subAccountAPI.partner_if_rebate(apiKey = '')
521
+ # 获取子账户最大可转余额
522
+ # result = subAccountAPI.max_withdrawal()
523
+ # 查询托管子账户转账记录
524
+ # result = subAccountAPI.managed_subaccount_bills()
525
+
526
+ # 信号交易 SignalApi
527
+ # SignalAPI = Signal.SignalApi(api_key, secret_key, passphrase, False, flag)
528
+ # POST / 创建信号 /api/v5/tradingBot/signal/create-signal
529
+ # result = SignalAPI.create_signal(signalChanName='',signalChanDesc='')
530
+ # GET / 查询所有信号 /api/v5/tradingBot/signal/signals
531
+ # result = SignalAPI.signals(signalSourceType='', signalChanId='',after='', before='',
532
+ # limit='', )
533
+ # POST / 创建信号策略 /api/v5/tradingBot/signal/order-algo
534
+ # result = SignSignalAPIalAPI.order_algo(includeAll='', signalChanId='',instIds='', lever='',
535
+ # investAmt='',subOrdType='',ratio='',entrySettingParam='',exitSettingParam='',)
536
+ # POST / 停止信号策略 POST /api/v5/tradingBot/signal/stop-order-algo
537
+ # result = SignSignalAPIalAPI.signal_stop_order_algo( algoId='', )
538
+ # 调整保证金 POST /api/v5/tradingBot/signal/margin-balance
539
+ # result = SignSignalAPIalAPI.signal_margin_balance(algoId='',type='',amt='',allowReinvest='', )
540
+ # 修改止盈止损 POST /api/v5/tradingBot/signal/amendTPSL
541
+ # result = SignSignalAPIalAPI.amendTPSL(algoId='',exitSettingParam='', )
542
+ # 设置币对 POST /api/v5/tradingBot/signal/set-instruments
543
+ # result = SignSignalAPIalAPI.signal_set_instruments(algoId='',instIds='', includeAll='')
544
+ # 获取信号策略详情 GET /api/v5/tradingBot/signal/orders-algo-details
545
+ # result = SignSignalAPIalAPI.orders_algo_details( algoId='',algoOrdType='',)
546
+ # 获取活跃信号策略 GET /api/v5/tradingBot/signal/orders-algo-pending
547
+ # result = SignSignalAPIalAPI.orders_algo_pending(algoId='',algoOrdType='',after='',before='',limit='',)
548
+ # 获取历史信号策略 GET /api/v5/tradingBot/signal/orders-algo-history
549
+ # result = SignSignalAPIalAPI.orders_algo_history(algoId='',algoOrdType='',after='',before='',limit='', )
550
+ # 获取信号策略持仓 GET /api/v5/tradingBot/signal/positions
551
+ # result = SignSignalAPIalAPI.signal_positions(algoId='',algoOrdType='', )
552
+ # 查看历史持仓信息 GET /api/v5/tradingBot/signal/positions-history
553
+ # result = SignSignalAPIalAPI.signal_positions_history(algoId='',instId='',after='',before='',limit='', )
554
+ # 市价仓位全平 POST /api/v5/tradingBot/signal/close-position
555
+ # result = SignSignalAPIalAPI.signal_close_position( algoId='',instId='',)
556
+ # 下单 POST /api/v5/tradingBot/signal/sub-order
557
+ # result = SignSignalAPIalAPI.sub_order(algoId='',instId='',side='',ordType='',sz='',px='',reduceOnly='')
558
+ # 撤单 POST /api/v5/tradingBot/signal/cancel-sub-order
559
+ # result = SignSignalAPIalAPI.cancel_sub_order(algoId='',instId='',signalOrdId='',)
560
+ # 获取信号策略子订单信息 GET /api/v5/tradingBot/signal/sub-orders
561
+ # result = SignSignalAPIalAPI.sub_orders(algoId='',algoOrdType='',signalOrdId='',state='',after='',before='',limit='',
562
+ # begin='',end='',type='',clOrdId='')
563
+ # 获取信号策略历史事件 GET /api/v5/tradingBot/signal/event-history
564
+ # result = SignSignalAPIalAPI.event_history(algoId='',after='',before='',limit='',)
565
+
566
+ # BrokerAPI -- DMA经纪商
567
+ # BrokerAPI = Broker.BrokerAPI(api_key, secret_key, passphrase, False, flag)
568
+ # 获取独立经纪商账户信息 GET Obtain independent broker account information
569
+ # result = BrokerAPI.broker_info()
570
+ # 创建子账户 Create sub account
571
+ # result = BrokerAPI.create_subaccount(subAcct = 'qwerty', label = '',clientIP='',mainAcct='')
572
+ # 删除子账户 Delete sub account
573
+ # result = BrokerAPI.delete_subaccount(subAcct = 'qwerty')
574
+ # 获取子账户列表 Get sub account list
575
+ # result = BrokerAPI.subaccount_info(page = '', subAcct = '', limit = '', uid = '')
576
+ # 获取子账户交易手续费费率 GET /api/v5/broker/dma/subaccount-trade-fee
577
+ # result = BrokerAPI.subaccount_trade_fee(page = '', subAcct = '', limit = '', uid = '')
578
+ # 设置子账户的账户模式 Set account level of sub account
579
+ # result = BrokerAPI.set_subaccount_level(subAcct = 'qwerty', acctLv = '1')
580
+ # 设置子账户的交易手续费费率 Set transaction fee rate of sub account
581
+ # result = BrokerAPI.set_subaccount_fee_rate(subAcct = 'qwerty', instType = 'SPOT', mgnType = '', chgType = 'absolute', chgTaker = '0.1bp', chgMaker = '', effDate = '')
582
+ # 创建子账户充值地址 Create sub account recharge address
583
+ # result = BrokerAPI.subaccount_deposit_address(subAcct = 'qwerty', ccy = 'BTC', chain = '', addrType = '', to = '')
584
+ # 获取子账户获取充值记录 Get sub account recharge record
585
+ # result = BrokerAPI.subaccount_deposit_history(subAcct = 'qwerty', ccy = 'BTC', txId = '', state = '', after = '', before = '', limit = '')
586
+ # 获取子账户提币记录
587
+ # result = BrokerAPI.nd_subaccount_withdrawal_history(subAcct = 'qwerty', ccy = 'BTC', wdId = '', clientId = '', txId = '', type = '', state = '', after = '', before = '', limit = '')
588
+ # 获取子账户返佣记录 Get rebate record of sub account
589
+ # result = BrokerAPI.rebate_daily(subAcct = 'qwerty', begin = '', end = '', page = '', limit = '')
590
+ # 创建子账户的APIKEY Apikey for creating sub accounts
591
+ # result = BrokerAPI.dma_create_apikey(subAcct = 'qwerty', label = '', passphrase = '', ip = '', perm = '')
592
+ # 查询子账户的APIKEY
593
+ # result = BrokerAPI.dma_select_apikey(subAcct = 'qwerty', apiKey = '')
594
+ # 重置子账户的APIKEY
595
+ # result = BrokerAPI.dma_modify_apikey(subAcct = 'qwerty', apiKey = '', label = '', perm = '', ip = '')
596
+ # 删除子账户的APIKEY
597
+ # result = BrokerAPI.dma_delete_apikey(subAcct = 'qwerty', apiKey = '')
598
+ # 生成返佣明细下载链接
599
+ # result = BrokerAPI.rebate_per_orders(begin = '', end = '')
600
+ # 获取返佣明细下载链接
601
+ # result = BrokerAPI.rebate_per_orders(type = '', begin = '', end = '')
602
+ # 重置子账户充值地址
603
+ # result = BrokerAPI.modify_subaccount_deposit_address(subAcct = 'qwert', ccy = 'BTC', chain = '', addr = '1', to = '6')
604
+ # 设置模拟盘ND子账户资产
605
+ # result = BrokerAPI.set_subaccount_assets(subAcct='',ccy='')
606
+ # 子账户IP上报 POST /api/v5/broker/nd/report-subaccount-ip
607
+ # result = BrokerAPI.report_subaccount_ip(subAcct='',clientIP='')
608
+ # 获取用户的 Broker 返佣信息 GET /api/v5/broker/nd/if-rebate
609
+ # result = BrokerAPI.if_rebate(subAcct='',clientIP='')
610
+
611
+
612
+
613
+
614
+ # FDBrokerAPI
615
+ # FDBrokerAPI = FDBroker.FDBrokerAPI(api_key, secret_key, passphrase, False, flag)
616
+ # 生成返佣明细下载链接
617
+ # result = FDBrokerAPI.fd_rebate_per_orders(begin = '', end = '', brokerType = '')
618
+ # 获取返佣明细下载链接
619
+ # result = FDBrokerAPI.fd_get_rebate_per_orders(type = '', begin = '', end = '', brokerType = '')
620
+ # 获取返佣明细下载链接
621
+ # result = FDBrokerAPI.fd_if_rebate(apiKey = '', brokerType = '')
622
+
623
+ # 大宗交易(Rfq)API
624
+ # RfqAPI = Rfq.RfqAPI(api_key, secret_key, passphrase, False, flag)
625
+ # 获取报价方信息
626
+ # result = RfqAPI.counterparties()
627
+ # 询价
628
+ # result = RfqAPI.create_rfq(counterparties = ["TESTQ4","TESTQ2"], anonymous = False, clRfqId = '20220531test001', tag = '555', allowPartialExecution ='',
629
+ # legs = [{"instId":"BTC-USDT","sz":"1","side":"buy","tgtCcy":"base_ccy"},{"instId":"ETH-USDT","sz":"0.1","side":"buy","tgtCcy":"base_ccy"}])
630
+ # 取消询价单
631
+ # result = RfqAPI.cancel_rfq(rfqId = '3GIFPJ8', clRfqId = '')
632
+ # 批量取消询价单
633
+ # result = RfqAPI.cancel_batch_rfqs(rfqIds = '', clRfqIds = '')
634
+ # 取消所有询价单
635
+ # result = RfqAPI.cancel_all_rfqs()
636
+ # 执行报价
637
+ # result = RfqAPI.execute_quote(rfqId = '', quoteId = '')
638
+ # 获取可报价产品
639
+ # result = RfqAPI.get_maker_instrument_settings()
640
+ # 设置可报价产品
641
+ # result = RfqAPI.maker_instrument_settings(instType = 'SPOT', data = [{"instFamily":"","instId":"","maxBlockSz":"","makerPxBand":""}])
642
+ # 重设MMP状态
643
+ # result = RfqAPI.mmp_reset()
644
+ # 设置 MMP
645
+ # result = RfqAPI.mmp_config(timeInterval='',frozenInterval='',countLimit='')
646
+ # 查看 MMP 配置
647
+ # result = RfqAPI.mmp_configs(timeInterval='', frozenInterval='', countLimit='',mmpFrozen='',mmpFrozenUntil='',)
648
+ # 报价
649
+ # result = RfqAPI.create_quote(rfqId = '', clQuoteId = '', tag = '123', quoteSide = 'buy', anonymous = 'True', expiresIn = '', legs = [{"px":"39450.0","sz":"200000","instId":"BTC-USDT-SWAP","side":"buy"}])
650
+ # 取消报价单
651
+ # result = RfqAPI.cancel_quote(quoteId = '', clQuoteId = '', rfqId = '')
652
+ # 批量取消报价单
653
+ # result = RfqAPI.cancel_batch_quotes(quoteIds = '', clQuoteIds = '')
654
+ # 取消所有报价单
655
+ # result = RfqAPI.cancel_all_quotes()
656
+ # 获取询价单信息
657
+ # result = RfqAPI.get_rfqs(rfqId = '', clRfqId = '', state = '', beginId = '', endId = '', limit = '')
658
+ # 获取报价单信息
659
+ # result = RfqAPI.get_quotes(rfqId = '', clRfqId = '', quoteId = '', clQuoteId = '', state = '', beginId = '', endId = '', limit = '')
660
+ # 获取大宗交易信息
661
+ # result = RfqAPI.get_rfq_trades(rfqId = '', clRfqId = '', quoteId = '', blockTdId = '', clQuoteId = '', isSuccessful = '', beginId = '', endId = '', beginTs ='', endTs = '', limit = '')
662
+ # 获取大宗交易公共成交数据
663
+ # result = RfqAPI.get_public_trades(beginId = '', endId = '', limit = '')
664
+ # 倒计时全部撤单 POST /api/v5/rfq/cancel-all-after
665
+ # result = RfqAPI.tag()
666
+
667
+
668
+
669
+ # 网格交易
670
+ # TradingBot = TradingBot.TradingBotAPI(api_key, secret_key, passphrase, False, flag)
671
+ # 网格策略下单
672
+ # result = TradingBot.grid_order_algo(instId = 'BTC-USDT', algoOrdType = 'grid', maxPx = '100000', minPx = '10000', gridNum = '2', runType = '', tpTriggerPx = '', slTriggerPx = '', algoClOrdId='', profitSharingRatio = '', tag = '',
673
+ # triggerParams = [{"triggerAction":"start", "triggerStrategy":"rsi", "timeframe":"30M","thold":"10","triggerCond":"cross","timePeriod":"14"}])
674
+ # 修改网格策略订单
675
+ # result = TradingBot.grid_amend_order_algo(algoId = '451791361361317888', instId = '', slTriggerPx = '', tpTriggerPx = '')
676
+ # 网格策略停止
677
+ # result = TradingBot.grid_stop_order_algo(algoId = '455784823937040384', instId = 'BTC-USDT', algoOrdType = 'grid', stopType = '1')
678
+ # 获取未完成网格策略委托单列表
679
+ # result = TradingBot.grid_orders_algo_pending(algoOrdType = 'grid', algoId = '', instId = '', instType = '', after = '', before = '', limit = '')
680
+ # 获取历史网格策略委托单列表
681
+ # result = TradingBot.grid_orders_algo_history(algoOrdType = 'grid', algoId = '', instId = '', instType = '', after = '', before = '', limit = '')
682
+ # 获取网格策略委托订单详情
683
+ # result = TradingBot.grid_orders_algo_details(algoOrdType = 'grid', algoId = '451805034968518656')
684
+ # 获取网格策略委托子订单信息
685
+ # result = TradingBot.grid_sub_orders(algoId = '451791361361317888', algoOrdType = 'grid', type = 'filled', groupId = '', after = '', before = '', limit = '')
686
+ # 获取网格策略委托持仓
687
+ # result = TradingBot.grid_positions(algoOrdType = '', algoId = '')
688
+ # 现货网格提取利润
689
+ # result = TradingBot.grid_withdraw_income(algoId = '455784823937040384')
690
+ # 调整保证金计算
691
+ # result = TradingBot.grid_compute_margin_balance(algoId = '455784823937040384', type = 'add', amt = '')
692
+ # 调整保证金
693
+ # result = TradingBot.grid_margin_balance(algoId = '455784823937040384', type = 'add', amt = '10', percent = '')
694
+ # 网格策略智能回测(公共)
695
+ # result = TradingBot.grid_ai_param(algoOrdType = 'grid', instId = 'BTC-USDT', direction = '', duration = '')
696
+ # 加仓 POST /api/v5/tradingBot/grid/adjust-investment
697
+ # result = TradingBot.grid_adjust_investment(algoId = '', amt = '')
698
+ # 最大网格数量(公共)GET /api/v5/tradingBot/grid/grid-quantity
699
+ # result = TradingBot.grid_quantity(instId = 'BTC-USDT', runType = '1', algoOrdType = '', maxPx = '', minPx = '', lever = '')
700
+
701
+
702
+ # 金融产品 Finance API
703
+ # Finance = Finance.FinanceAPI(api_key, secret_key, passphrase, False, flag)
704
+ # 查看项目 View items
705
+ # result = Finance.staking_defi_offers(productId = '', protocolType = 'defi', ccy = '')
706
+ # 申购项目 Subscription items
707
+ # result = Finance.staking_defi_purchase(productId = '1456', investData = [{"ccy":"USDT","amt":"1"}], term = '30', tag='')
708
+ # 赎回项目 Redemption items
709
+ # result = Finance.staking_defi_redeem(ordId = '123', protocolType = 'defi', allowEarlyRedeem = '')
710
+ # 撤销项目申购/赎回 Cancellation of project subscription / redemption
711
+ # result = Finance.staking_defi_cancel(ordId = '', protocolType = 'defi')
712
+ # 查看活跃订单 View active orders
713
+ # result = Finance.staking_defi_orders_active(productId = '', protocolType = 'defi', ccy = '', state = '')
714
+ # 查看历史订单 View historical orders
715
+ # result = Finance.staking_defi_orders_history(productId = '', protocolType = '', ccy = '', after = '', before = '', limit = '')
716
+
717
+ # ETH质押
718
+ # 申购/api/v5/finance/staking-defi/eth/purchase
719
+ # result = Finance.staking_defi_eth_purcase()
720
+ # 赎回 POST /api/v5/finance/staking-defi/eth/redeem
721
+ # result = Finance.staking_defi_eth_redeem()
722
+ # GET / 获取余额 GET /api/v5/finance/staking-defi/eth/balance
723
+ # result = Finance.staking_defi_eth_balance()
724
+ # 获取申购赎回记录 GET /api/v5/finance/staking-defi/eth/purchase-redeem-history
725
+ # result = Finance.staking_defi_eth_p_r_history()
726
+ # 获取历史收益率(公共) GET /api/v5/finance/staking-defi/eth/apy-history
727
+ # result = Finance.staking_defi_eth_apy_history()
728
+ # 获取产品信息
729
+ # result = Finance.staking_defi_eth_product_info()
730
+
731
+ # SOL质押
732
+ # 申购 POST /api/v5/finance/staking-defi/sol/purchase
733
+ # result = Finance.staking_defi_sol_purcase(amt = '')
734
+ # 赎回 POST /api/v5/finance/staking-defi/sol/redeem
735
+ # result = Finance.staking_defi_sol_redeem(amt = '')
736
+ # 获取余额 GET /api/v5/finance/staking-defi/sol/balance
737
+ # result = Finance.staking_defi_sol_balance()
738
+ # 获取申购赎回记录 GET /api/v5/finance/staking-defi/sol/purchase-redeem-history
739
+ # result = Finance.staking_defi_sol_p_r_history(type = '', status = '', after = '', before = '', limit = '')
740
+ # 获取历史收益率(公共) GET /api/v5/finance/staking-defi/sol/apy-history
741
+ # result = Finance.staking_defi_sol_apy_history(days = '1')
742
+
743
+
744
+ # 活期简单赚币
745
+ # 余币宝申购/赎回 PiggyBank Purchase/Redemption
746
+ # result = fundingAPI.purchase_redempt('BTC', '1', 'purchase')
747
+ # 获取余币宝余额 PIGGY BALABCE
748
+ # result = fundingAPI.get_piggy_balance()
749
+ # 设置余币宝借贷利率 POST SET LENDING RATE
750
+ # result = fundingAPI.set_lending_rate(ccy = 'USDT',rate='')
751
+ # 获取余币宝出借明细 GET LENDING HISTORY
752
+ # result = fundingAPI.get_lending_rate(ccy = '')
753
+ # 获取市场借贷信息(公共)GET /api/v5/finance/savings/lending-rate-summary
754
+ # result = Finance.savings_lending_rate_summary()
755
+ # 获取市场借贷历史(公共) GET /api/v5/finance/savings/lending-rate-history
756
+ # result = Finance.savings_lending_rate_his()
757
+
758
+ # 定期简单赚币
759
+ # 获取借币信息 GET /api/v5/finance/fixed-loan/lending-offers
760
+ # result = Finance.fixed_loan_lending_offers()
761
+ # 获取历史收益率 GET /api/v5/finance/fixed-loan/lending-apy-history
762
+ # result = Finance.fixed_loan_lending_apy_history()
763
+ # 获取借贷量 GET /api/v5/finance/fixed-loan/pending-lending-volume
764
+ # result = Finance.fixed_loan_pending_lending_vol()
765
+ # 定期简单赚币申购 POST /api/v5/finance/fixed-loan/lending-order
766
+ # result = Finance.fixed_loan_lending_order(ccy = 'BTC', amt = '1', rate ='0.01', term = '30', autoRenewal = '')
767
+ # 定期简单赚币修改订单 POST /api/v5/finance/fixed-loan/amend-lending-order
768
+ # result = Finance.fixed_loan_amend_lending_order(ordId = '', changeAmt = '', rate ='', autoRenewal = '')
769
+ # 获取定期简单赚币订单信息 GET /api/v5/finance/fixed-loan/lending-orders-list
770
+ # result = Finance.fixed_loan_lending_orders_list(ordId = '', ccy ='', state ='', after = '', before = '', limit = '')
771
+ # 获取定期简单赚币子订单信息
772
+ # result = Finance.fixed_loan_lending_sub_orders(ordId = '', state ='', after = '', before = '', limit = '')
773
+
774
+ # 活期借币
775
+ # 可借币种列表 GET /api/v5/finance/flexible-loan/borrow-currencies
776
+ # result = Finance.flexible_loan_borrow_currencies()
777
+ # 可抵押资产 GET /api/v5/finance/flexible-loan/collateral-assets
778
+ # result = Finance.flexible_loan_collateral_assets(ccy = 'BTC')
779
+ # 最大可借 POST /api/v5/finance/flexible-loan/max-loan
780
+ # result = Finance.flexible_loan_max_loan(borrowCcy = 'BTC')
781
+ # 抵押物最大可赎回数量 GET /api/v5/finance/flexible-loan/max-collateral-redeem-amount
782
+ # result = Finance.flexible_loan_max_c_r_a(borrowCcy = 'BTC')
783
+ # 调整抵押物 POST /api/v5/finance/flexible-loan/adjust-collateral
784
+ # result = Finance.flexible_loan_adj_coll(type = '', collateralCcy = '', collateralAmt = '')
785
+ # 借贷信息 GET /api/v5/finance/flexible-loan/loan-info
786
+ # result = Finance.flexible_loan_loan_info()
787
+ # 借贷历史 GET /api/v5/finance/flexible-loan/loan-history
788
+ # result = Finance.flexible_loan_loan_history(type = '', after = '', before = '', limit = '')
789
+ # 计息记录 GET /api/v5/finance/flexible-loan/interest-accrued
790
+ # result = Finance.flexible_loan_interest_accrued(ccy = '', after = '', before = '', limit = '')
791
+
792
+
793
+ # 跟单
794
+ # Copytrading = Copytrading.CopytradingAPI(api_key, secret_key, passphrase, False, flag)
795
+ # 交易员获取当前带单
796
+ # result = Copytrading.current_subpositions(instId='', after='', before='', limit='')
797
+ # 交易员获取历史带单
798
+ # result = Copytrading.subpositions_history(instId='', after='', before='', limit='')
799
+ # 带单或跟单仓位止盈止损
800
+ # result = Copytrading.copytrading_algo_order(subPosId='123456789', tpTriggerPx='1', slTriggerPx='', tpTriggerPxType='', slTriggerPxType=''
801
+ # tag='')
802
+ # 交易员平仓
803
+ # result = Copytrading.copytrading_close_subposition(subPosId='123456789',tag='')
804
+ # 交易员获取带单合约
805
+ # result = Copytrading.copytrading_instruments()
806
+ # 交易员修改带单合约
807
+ # result = Copytrading.copytrading_set_instruments(instId='BTC-USDT-SWAP')
808
+ # 交易员历史分润明细
809
+ # result = Copytrading.profit_sharing_details(after='', before='', limit='')
810
+ # 交易员历史分润汇总
811
+ # result = Copytrading.total_profit_sharing()
812
+ # 交易员待分润明细
813
+ # result = Copytrading.unrealized_profit_sharing_details()
814
+ # 首次跟单设置
815
+ # result = Copytrading.first_copy_settings(instType='',uniqueCode='',copyMgnMode='',copyInstIdType='',instId='',copyMode='',
816
+ # copyTotalAmt='',copyAmt='',copyRatio='',tpRatio='',slRatio='',slTotalAmt='',
817
+ # subPosCloseType='')
818
+ # 修改跟单设置
819
+ # result = Copytrading.amend_copy_settings(instType='', uniqueCode='', copyMgnMode='', copyInstIdType='', instId='',
820
+ # copyMode='',
821
+ # copyTotalAmt='', copyAmt='', copyRatio='', tpRatio='', slRatio='',
822
+ # slTotalAmt='',
823
+ # subPosCloseType='')
824
+ # 停止跟单
825
+ # result = Copytrading.stop_copy_trading(instType='',uniqueCode='',subPosCloseType='')
826
+ # 获取跟单设置
827
+ # result = Copytrading.copy_settings(instType='',uniqueCode='')
828
+ # 批量获取杠杆倍数
829
+ # result = Copytrading.batch_leverage_info(mgnMode='',uniqueCode='',instId='')
830
+ # 批量设置杠杆倍数
831
+ # result = Copytrading.batch_set_leverage(mgnMode='', lever='', instId='')
832
+ # 获取我的交易员
833
+ # result = Copytrading.current_lead_traders(instType='')
834
+ # GET / 获取我的交易员历史
835
+ # result = Copytrading.lead_traders_history(after='',before='',limit='',instType='',)
836
+ # GET / 获取交易员排名
837
+ # result = Copytrading.public_lead_traders(instType='',sortType='',state='',minLeadDays='',minAssets='',maxAssets='',
838
+ # minAum='',maxAum='',dataVer='',page='',limit='')
839
+ # GET / 获取交易员收益周表现
840
+ # result = Copytrading.public_weekly_pnl(instType='',uniqueCode='')
841
+ # GET / 获取交易员收益日表现
842
+ # result = Copytrading.public_pnl(instType='', uniqueCode='',lastDays='')
843
+ # GET / 获取交易员带单情况
844
+ # result = Copytrading.public_stats(instType='', uniqueCode='',lastDays='')
845
+ # GET / 获取交易员币种偏好
846
+ # result = Copytrading.public_preference_currency(instType='', uniqueCode='')
847
+ # GET / 获取交易员当前带单
848
+ # result = Copytrading.public_current_subpositions(after='', before='', limit='', instType='', uniqueCode='')
849
+ # GET / 获取交易员历史带单
850
+ # result = Copytrading.public_subpositions_history(after='', before='', limit='', instType='', uniqueCode='')
851
+ # 带单申请 POST /api/v5/copytrading/apply-lead-trading
852
+ # result = Copytrading.apply_lead_trading()
853
+ # 停止带单 /api/v5/copytrading/stop-lead-trading
854
+ # result = Copytrading.stop_lead_trading()
855
+ # 修改分润比例 /api/v5/copytrading/amend-profit-sharing-ratio
856
+ # result = Copytrading.amend_profit_sharing_ratio()
857
+ # 获取交易员排名(私有)GET /api/v5/copytrading/lead-traders
858
+ # result = Copytrading.lead_traders()
859
+ # 获取交易员收益周表现(私有)GET /api/v5/copytrading/weekly-pnl
860
+ # result = Copytrading.weekly_pnl()
861
+ # 获取交易员收益日表现(私有)/api/v5/copytrading/pnl
862
+ # result = Copytrading.pnl()
863
+ # 获取交易员带单情况(私有)/api/v5/copytrading/stats
864
+ # result = Copytrading.stats()
865
+ # 获取交易员币种偏好(私有)/api/v5/copytrading/preference-currency
866
+ # result = Copytrading.preference_currency()
867
+ # 获取交易员当前带单(私有)/api/v5/copytrading/performance-current-subpositions
868
+ # result = Copytrading.performance_current_subpositions(after='', before='', limit='', instType='', uniqueCode='')
869
+ # 获取交易员历史带单(私有)/api/v5/copytrading/performance-subpositions-history
870
+ # result = Copytrading.performance_subpositions_history(after='', before='', limit='', instType='', uniqueCode='')
871
+ # 获取跟单人信息(私有)/api/v5/copytrading/copy-traders
872
+ # result = Copytrading.copy_traders(uniqueCode='')
873
+ # 获取跟单人信息/api/v5/copytrading/public-copy-traders
874
+ # result = Copytrading.public_copy_traders()
875
+ # 查看账户配置信息/api/v5/copytrading/config
876
+ # result = Copytrading.config()
877
+ # 交易员待分润汇总 /api/v5/copytrading/total-unrealized-profit-sharing
878
+ # result = Copytrading.total_unrealized_profit_sharing()
879
+
880
+ # 定投
881
+ # Recurring = Recurring.RecurringAPI(api_key, secret_key, passphrase, False, flag)
882
+ # 定投策略委托下单
883
+ # result = Recurring.recurring_order_algo(stgyName = 'test', recurringList = [{"ccy":"BTC","ratio":"1"}], period = 'daily', recurringDay = '1', recurringTime = '2',
884
+ # timeZone = '8', amt = '2', investmentCcy = 'USDT', tdMode = 'cash', algoClOrdId = 'testclordid', tag = 'testtag')
885
+ # 修改定投策略订单
886
+ # result = Recurring.recurring_amend_order_algo(algoId = '561293358812102656', stgyName = 'test2')
887
+ # 定投策略停止
888
+ # result = Recurring.recurring_stop_order_algo([{"algoId":"561293358812102656"}])
889
+ # 获取未完成定投策略委托单列表
890
+ # result = Recurring.recurring_orders_algo_pending(algoId = '', after = '', before = '', limit = '')
891
+ # 获取历史定投策略委托单列表
892
+ # result = Recurring.recurring_orders_algo_history(algoId = '', after = '', before = '', limit = '')
893
+ # 获取定投策略委托订单详情
894
+ # result = Recurring.recurring_orders_algo_details(algoId = '561293358812102656')
895
+ # 获取定投策略子订单信息
896
+ # result = Recurring.recurring_sub_orders(algoId = '561293358812102656', ordId = '', after = '', before = '', limit = '')
897
+
898
+
899
+ # 系统状态API(仅适用于实盘) system status
900
+ # Status = Status.StatusAPI(api_key, secret_key, passphrase, False, flag)
901
+ # 查看系统的升级状态
902
+ # result = Status.status()
903
+ # 公告 GET /api/v5/support/announcements
904
+ # result = Status.get_announcements(annType = '', page = '')
905
+ # 公告类型 GET /api/v5/support/announcement-types
906
+ # result = Status.get_announcements_types()
907
+ # print(json.dumps(result))
908
+
909
+
910
+
911
+ 附言:
912
+
913
+ * 如果对API尚不了解,建议参考`OKx`官方[API文档](https://www.okx.com/docs-v5/zh/)
914
+
915
+ * 使用RestAPI通过设置flag参数来选择接入实盘或者模拟盘