@yuants/vendor-okx 0.23.23 → 0.23.25
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.
- package/dist/account.js +11 -9
- package/dist/account.js.map +1 -1
- package/dist/api-service.js +29 -0
- package/dist/api-service.js.map +1 -0
- package/dist/api.js +445 -510
- package/dist/api.js.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/interest_rate.js +4 -4
- package/dist/interest_rate.js.map +1 -1
- package/dist/loan-account.js +3 -2
- package/dist/loan-account.js.map +1 -1
- package/dist/market-order.js +1 -1
- package/dist/market-order.js.map +1 -1
- package/dist/ohlc.js +3 -3
- package/dist/ohlc.js.map +1 -1
- package/dist/order-actions.js +211 -0
- package/dist/order-actions.js.map +1 -0
- package/dist/order.js +3 -3
- package/dist/order.js.map +1 -1
- package/dist/product.js +4 -4
- package/dist/product.js.map +1 -1
- package/dist/public-api.js +146 -0
- package/dist/public-api.js.map +1 -0
- package/dist/quote.js +80 -11
- package/dist/quote.js.map +1 -1
- package/dist/services.js +3 -2
- package/dist/services.js.map +1 -1
- package/dist/strategy-account.js +5 -4
- package/dist/strategy-account.js.map +1 -1
- package/dist/trade.js +6 -5
- package/dist/trade.js.map +1 -1
- package/dist/transfer.js +279 -0
- package/dist/transfer.js.map +1 -0
- package/dist/websocket.js.map +1 -1
- package/lib/account.d.ts +2 -2
- package/lib/account.d.ts.map +1 -1
- package/lib/account.js +10 -8
- package/lib/account.js.map +1 -1
- package/lib/api-service.d.ts +2 -0
- package/lib/api-service.d.ts.map +1 -0
- package/lib/api-service.js +31 -0
- package/lib/api-service.js.map +1 -0
- package/lib/api.d.ts +1251 -1558
- package/lib/api.d.ts.map +1 -1
- package/lib/api.js +477 -514
- package/lib/api.js.map +1 -1
- package/lib/index.d.ts +5 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -3
- package/lib/index.js.map +1 -1
- package/lib/interest_rate.js +4 -4
- package/lib/interest_rate.js.map +1 -1
- package/lib/loan-account.js +2 -1
- package/lib/loan-account.js.map +1 -1
- package/lib/market-order.d.ts.map +1 -1
- package/lib/market-order.js +1 -1
- package/lib/market-order.js.map +1 -1
- package/lib/ohlc.js +3 -3
- package/lib/ohlc.js.map +1 -1
- package/lib/order-actions.d.ts +2 -0
- package/lib/order-actions.d.ts.map +1 -0
- package/lib/order-actions.js +213 -0
- package/lib/order-actions.js.map +1 -0
- package/lib/order.js +2 -2
- package/lib/order.js.map +1 -1
- package/lib/product.js +4 -4
- package/lib/product.js.map +1 -1
- package/lib/public-api.d.ts +359 -0
- package/lib/public-api.d.ts.map +1 -0
- package/lib/public-api.js +161 -0
- package/lib/public-api.js.map +1 -0
- package/lib/quote.d.ts +1 -1
- package/lib/quote.d.ts.map +1 -1
- package/lib/quote.js +78 -9
- package/lib/quote.js.map +1 -1
- package/lib/services.js +2 -1
- package/lib/services.js.map +1 -1
- package/lib/strategy-account.d.ts +2 -2
- package/lib/strategy-account.d.ts.map +1 -1
- package/lib/strategy-account.js +4 -3
- package/lib/strategy-account.js.map +1 -1
- package/lib/trade.js +6 -5
- package/lib/trade.js.map +1 -1
- package/lib/transfer.d.ts +2 -0
- package/lib/transfer.d.ts.map +1 -0
- package/lib/transfer.js +281 -0
- package/lib/transfer.js.map +1 -0
- package/lib/websocket.js.map +1 -1
- package/package.json +13 -12
- package/temp/package-deps.json +34 -31
- package/dist/legacy_index.js +0 -562
- package/dist/legacy_index.js.map +0 -1
- package/dist/logger.js +0 -91
- package/dist/logger.js.map +0 -1
- package/lib/legacy_index.d.ts +0 -2
- package/lib/legacy_index.d.ts.map +0 -1
- package/lib/legacy_index.js +0 -564
- package/lib/legacy_index.js.map +0 -1
- package/lib/logger.d.ts +0 -21
- package/lib/logger.d.ts.map +0 -1
- package/lib/logger.js +0 -98
- package/lib/logger.js.map +0 -1
package/dist/api.js
CHANGED
|
@@ -1,514 +1,449 @@
|
|
|
1
|
-
import { formatTime } from '@yuants/utils';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
* 获取产品行情信息
|
|
15
|
-
*
|
|
16
|
-
* 限速:20次/2s
|
|
17
|
-
* 限速规则:IP
|
|
18
|
-
*
|
|
19
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-market-data-get-tickers
|
|
20
|
-
*/
|
|
21
|
-
this.getMarketTickers = (params) => this.request('GET', '/api/v5/market/tickers', params);
|
|
22
|
-
/**
|
|
23
|
-
* 获取账户资产估值
|
|
24
|
-
*
|
|
25
|
-
* 查看账户资产估值
|
|
26
|
-
*
|
|
27
|
-
* 限速:1次/s
|
|
28
|
-
* 限速规则:UserID
|
|
29
|
-
*
|
|
30
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-account-asset-valuation
|
|
31
|
-
*/
|
|
32
|
-
this.getAssetValuation = (params) => this.request('GET', '/api/v5/asset/asset-valuation', params);
|
|
33
|
-
/**
|
|
34
|
-
* 获取持仓总量
|
|
35
|
-
*
|
|
36
|
-
* 查询单个交易产品的市场的持仓总量
|
|
37
|
-
*
|
|
38
|
-
* 限速:20次/2s
|
|
39
|
-
* 限速规则:IP + instrumentID
|
|
40
|
-
*
|
|
41
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-open-interest
|
|
42
|
-
*/
|
|
43
|
-
this.getOpenInterest = (params) => this.request('GET', '/api/v5/public/open-interest', params);
|
|
44
|
-
/**
|
|
45
|
-
* 查看账户配置
|
|
46
|
-
* 查看当前账户的配置信息。
|
|
47
|
-
*
|
|
48
|
-
* 限速:5次/2s
|
|
49
|
-
* 限速规则:UserID
|
|
50
|
-
*
|
|
51
|
-
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-account-configuration
|
|
52
|
-
*/
|
|
53
|
-
this.getAccountConfig = () => this.request('GET', '/api/v5/account/config');
|
|
54
|
-
/**
|
|
55
|
-
* 获取市场借币杠杆利率和借币限额
|
|
56
|
-
*
|
|
57
|
-
* 限速:2次/2s
|
|
58
|
-
* 限速规则:IP
|
|
59
|
-
*
|
|
60
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-interest-rate-and-loan-quota
|
|
61
|
-
*/
|
|
62
|
-
this.getInterestRateLoanQuota = () => this.request('GET', '/api/v5/public/interest-rate-loan-quota');
|
|
63
|
-
/**
|
|
64
|
-
* 获取交易产品基础信息
|
|
65
|
-
*
|
|
66
|
-
* 获取所有可交易产品的信息列表。
|
|
67
|
-
*
|
|
68
|
-
* 限速:20次/2s
|
|
69
|
-
* 限速规则:IP +instType
|
|
70
|
-
*
|
|
71
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-instruments
|
|
72
|
-
*/
|
|
73
|
-
this.getInstruments = (params) => this.request('GET', '/api/v5/public/instruments', params);
|
|
74
|
-
/**
|
|
75
|
-
* 获取永续合约当前资金费率
|
|
76
|
-
* 获取当前资金费率
|
|
77
|
-
*
|
|
78
|
-
* 限速:20次/2s
|
|
79
|
-
* 限速规则:IP +instrumentID
|
|
80
|
-
*
|
|
81
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-funding-rate
|
|
82
|
-
*/
|
|
83
|
-
this.getFundingRate = (params) => this.request('GET', '/api/v5/public/funding-rate', params);
|
|
84
|
-
/**
|
|
85
|
-
* 获取永续合约历史资金费率
|
|
86
|
-
*
|
|
87
|
-
* 获取最近3个月的历史资金费率
|
|
88
|
-
*
|
|
89
|
-
* 限速:10次/2s
|
|
90
|
-
* 限速规则:IP +instrumentID
|
|
91
|
-
*
|
|
92
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-funding-rate-history
|
|
93
|
-
*/
|
|
94
|
-
this.getFundingRateHistory = (params) => this.request('GET', '/api/v5/public/funding-rate-history', params);
|
|
95
|
-
/**
|
|
96
|
-
* 获取标记价格历史K线数据
|
|
97
|
-
*
|
|
98
|
-
* 获取最近几年的标记价格K线数据
|
|
99
|
-
*
|
|
100
|
-
* 限速:10次/2s
|
|
101
|
-
* 限速规则:IP
|
|
102
|
-
*
|
|
103
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-mark-price-candlesticks-history
|
|
104
|
-
*/
|
|
105
|
-
this.getHistoryMarkPriceCandles = (params) => this.request('GET', '/api/v5/market/history-mark-price-candles', params);
|
|
106
|
-
/**
|
|
107
|
-
* GET / 获取交易产品历史K线数据
|
|
108
|
-
*
|
|
109
|
-
* 获取最近几年的历史k线数据(1s k线支持查询最近3个月的数据)
|
|
110
|
-
*
|
|
111
|
-
* 限速:20次/2s
|
|
112
|
-
*
|
|
113
|
-
* 限速规则:IP
|
|
114
|
-
*
|
|
115
|
-
* 期权不支持 1s K线, 其他业务线 (币币, 杠杆, 交割和永续)支持
|
|
116
|
-
*/
|
|
117
|
-
this.getHistoryCandles = (params) => this.request('GET', '/api/v5/market/history-candles', params);
|
|
118
|
-
/**
|
|
119
|
-
* 获取余币宝余额
|
|
120
|
-
*
|
|
121
|
-
* 限速:6次/s
|
|
122
|
-
* 限速规则:UserID
|
|
123
|
-
*
|
|
124
|
-
* https://www.okx.com/docs-v5/zh/#financial-product-savings-get-saving-balance
|
|
125
|
-
*/
|
|
126
|
-
this.getFinanceSavingsBalance = (params) => this.request('GET', '/api/v5/finance/savings/balance', params);
|
|
127
|
-
/**
|
|
128
|
-
* 余币宝申购/赎回
|
|
129
|
-
*
|
|
130
|
-
* 仅资金账户中的资产支持余币宝申购。
|
|
131
|
-
*
|
|
132
|
-
* 限速:6次/s
|
|
133
|
-
*
|
|
134
|
-
* 限速规则:UserID
|
|
135
|
-
*
|
|
136
|
-
* https://www.okx.com/docs-v5/zh/#financial-product-savings-post-savings-purchase-redemption
|
|
137
|
-
*/
|
|
138
|
-
this.postFinanceSavingsPurchaseRedempt = (params) => this.request('POST', '/api/v5/finance/savings/purchase-redempt', params);
|
|
139
|
-
/**
|
|
140
|
-
* GET / 获取市场借贷历史(公共)
|
|
141
|
-
*
|
|
142
|
-
* 公共接口无须鉴权
|
|
143
|
-
*
|
|
144
|
-
* 返回2021年12月14日后的记录
|
|
145
|
-
*
|
|
146
|
-
* 限速:6次/s
|
|
147
|
-
* 限速规则:IP
|
|
148
|
-
*
|
|
149
|
-
* https://www.okx.com/docs-v5/zh/#financial-product-savings-get-public-borrow-history-public
|
|
150
|
-
*/
|
|
151
|
-
this.getLendingRateHistory = (params) => this.request('GET', '/api/v5/finance/savings/lending-rate-history', params);
|
|
152
|
-
/**
|
|
153
|
-
* 提币
|
|
154
|
-
*
|
|
155
|
-
* 用户提币。普通子账户不支持提币。
|
|
156
|
-
*
|
|
157
|
-
* API只能提币到免认证地址/账户上,通过 WEB/APP 可以设置免认证地址。
|
|
158
|
-
*
|
|
159
|
-
* 关于标签:某些币种如XRP充币时同时需要一个充值地址和标签(又名memo/payment_id),标签是一种保证您的充币地址唯一性的数字串,与充币地址成对出现并一一对应。请您务必遵守正确的充值步骤,在提币时输入完整信息,否则将面临丢失币的风险!
|
|
160
|
-
* 对于有标签的币种,如果是OKX用户间的提币,请走内部转账不要走链上提币。
|
|
161
|
-
*
|
|
162
|
-
* 限速:6次/s
|
|
163
|
-
* 限速规则:UserID
|
|
164
|
-
*
|
|
165
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-withdrawal
|
|
166
|
-
*/
|
|
167
|
-
this.postAssetWithdrawal = (params) => this.request('POST', '/api/v5/asset/withdrawal', params);
|
|
168
|
-
/**
|
|
169
|
-
* 获取充值地址信息
|
|
170
|
-
*
|
|
171
|
-
* 获取各个币种的充值地址,包括曾使用过的老地址。
|
|
172
|
-
*
|
|
173
|
-
* 限速:6次/s
|
|
174
|
-
* 限速规则:UserID
|
|
175
|
-
*
|
|
176
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-address
|
|
177
|
-
*/
|
|
178
|
-
this.getAssetDepositAddress = (params) => this.request('GET', '/api/v5/asset/deposit-address', params);
|
|
179
|
-
/**
|
|
180
|
-
* 获取提币记录
|
|
181
|
-
*
|
|
182
|
-
* 根据币种,提币状态,时间范围获取提币记录,按照时间倒序排列,默认返回100条数据。
|
|
183
|
-
* 支持Websocket订阅,参考 提币信息频道。
|
|
184
|
-
*
|
|
185
|
-
* 限速:6 次/s
|
|
186
|
-
* 限速规则:UserID
|
|
187
|
-
*
|
|
188
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-withdrawal-history
|
|
189
|
-
*/
|
|
190
|
-
this.getAssetWithdrawalHistory = (params) => this.request('GET', '/api/v5/asset/withdrawal-history', params);
|
|
191
|
-
/**
|
|
192
|
-
* 获取充值记录
|
|
193
|
-
*
|
|
194
|
-
* 根据币种,充值状态,时间范围获取充值记录,按照时间倒序排列,默认返回 100 条数据。
|
|
195
|
-
* 支持Websocket订阅,参考 充值信息频道。
|
|
196
|
-
*
|
|
197
|
-
* 限速:6次/s
|
|
198
|
-
* 限速规则:UserID
|
|
199
|
-
*
|
|
200
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-history
|
|
201
|
-
*/
|
|
202
|
-
this.getAssetDepositHistory = (params) => this.request('GET', '/api/v5/asset/deposit-history', params);
|
|
203
|
-
/**
|
|
204
|
-
* 获取资金账户余额
|
|
205
|
-
*
|
|
206
|
-
* 获取资金账户所有资产列表,查询各币种的余额、冻结和可用等信息。
|
|
207
|
-
*
|
|
208
|
-
* 只返回余额大于0的币资产信息。
|
|
209
|
-
*
|
|
210
|
-
* 限速:6次/s
|
|
211
|
-
* 限速规则:UserID
|
|
212
|
-
*
|
|
213
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-balance
|
|
214
|
-
*/
|
|
215
|
-
this.getAssetBalances = (params) => this.request('GET', '/api/v5/asset/balances', params);
|
|
216
|
-
/**
|
|
217
|
-
* 资金划转
|
|
218
|
-
*
|
|
219
|
-
* 调用时,API Key 需要有交易权限。
|
|
220
|
-
*
|
|
221
|
-
* 支持母账户的资金账户划转到交易账户,母账户到子账户的资金账户和交易账户划转。
|
|
222
|
-
*
|
|
223
|
-
* 子账户默认可转出至母账户,划转到同一母账户下的其他子账户,需要先调用 设置子账户主动转出权限 接口进行授权。
|
|
224
|
-
*
|
|
225
|
-
* 请求失败不代表划转失败,建议以获取资金划转状态接口返回的状态为准。
|
|
226
|
-
*
|
|
227
|
-
* 限速:2 次/s
|
|
228
|
-
* 限速规则:UserID + Currency
|
|
229
|
-
*
|
|
230
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-funds-transfer
|
|
231
|
-
*/
|
|
232
|
-
this.postAssetTransfer = (params) => this.request('POST', '/api/v5/asset/transfer', params);
|
|
233
|
-
/**
|
|
234
|
-
* 查看账户余额
|
|
235
|
-
*
|
|
236
|
-
* 获取交易账户中资金余额信息。
|
|
237
|
-
*
|
|
238
|
-
* 免息额度和折算率都是公共数据,不在账户接口内展示
|
|
239
|
-
*
|
|
240
|
-
* 限速:10次/2s
|
|
241
|
-
* 限速规则:UserID
|
|
242
|
-
*
|
|
243
|
-
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-balance
|
|
244
|
-
*/
|
|
245
|
-
this.getAccountBalance = (params) => this.request('GET', '/api/v5/account/balance', params);
|
|
246
|
-
/**
|
|
247
|
-
* 查看持仓信息
|
|
248
|
-
*
|
|
249
|
-
* 获取该账户下拥有实际持仓的信息。账户为买卖模式会显示净持仓(net),账户为开平仓模式下会分别返回开多(long)或开空(short)的仓位。按照仓位创建时间倒序排列。
|
|
250
|
-
*
|
|
251
|
-
* 如果该 instId 拥有过仓位且当前持仓量为0,传 instId 时,如果当前存在有效的posId,会返回仓位信息,如果当前不存在有效的 posId 时,不会返回仓位信息;不传 instId 时,仓位信息不返回。
|
|
252
|
-
*
|
|
253
|
-
* 逐仓交易设置中,如果设置为自主划转模式,逐仓转入保证金后,会生成一个持仓量为0的仓位
|
|
254
|
-
*
|
|
255
|
-
* 限速:10次/2s
|
|
256
|
-
* 限速规则:UserID
|
|
257
|
-
*
|
|
258
|
-
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-positions
|
|
259
|
-
*/
|
|
260
|
-
this.getAccountPositions = (params) => this.request('GET', '/api/v5/account/positions', params);
|
|
261
|
-
/**
|
|
262
|
-
* 赚币
|
|
263
|
-
* GET / 查看项目
|
|
264
|
-
*
|
|
265
|
-
* 限速:3次/s
|
|
266
|
-
* 限速规则:UserID
|
|
267
|
-
*/
|
|
268
|
-
this.getFinanceStakingDeFiOffers = (params) => this.request('GET', '/api/v5/finance/staking-defi/offers', params);
|
|
269
|
-
/**
|
|
270
|
-
* 赚币
|
|
271
|
-
* GET / 查看活跃订单
|
|
272
|
-
*
|
|
273
|
-
* 限速:3次/s
|
|
274
|
-
* 限速规则:UserID
|
|
275
|
-
*/
|
|
276
|
-
this.getFinanceStakingDeFiOrdersActive = (params) => this.request('GET', '/api/v5/finance/staking-defi/orders-active', params);
|
|
277
|
-
/**
|
|
278
|
-
* 下单
|
|
279
|
-
*
|
|
280
|
-
* 只有当您的账户有足够的资金才能下单。
|
|
281
|
-
*
|
|
282
|
-
* 限速:60次/2s
|
|
283
|
-
*
|
|
284
|
-
* 跟单交易带单产品的限速:4次/2s
|
|
285
|
-
*
|
|
286
|
-
* 限速规则(期权以外):UserID + Instrument ID
|
|
287
|
-
*
|
|
288
|
-
* 限速规则(只限期权):UserID + Instrument Family
|
|
289
|
-
*
|
|
290
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-place-order
|
|
291
|
-
*/
|
|
292
|
-
this.postTradeOrder = (params) => this.request('POST', '/api/v5/trade/order', params);
|
|
293
|
-
/**
|
|
294
|
-
* 修改订单
|
|
295
|
-
*
|
|
296
|
-
* 修改当前未成交的挂单
|
|
297
|
-
*
|
|
298
|
-
* 限速:60次/2s
|
|
299
|
-
*
|
|
300
|
-
* 跟单交易带单员带单产品的限速:4个/2s
|
|
301
|
-
*
|
|
302
|
-
* 限速规则:User ID + Instrument ID
|
|
303
|
-
*
|
|
304
|
-
* 权限:交易
|
|
305
|
-
*
|
|
306
|
-
* 该接口限速同时受到 子账户限速 及 基于成交比率的子账户限速 限速规则的影响。
|
|
307
|
-
*
|
|
308
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-amend-order
|
|
309
|
-
*/
|
|
310
|
-
this.postTradeAmendOrder = (params) => this.request('POST', '/api/v5/trade/amend-order', params);
|
|
311
|
-
/**
|
|
312
|
-
* 获取未成交订单列表
|
|
313
|
-
*
|
|
314
|
-
* 获取当前账户下所有未成交订单信息
|
|
315
|
-
*
|
|
316
|
-
* 限速:60次/2s
|
|
317
|
-
* 限速规则:UserID
|
|
318
|
-
*
|
|
319
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-get-order-list
|
|
320
|
-
*/
|
|
321
|
-
this.getTradeOrdersPending = (params) => this.request('GET', '/api/v5/trade/orders-pending', params);
|
|
322
|
-
/**
|
|
323
|
-
* 获取历史订单记录(近七天)
|
|
324
|
-
*
|
|
325
|
-
* 获取最近7天挂单,且完成的订单数据,包括7天以前挂单,但近7天才成交的订单数据。按照订单创建时间倒序排序。
|
|
326
|
-
*
|
|
327
|
-
* 已经撤销的未成交单 只保留2小时
|
|
328
|
-
* 限速:40次/2s
|
|
329
|
-
* 限速规则:User ID
|
|
330
|
-
*/
|
|
331
|
-
this.getTradeOrdersHistory = (params) => this.request('GET', '/api/v5/trade/orders-history', params);
|
|
332
|
-
/**
|
|
333
|
-
* 撤单
|
|
334
|
-
*
|
|
335
|
-
* 撤销之前下的未完成订单。
|
|
336
|
-
*
|
|
337
|
-
* 限速:60次/2s
|
|
338
|
-
*
|
|
339
|
-
* 限速规则(期权以外):UserID + Instrument ID
|
|
340
|
-
*
|
|
341
|
-
* 限速规则(只限期权):UserID + Instrument Family
|
|
342
|
-
*
|
|
343
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-cancel-order
|
|
344
|
-
*/
|
|
345
|
-
this.postTradeCancelOrder = (params) => this.request('POST', '/api/v5/trade/cancel-order', params);
|
|
346
|
-
/**
|
|
347
|
-
* 查看子账户列表
|
|
348
|
-
*
|
|
349
|
-
* 仅适用于母账户。
|
|
350
|
-
*
|
|
351
|
-
* 限速:2次/2s
|
|
352
|
-
*
|
|
353
|
-
* 限速规则:UserID
|
|
354
|
-
*/
|
|
355
|
-
this.getSubAccountList = (params) => this.request('GET', '/api/v5/users/subaccount/list', params);
|
|
356
|
-
/**
|
|
357
|
-
* 设置子账户主动转出权限
|
|
358
|
-
*
|
|
359
|
-
* 设置子账户转出权限(仅适用于母账户),默认可转出至母账户。
|
|
360
|
-
*
|
|
361
|
-
* 限速:1次/s
|
|
362
|
-
*
|
|
363
|
-
* 限速规则:UserID
|
|
364
|
-
*/
|
|
365
|
-
this.postSetSubAccountTransferOut = (params) => this.request('POST', '/api/v5/users/subaccount/set-transfer-out', params);
|
|
366
|
-
/**
|
|
367
|
-
* 获取资金划转状态
|
|
368
|
-
*
|
|
369
|
-
* 获取最近2个星期内的资金划转状态数据
|
|
370
|
-
*
|
|
371
|
-
* 限速:10 次/s
|
|
372
|
-
*
|
|
373
|
-
* 限速规则:UserID
|
|
374
|
-
*
|
|
375
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-funds-transfer-state
|
|
376
|
-
*/
|
|
377
|
-
this.getAssetTransferState = (params) => this.request('GET', '/api/v5/asset/transfer-state', params);
|
|
378
|
-
/**
|
|
379
|
-
* 获取币种列表
|
|
380
|
-
*
|
|
381
|
-
* 获取当前用户KYC实体支持的币种列表。
|
|
382
|
-
*
|
|
383
|
-
* 限速:6 次/s
|
|
384
|
-
*
|
|
385
|
-
* 限速规则:UserID
|
|
386
|
-
*
|
|
387
|
-
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-currencies
|
|
388
|
-
*/
|
|
389
|
-
this.getAssetCurrencies = (params) => this.request('GET', '/api/v5/asset/currencies', params);
|
|
390
|
-
/**
|
|
391
|
-
* 获取指数行情数据
|
|
392
|
-
*
|
|
393
|
-
*
|
|
394
|
-
* 限速:20 次/2s
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* https://www.okx.com/docs-v5/zh/#public-data-rest-api-get-index-tickers
|
|
398
|
-
*/
|
|
399
|
-
this.getMarketIndexTicker = (params) => this.request('GET', '/api/v5/market/index-tickers', params);
|
|
400
|
-
/**
|
|
401
|
-
* GET / 借贷信息
|
|
402
|
-
* 限速:5次/2s
|
|
403
|
-
* 限速规则:User ID
|
|
404
|
-
* 权限:读取
|
|
405
|
-
* HTTP请求
|
|
406
|
-
*
|
|
407
|
-
* https://www.okx.com/docs-v5/zh/#financial-product-flexible-loan-get-loan-info
|
|
408
|
-
*/
|
|
409
|
-
this.getFlexibleLoanInfo = () => this.request('GET', '/api/v5/finance/flexible-loan/loan-info');
|
|
410
|
-
/**
|
|
411
|
-
* 账单流水查询(近七天)
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
* 限速:5次/s
|
|
415
|
-
*
|
|
416
|
-
*
|
|
417
|
-
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-7-days
|
|
418
|
-
*/
|
|
419
|
-
this.getAccountBills = (params) => this.request('GET', '/api/v5/account/bills', params);
|
|
420
|
-
/**
|
|
421
|
-
* 账单流水查询(近三个月)
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
* 限速:5次/2s
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-3-months
|
|
428
|
-
*/
|
|
429
|
-
this.getAccountBillsArchive = (params) => this.request('GET', '/api/v5/account/bills-archive', params);
|
|
430
|
-
/**
|
|
431
|
-
* POST / 网格策略委托下单
|
|
432
|
-
* 限速:20次/2s
|
|
433
|
-
* 限速规则:User ID + Instrument ID
|
|
434
|
-
* 权限:交易
|
|
435
|
-
* HTTP请求
|
|
436
|
-
*
|
|
437
|
-
* https://www.okx.com/docs-v5/zh/?language=shell#order-book-trading-grid-trading-post-place-grid-algo-order
|
|
438
|
-
*/
|
|
439
|
-
this.postGridAlgoOrder = (params) => this.request('POST', '/api/v5/tradingBot/grid/order-algo', params);
|
|
440
|
-
/**
|
|
441
|
-
* GET / 获取未完成网格策略委托单列表
|
|
442
|
-
* 限速:20次/2s
|
|
443
|
-
* 限速规则:User ID
|
|
444
|
-
* 权限:读取
|
|
445
|
-
* HTTP请求
|
|
446
|
-
*
|
|
447
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-grid-trading-get-grid-algo-order-list
|
|
448
|
-
*/
|
|
449
|
-
this.getGridOrdersAlgoPending = (param) => this.request('GET', '/api/v5/tradingBot/grid/orders-algo-pending', param);
|
|
450
|
-
/**
|
|
451
|
-
* GET / 获取网格策略委托持仓
|
|
452
|
-
* 限速:20次/2s
|
|
453
|
-
* 限速规则:User ID
|
|
454
|
-
* 权限:读取
|
|
455
|
-
* HTTP请求
|
|
456
|
-
*
|
|
457
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-grid-trading-get-grid-algo-order-positions
|
|
458
|
-
*/
|
|
459
|
-
this.getGridPositions = (param) => this.request('GET', '/api/v5/tradingBot/grid/positions', param);
|
|
460
|
-
/**
|
|
461
|
-
* GET / 获取产品深度
|
|
462
|
-
* 限速:40次/2s
|
|
463
|
-
* 限速规则:IP
|
|
464
|
-
* HTTP请求
|
|
465
|
-
*
|
|
466
|
-
* https://www.okx.com/docs-v5/zh/#order-book-trading-market-data-get-order-book
|
|
467
|
-
*/
|
|
468
|
-
this.getMarketBooks = (param) => this.request('GET', '/api/v5/market/books', param);
|
|
469
|
-
if (config.auth.public_key && config.auth.secret_key && config.auth.passphrase) {
|
|
470
|
-
this.noAuth = false;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
async request(method, path, params) {
|
|
474
|
-
const url = new URL('https://www.okx.com');
|
|
475
|
-
url.pathname = path;
|
|
476
|
-
if (method === 'GET') {
|
|
477
|
-
for (const key in params) {
|
|
478
|
-
url.searchParams.set(key, params[key]);
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (this.noAuth) {
|
|
482
|
-
console.info(formatTime(Date.now()), method, url.href);
|
|
483
|
-
const res = await fetch(url.href, { method });
|
|
484
|
-
return res.json();
|
|
1
|
+
import { encodeBase64, formatTime, HmacSHA256 } from '@yuants/utils';
|
|
2
|
+
export const getDefaultCredential = () => ({
|
|
3
|
+
access_key: process.env.ACCESS_KEY,
|
|
4
|
+
secret_key: process.env.SECRET_KEY,
|
|
5
|
+
passphrase: process.env.PASSPHRASE,
|
|
6
|
+
});
|
|
7
|
+
export async function request(credential, method, path, params) {
|
|
8
|
+
const url = new URL('https://www.okx.com');
|
|
9
|
+
url.pathname = path;
|
|
10
|
+
if (method === 'GET' && params) {
|
|
11
|
+
for (const key in params) {
|
|
12
|
+
url.searchParams.set(key, String(params[key]));
|
|
485
13
|
}
|
|
486
|
-
const timestamp = formatTime(Date.now(), 'UTC').replace(' ', 'T');
|
|
487
|
-
const secret_key = this.config.auth.secret_key;
|
|
488
|
-
const body = method === 'GET' ? '' : JSON.stringify(params);
|
|
489
|
-
const signData = timestamp + method + url.pathname + url.search + body;
|
|
490
|
-
const str = CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(signData, secret_key));
|
|
491
|
-
const headers = {
|
|
492
|
-
'Content-Type': 'application/json',
|
|
493
|
-
'OK-ACCESS-KEY': this.config.auth.public_key,
|
|
494
|
-
'OK-ACCESS-SIGN': str,
|
|
495
|
-
'OK-ACCESS-TIMESTAMP': timestamp,
|
|
496
|
-
'OK-ACCESS-PASSPHRASE': this.config.auth.passphrase,
|
|
497
|
-
};
|
|
498
|
-
console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body, signData);
|
|
499
|
-
const res = await fetch(url.href, {
|
|
500
|
-
method,
|
|
501
|
-
headers,
|
|
502
|
-
body: body || undefined,
|
|
503
|
-
});
|
|
504
|
-
return res.json();
|
|
505
14
|
}
|
|
15
|
+
const timestamp = formatTime(Date.now(), 'UTC').replace(' ', 'T');
|
|
16
|
+
const secret_key = credential.secret_key;
|
|
17
|
+
const body = method === 'GET' ? '' : JSON.stringify(params);
|
|
18
|
+
const signData = timestamp + method + url.pathname + url.search + body;
|
|
19
|
+
const str = encodeBase64(await HmacSHA256(
|
|
20
|
+
//
|
|
21
|
+
new TextEncoder().encode(signData), new TextEncoder().encode(secret_key)));
|
|
22
|
+
const headers = {
|
|
23
|
+
'Content-Type': 'application/json',
|
|
24
|
+
'OK-ACCESS-KEY': credential.access_key,
|
|
25
|
+
'OK-ACCESS-SIGN': str,
|
|
26
|
+
'OK-ACCESS-TIMESTAMP': timestamp,
|
|
27
|
+
'OK-ACCESS-PASSPHRASE': credential.passphrase,
|
|
28
|
+
};
|
|
29
|
+
console.info(formatTime(Date.now()), method, url.href, JSON.stringify(headers), body, signData);
|
|
30
|
+
const res = await fetch(url.href, {
|
|
31
|
+
method,
|
|
32
|
+
headers,
|
|
33
|
+
body: body || undefined,
|
|
34
|
+
});
|
|
35
|
+
console.info(formatTime(Date.now()), 'PrivateApiResponse', credential.access_key, method, url.href, res.status);
|
|
36
|
+
return res.json();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 获取账户资产估值
|
|
40
|
+
*
|
|
41
|
+
* 查看账户资产估值
|
|
42
|
+
*
|
|
43
|
+
* 限速:1次/s
|
|
44
|
+
* 限速规则:UserID
|
|
45
|
+
*
|
|
46
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-account-asset-valuation
|
|
47
|
+
*/
|
|
48
|
+
export function getAssetValuation(credential, params) {
|
|
49
|
+
return request(credential, 'GET', '/api/v5/asset/asset-valuation', params);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 查看账户配置
|
|
53
|
+
* 查看当前账户的配置信息。
|
|
54
|
+
*
|
|
55
|
+
* 限速:5次/2s
|
|
56
|
+
* 限速规则:UserID
|
|
57
|
+
*
|
|
58
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-account-configuration
|
|
59
|
+
*/
|
|
60
|
+
export function getAccountConfig(credential) {
|
|
61
|
+
return request(credential, 'GET', '/api/v5/account/config');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* 获取余币宝余额
|
|
65
|
+
*
|
|
66
|
+
* 限速:6次/s
|
|
67
|
+
* 限速规则:UserID
|
|
68
|
+
*
|
|
69
|
+
* https://www.okx.com/docs-v5/zh/#financial-product-savings-get-saving-balance
|
|
70
|
+
*/
|
|
71
|
+
export function getFinanceSavingsBalance(credential, params) {
|
|
72
|
+
return request(credential, 'GET', '/api/v5/finance/savings/balance', params);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 余币宝申购/赎回
|
|
76
|
+
*
|
|
77
|
+
* 仅资金账户中的资产支持余币宝申购。
|
|
78
|
+
*
|
|
79
|
+
* 限速:6次/s
|
|
80
|
+
*
|
|
81
|
+
* 限速规则:UserID
|
|
82
|
+
*
|
|
83
|
+
* https://www.okx.com/docs-v5/zh/#financial-product-savings-post-savings-purchase-redemption
|
|
84
|
+
*/
|
|
85
|
+
export function postFinanceSavingsPurchaseRedempt(credential, params) {
|
|
86
|
+
return request(credential, 'POST', '/api/v5/finance/savings/purchase-redempt', params);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 提币
|
|
90
|
+
*
|
|
91
|
+
* 用户提币。普通子账户不支持提币。
|
|
92
|
+
*
|
|
93
|
+
* API只能提币到免认证地址/账户上,通过 WEB/APP 可以设置免认证地址。
|
|
94
|
+
*
|
|
95
|
+
* 关于标签:某些币种如XRP充币时同时需要一个充值地址和标签(又名memo/payment_id),标签是一种保证您的充币地址唯一性的数字串,与充币地址成对出现并一一对应。请您务必遵守正确的充值步骤,在提币时输入完整信息,否则将面临丢失币的风险!
|
|
96
|
+
* 对于有标签的币种,如果是OKX用户间的提币,请走内部转账不要走链上提币。
|
|
97
|
+
*
|
|
98
|
+
* 限速:6次/s
|
|
99
|
+
* 限速规则:UserID
|
|
100
|
+
*
|
|
101
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-withdrawal
|
|
102
|
+
*/
|
|
103
|
+
export function postAssetWithdrawal(credential, params) {
|
|
104
|
+
return request(credential, 'POST', '/api/v5/asset/withdrawal', params);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 获取充值地址信息
|
|
108
|
+
*
|
|
109
|
+
* 获取各个币种的充值地址,包括曾使用过的老地址。
|
|
110
|
+
*
|
|
111
|
+
* 限速:6次/s
|
|
112
|
+
* 限速规则:UserID
|
|
113
|
+
*
|
|
114
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-address
|
|
115
|
+
*/
|
|
116
|
+
export function getAssetDepositAddress(credential, params) {
|
|
117
|
+
return request(credential, 'GET', '/api/v5/asset/deposit-address', params);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 获取提币记录
|
|
121
|
+
*
|
|
122
|
+
* 根据币种,提币状态,时间范围获取提币记录,按照时间倒序排列,默认返回100条数据。
|
|
123
|
+
* 支持Websocket订阅,参考 提币信息频道。
|
|
124
|
+
*
|
|
125
|
+
* 限速:6 次/s
|
|
126
|
+
* 限速规则:UserID
|
|
127
|
+
*
|
|
128
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-withdrawal-history
|
|
129
|
+
*/
|
|
130
|
+
export function getAssetWithdrawalHistory(credential, params) {
|
|
131
|
+
return request(credential, 'GET', '/api/v5/asset/withdrawal-history', params);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 获取充值记录
|
|
135
|
+
*
|
|
136
|
+
* 根据币种,充值状态,时间范围获取充值记录,按照时间倒序排列,默认返回 100 条数据。
|
|
137
|
+
* 支持Websocket订阅,参考 充值信息频道。
|
|
138
|
+
*
|
|
139
|
+
* 限速:6次/s
|
|
140
|
+
* 限速规则:UserID
|
|
141
|
+
*
|
|
142
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-deposit-history
|
|
143
|
+
*/
|
|
144
|
+
export function getAssetDepositHistory(credential, params) {
|
|
145
|
+
return request(credential, 'GET', '/api/v5/asset/deposit-history', params);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 获取资金账户余额
|
|
149
|
+
*
|
|
150
|
+
* 获取资金账户所有资产列表,查询各币种的余额、冻结和可用等信息。
|
|
151
|
+
*
|
|
152
|
+
* 只返回余额大于0的币资产信息。
|
|
153
|
+
*
|
|
154
|
+
* 限速:6次/s
|
|
155
|
+
* 限速规则:UserID
|
|
156
|
+
*
|
|
157
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-balance
|
|
158
|
+
*/
|
|
159
|
+
export function getAssetBalances(credential, params) {
|
|
160
|
+
return request(credential, 'GET', '/api/v5/asset/balances', params);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 资金划转
|
|
164
|
+
*
|
|
165
|
+
* 调用时,API Key 需要有交易权限。
|
|
166
|
+
*
|
|
167
|
+
* 支持母账户的资金账户划转到交易账户,母账户到子账户的资金账户和交易账户划转。
|
|
168
|
+
*
|
|
169
|
+
* 子账户默认可转出至母账户,划转到同一母账户下的其他子账户,需要先调用 设置子账户主动转出权限 接口进行授权。
|
|
170
|
+
*
|
|
171
|
+
* 请求失败不代表划转失败,建议以获取资金划转状态接口返回的状态为准。
|
|
172
|
+
*
|
|
173
|
+
* 限速:2 次/s
|
|
174
|
+
* 限速规则:UserID + Currency
|
|
175
|
+
*
|
|
176
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-funds-transfer
|
|
177
|
+
*/
|
|
178
|
+
export function postAssetTransfer(credential, params) {
|
|
179
|
+
return request(credential, 'POST', '/api/v5/asset/transfer', params);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 查看账户余额
|
|
183
|
+
*
|
|
184
|
+
* 获取交易账户中资金余额信息。
|
|
185
|
+
*
|
|
186
|
+
* 免息额度和折算率都是公共数据,不在账户接口内展示
|
|
187
|
+
*
|
|
188
|
+
* 限速:10次/2s
|
|
189
|
+
* 限速规则:UserID
|
|
190
|
+
*
|
|
191
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-balance
|
|
192
|
+
*/
|
|
193
|
+
export function getAccountBalance(credential, params) {
|
|
194
|
+
return request(credential, 'GET', '/api/v5/account/balance', params);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 查看持仓信息
|
|
198
|
+
*
|
|
199
|
+
* 获取该账户下拥有实际持仓的信息。账户为买卖模式会显示净持仓(net),账户为开平仓模式下会分别返回开多(long)或开空(short)的仓位。按照仓位创建时间倒序排列。
|
|
200
|
+
*
|
|
201
|
+
* 如果该 instId 拥有过仓位且当前持仓量为0,传 instId 时,如果当前存在有效的posId,会返回仓位信息,如果当前不存在有效的 posId 时,不会返回仓位信息;不传 instId 时,仓位信息不返回。
|
|
202
|
+
*
|
|
203
|
+
* 逐仓交易设置中,如果设置为自主划转模式,逐仓转入保证金后,会生成一个持仓量为0的仓位
|
|
204
|
+
*
|
|
205
|
+
* 限速:10次/2s
|
|
206
|
+
* 限速规则:UserID
|
|
207
|
+
*
|
|
208
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-positions
|
|
209
|
+
*/
|
|
210
|
+
export function getAccountPositions(credential, params) {
|
|
211
|
+
return request(credential, 'GET', '/api/v5/account/positions', params);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* 获取最大可下单数量
|
|
215
|
+
*
|
|
216
|
+
* 获取最大可买卖/开仓数量,可对应下单时的 sz 字段
|
|
217
|
+
*
|
|
218
|
+
* 限速:20次/2s
|
|
219
|
+
* 限速规则:UserID
|
|
220
|
+
*
|
|
221
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-maximum-tradable-size
|
|
222
|
+
*/
|
|
223
|
+
export function getAccountMaxSize(credential, params) {
|
|
224
|
+
return request(credential, 'GET', '/api/v5/account/max-size', params);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 赚币
|
|
228
|
+
* GET / 查看项目
|
|
229
|
+
*
|
|
230
|
+
* 限速:3次/s
|
|
231
|
+
* 限速规则:UserID
|
|
232
|
+
*/
|
|
233
|
+
export function getFinanceStakingDeFiOffers(credential, params) {
|
|
234
|
+
return request(credential, 'GET', '/api/v5/finance/staking-defi/offers', params);
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* 赚币
|
|
238
|
+
* GET / 查看活跃订单
|
|
239
|
+
*
|
|
240
|
+
* 限速:3次/s
|
|
241
|
+
* 限速规则:UserID
|
|
242
|
+
*/
|
|
243
|
+
export function getFinanceStakingDeFiOrdersActive(credential, params) {
|
|
244
|
+
return request(credential, 'GET', '/api/v5/finance/staking-defi/orders-active', params);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* 下单
|
|
248
|
+
*
|
|
249
|
+
* 只有当您的账户有足够的资金才能下单。
|
|
250
|
+
*
|
|
251
|
+
* 限速:60次/2s
|
|
252
|
+
*
|
|
253
|
+
* 跟单交易带单产品的限速:4次/2s
|
|
254
|
+
*
|
|
255
|
+
* 限速规则(期权以外):UserID + Instrument ID
|
|
256
|
+
*
|
|
257
|
+
* 限速规则(只限期权):UserID + Instrument Family
|
|
258
|
+
*
|
|
259
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-place-order
|
|
260
|
+
*/
|
|
261
|
+
export function postTradeOrder(credential, params) {
|
|
262
|
+
return request(credential, 'POST', '/api/v5/trade/order', params);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 修改订单
|
|
266
|
+
*
|
|
267
|
+
* 修改当前未成交的挂单
|
|
268
|
+
*
|
|
269
|
+
* 限速:60次/2s
|
|
270
|
+
*
|
|
271
|
+
* 跟单交易带单员带单产品的限速:4个/2s
|
|
272
|
+
*
|
|
273
|
+
* 限速规则:User ID + Instrument ID
|
|
274
|
+
*
|
|
275
|
+
* 权限:交易
|
|
276
|
+
*
|
|
277
|
+
* 该接口限速同时受到 子账户限速 及 基于成交比率的子账户限速 限速规则的影响。
|
|
278
|
+
*
|
|
279
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-amend-order
|
|
280
|
+
*/
|
|
281
|
+
export function postTradeAmendOrder(credential, params) {
|
|
282
|
+
return request(credential, 'POST', '/api/v5/trade/amend-order', params);
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* 获取未成交订单列表
|
|
286
|
+
*
|
|
287
|
+
* 获取当前账户下所有未成交订单信息
|
|
288
|
+
*
|
|
289
|
+
* 限速:60次/2s
|
|
290
|
+
* 限速规则:UserID
|
|
291
|
+
*
|
|
292
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-get-order-list
|
|
293
|
+
*/
|
|
294
|
+
export function getTradeOrdersPending(credential, params) {
|
|
295
|
+
return request(credential, 'GET', '/api/v5/trade/orders-pending', params);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* 获取历史订单记录(近七天)
|
|
299
|
+
*
|
|
300
|
+
* 获取最近7天挂单,且完成的订单数据,包括7天以前挂单,但近7天才成交的订单数据。按照订单创建时间倒序排序。
|
|
301
|
+
*
|
|
302
|
+
* 已经撤销的未成交单 只保留2小时
|
|
303
|
+
* 限速:40次/2s
|
|
304
|
+
* 限速规则:User ID
|
|
305
|
+
*/
|
|
306
|
+
export function getTradeOrdersHistory(credential, params) {
|
|
307
|
+
return request(credential, 'GET', '/api/v5/trade/orders-history', params);
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* 撤单
|
|
311
|
+
*
|
|
312
|
+
* 撤销之前下的未完成订单。
|
|
313
|
+
*
|
|
314
|
+
* 限速:60次/2s
|
|
315
|
+
*
|
|
316
|
+
* 限速规则(期权以外):UserID + Instrument ID
|
|
317
|
+
*
|
|
318
|
+
* 限速规则(只限期权):UserID + Instrument Family
|
|
319
|
+
*
|
|
320
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-trade-post-cancel-order
|
|
321
|
+
*/
|
|
322
|
+
export function postTradeCancelOrder(credential, params) {
|
|
323
|
+
return request(credential, 'POST', '/api/v5/trade/cancel-order', params);
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* 查看子账户列表
|
|
327
|
+
*
|
|
328
|
+
* 仅适用于母账户。
|
|
329
|
+
*
|
|
330
|
+
* 限速:2次/2s
|
|
331
|
+
*
|
|
332
|
+
* 限速规则:UserID
|
|
333
|
+
*/
|
|
334
|
+
export function getSubAccountList(credential, params) {
|
|
335
|
+
return request(credential, 'GET', '/api/v5/users/subaccount/list', params);
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 设置子账户主动转出权限
|
|
339
|
+
*
|
|
340
|
+
* 设置子账户转出权限(仅适用于母账户),默认可转出至母账户。
|
|
341
|
+
*
|
|
342
|
+
* 限速:1次/s
|
|
343
|
+
*
|
|
344
|
+
* 限速规则:UserID
|
|
345
|
+
*/
|
|
346
|
+
export function postSetSubAccountTransferOut(credential, params) {
|
|
347
|
+
return request(credential, 'POST', '/api/v5/users/subaccount/set-transfer-out', params);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* 获取资金划转状态
|
|
351
|
+
*
|
|
352
|
+
* 获取最近2个星期内的资金划转状态数据
|
|
353
|
+
*
|
|
354
|
+
* 限速:10 次/s
|
|
355
|
+
*
|
|
356
|
+
* 限速规则:UserID
|
|
357
|
+
*
|
|
358
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-funds-transfer-state
|
|
359
|
+
*/
|
|
360
|
+
export function getAssetTransferState(credential, params) {
|
|
361
|
+
return request(credential, 'GET', '/api/v5/asset/transfer-state', params);
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* 获取币种列表
|
|
365
|
+
*
|
|
366
|
+
* 获取当前用户KYC实体支持的币种列表。
|
|
367
|
+
*
|
|
368
|
+
* 限速:6 次/s
|
|
369
|
+
*
|
|
370
|
+
* 限速规则:UserID
|
|
371
|
+
*
|
|
372
|
+
* https://www.okx.com/docs-v5/zh/#funding-account-rest-api-get-currencies
|
|
373
|
+
*/
|
|
374
|
+
export function getAssetCurrencies(credential, params) {
|
|
375
|
+
return request(credential, 'GET', '/api/v5/asset/currencies', params);
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* GET / 借贷信息
|
|
379
|
+
* 限速:5次/2s
|
|
380
|
+
* 限速规则:User ID
|
|
381
|
+
* 权限:读取
|
|
382
|
+
* HTTP请求
|
|
383
|
+
*
|
|
384
|
+
* https://www.okx.com/docs-v5/zh/#financial-product-flexible-loan-get-loan-info
|
|
385
|
+
*/
|
|
386
|
+
export function getFlexibleLoanInfo(credential) {
|
|
387
|
+
return request(credential, 'GET', '/api/v5/finance/flexible-loan/loan-info');
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* 账单流水查询(近七天)
|
|
391
|
+
*
|
|
392
|
+
*
|
|
393
|
+
* 限速:5次/s
|
|
394
|
+
*
|
|
395
|
+
*
|
|
396
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-7-days
|
|
397
|
+
*/
|
|
398
|
+
export function getAccountBills(credential, params) {
|
|
399
|
+
return request(credential, 'GET', '/api/v5/account/bills', params);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* 账单流水查询(近三个月)
|
|
403
|
+
*
|
|
404
|
+
*
|
|
405
|
+
* 限速:5次/2s
|
|
406
|
+
*
|
|
407
|
+
*
|
|
408
|
+
* https://www.okx.com/docs-v5/zh/#trading-account-rest-api-get-bills-details-last-3-months
|
|
409
|
+
*/
|
|
410
|
+
export function getAccountBillsArchive(credential, params) {
|
|
411
|
+
return request(credential, 'GET', '/api/v5/account/bills-archive', params);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* POST / 网格策略委托下单
|
|
415
|
+
* 限速:20次/2s
|
|
416
|
+
* 限速规则:User ID + Instrument ID
|
|
417
|
+
* 权限:交易
|
|
418
|
+
* HTTP请求
|
|
419
|
+
*
|
|
420
|
+
* https://www.okx.com/docs-v5/zh/?language=shell#order-book-trading-grid-trading-post-place-grid-algo-order
|
|
421
|
+
*/
|
|
422
|
+
export function postGridAlgoOrder(credential, params) {
|
|
423
|
+
return request(credential, 'POST', '/api/v5/tradingBot/grid/order-algo', params);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* GET / 获取未完成网格策略委托单列表
|
|
427
|
+
* 限速:20次/2s
|
|
428
|
+
* 限速规则:User ID
|
|
429
|
+
* 权限:读取
|
|
430
|
+
* HTTP请求
|
|
431
|
+
*
|
|
432
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-grid-trading-get-grid-algo-order-list
|
|
433
|
+
*/
|
|
434
|
+
export function getGridOrdersAlgoPending(credential, param) {
|
|
435
|
+
return request(credential, 'GET', '/api/v5/tradingBot/grid/orders-algo-pending', param);
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* GET / 获取网格策略委托持仓
|
|
439
|
+
* 限速:20次/2s
|
|
440
|
+
* 限速规则:User ID
|
|
441
|
+
* 权限:读取
|
|
442
|
+
* HTTP请求
|
|
443
|
+
*
|
|
444
|
+
* https://www.okx.com/docs-v5/zh/#order-book-trading-grid-trading-get-grid-algo-order-positions
|
|
445
|
+
*/
|
|
446
|
+
export function getGridPositions(credential, param) {
|
|
447
|
+
return request(credential, 'GET', '/api/v5/tradingBot/grid/positions', param);
|
|
506
448
|
}
|
|
507
|
-
export const client = new OkxClient({
|
|
508
|
-
auth: {
|
|
509
|
-
public_key: process.env.ACCESS_KEY,
|
|
510
|
-
secret_key: process.env.SECRET_KEY,
|
|
511
|
-
passphrase: process.env.PASSPHRASE,
|
|
512
|
-
},
|
|
513
|
-
});
|
|
514
449
|
//# sourceMappingURL=api.js.map
|