okx-api 0.0.1 → 0.0.4
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/README.md +43 -173
- package/lib/constants/funding.d.ts +139 -0
- package/lib/constants/funding.js +143 -0
- package/lib/constants/funding.js.map +1 -0
- package/lib/constants/index.d.ts +1 -0
- package/lib/constants/index.js +18 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +18 -13
- package/lib/index.js.map +1 -1
- package/lib/rest-client.d.ts +402 -0
- package/lib/rest-client.js +741 -0
- package/lib/rest-client.js.map +1 -0
- package/lib/types/rest/index.d.ts +3 -0
- package/lib/types/rest/index.js +20 -0
- package/lib/types/rest/index.js.map +1 -0
- package/lib/types/rest/request/account.d.ts +32 -0
- package/lib/types/rest/request/account.js +3 -0
- package/lib/types/rest/request/account.js.map +1 -0
- package/lib/types/rest/request/block-trading.d.ts +60 -0
- package/lib/types/rest/request/block-trading.js +3 -0
- package/lib/types/rest/request/block-trading.js.map +1 -0
- package/lib/types/rest/request/convert.d.ts +19 -0
- package/lib/types/rest/request/convert.js +3 -0
- package/lib/types/rest/request/convert.js.map +1 -0
- package/lib/types/rest/request/funding.d.ts +21 -0
- package/lib/types/rest/request/funding.js +3 -0
- package/lib/types/rest/request/funding.js.map +1 -0
- package/lib/types/rest/request/grid-trading.d.ts +30 -0
- package/lib/types/rest/request/grid-trading.js +3 -0
- package/lib/types/rest/request/grid-trading.js.map +1 -0
- package/lib/types/rest/request/index.d.ts +8 -0
- package/lib/types/rest/request/index.js +25 -0
- package/lib/types/rest/request/index.js.map +1 -0
- package/lib/types/rest/request/shared.d.ts +7 -0
- package/lib/types/rest/request/shared.js +3 -0
- package/lib/types/rest/request/shared.js.map +1 -0
- package/lib/types/rest/request/subaccount.d.ts +12 -0
- package/lib/types/rest/request/subaccount.js +3 -0
- package/lib/types/rest/request/subaccount.js.map +1 -0
- package/lib/types/rest/request/trade.d.ts +113 -0
- package/lib/types/rest/request/trade.js +3 -0
- package/lib/types/rest/request/trade.js.map +1 -0
- package/lib/types/rest/response/index.d.ts +6 -0
- package/lib/types/rest/response/index.js +23 -0
- package/lib/types/rest/response/index.js.map +1 -0
- package/lib/types/rest/response/private-account.d.ts +213 -0
- package/lib/types/rest/response/private-account.js +3 -0
- package/lib/types/rest/response/private-account.js.map +1 -0
- package/lib/types/rest/response/private-block-trading.d.ts +89 -0
- package/lib/types/rest/response/private-block-trading.js +3 -0
- package/lib/types/rest/response/private-block-trading.js.map +1 -0
- package/lib/types/rest/response/private-funding.d.ts +68 -0
- package/lib/types/rest/response/private-funding.js +3 -0
- package/lib/types/rest/response/private-funding.js.map +1 -0
- package/lib/types/rest/response/private-subaccount.d.ts +56 -0
- package/lib/types/rest/response/private-subaccount.js +3 -0
- package/lib/types/rest/response/private-subaccount.js.map +1 -0
- package/lib/types/rest/response/private-trade.d.ts +235 -0
- package/lib/types/rest/response/private-trade.js +3 -0
- package/lib/types/rest/response/private-trade.js.map +1 -0
- package/lib/types/rest/response/public-data.d.ts +70 -0
- package/lib/types/rest/response/public-data.js +3 -0
- package/lib/types/rest/response/public-data.js.map +1 -0
- package/lib/types/rest/shared.d.ts +40 -0
- package/lib/types/rest/shared.js +3 -0
- package/lib/types/rest/shared.js.map +1 -0
- package/lib/util/BaseRestClient.d.ts +34 -0
- package/lib/util/BaseRestClient.js +204 -0
- package/lib/util/BaseRestClient.js.map +1 -0
- package/lib/util/browser-support.d.ts +1 -0
- package/lib/util/browser-support.js +24 -0
- package/lib/util/browser-support.js.map +1 -0
- package/lib/util/node-support.d.ts +1 -0
- package/lib/util/node-support.js +9 -0
- package/lib/util/node-support.js.map +1 -0
- package/lib/util/requestUtils.d.ts +17 -0
- package/lib/util/requestUtils.js +52 -0
- package/lib/util/requestUtils.js.map +1 -0
- package/lib/util/typeGuards.d.ts +2 -0
- package/lib/util/typeGuards.js +14 -0
- package/lib/util/typeGuards.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,741 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RestClient = void 0;
|
|
16
|
+
const requestUtils_1 = require("./util/requestUtils");
|
|
17
|
+
const BaseRestClient_1 = __importDefault(require("./util/BaseRestClient"));
|
|
18
|
+
class RestClient extends BaseRestClient_1.default {
|
|
19
|
+
/**
|
|
20
|
+
* @public Creates an instance of the REST API client.
|
|
21
|
+
*/
|
|
22
|
+
constructor(credentials, environment = 'live', restClientOptions = {}, requestOptions = {}) {
|
|
23
|
+
super(credentials, (0, requestUtils_1.getRestBaseUrl)(environment, restClientOptions), restClientOptions, requestOptions, environment);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
getServerTime() {
|
|
27
|
+
var _a;
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const response = yield this.get('/api/v5/public/time');
|
|
30
|
+
const timestamp = Array.isArray(response) ? Number((_a = response[0]) === null || _a === void 0 ? void 0 : _a.ts) : NaN;
|
|
31
|
+
if (!Array.isArray(response) ||
|
|
32
|
+
isNaN(timestamp) ||
|
|
33
|
+
typeof timestamp !== 'number') {
|
|
34
|
+
throw response;
|
|
35
|
+
}
|
|
36
|
+
return timestamp;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* Trade endpoints (private)
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
submitOrder(params) {
|
|
45
|
+
return this.postPrivate('/api/v5/trade/order', params);
|
|
46
|
+
}
|
|
47
|
+
submitMultipleOrders(params) {
|
|
48
|
+
return this.postPrivate('/api/v5/trade/batch-orders', params);
|
|
49
|
+
}
|
|
50
|
+
cancelOrder(params) {
|
|
51
|
+
return this.postPrivate('/api/v5/trade/cancel-order', params);
|
|
52
|
+
}
|
|
53
|
+
cancelMultipleOrders(params) {
|
|
54
|
+
return this.postPrivate('/api/v5/trade/cancel-batch-orders', params);
|
|
55
|
+
}
|
|
56
|
+
amendOrder(params) {
|
|
57
|
+
return this.postPrivate('/api/v5/trade/amend-order', params);
|
|
58
|
+
}
|
|
59
|
+
amendMultipleOrders(params) {
|
|
60
|
+
return this.postPrivate('/api/v5/trade/amend-batch-orders', params);
|
|
61
|
+
}
|
|
62
|
+
closePositions(params) {
|
|
63
|
+
return this.postPrivate('/api/v5/trade/close-position', params);
|
|
64
|
+
}
|
|
65
|
+
getOrderDetails(params) {
|
|
66
|
+
return this.getPrivate('/api/v5/trade/order', params);
|
|
67
|
+
}
|
|
68
|
+
getOrderList(params) {
|
|
69
|
+
return this.getPrivate('/api/v5/trade/orders-pending', params);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get history for last 7 days
|
|
73
|
+
*/
|
|
74
|
+
getOrderHistory(params) {
|
|
75
|
+
return this.getPrivate('/api/v5/trade/orders-history', params);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get history for last 3 months
|
|
79
|
+
*/
|
|
80
|
+
getOrderHistoryArchive(params) {
|
|
81
|
+
return this.getPrivate('/api/v5/trade/orders-history-archive', params);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get history for last 7 days
|
|
85
|
+
*/
|
|
86
|
+
getFills(params) {
|
|
87
|
+
return this.getPrivate('/api/v5/trade/fills', params);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get history for last 3 months
|
|
91
|
+
*/
|
|
92
|
+
getFillsHistory(params) {
|
|
93
|
+
return this.getPrivate('/api/v5/trade/fills-history', params);
|
|
94
|
+
}
|
|
95
|
+
placeAlgoOrder(params) {
|
|
96
|
+
return this.postPrivate('/api/v5/trade/order-algo', params);
|
|
97
|
+
}
|
|
98
|
+
cancelAlgoOrder(params) {
|
|
99
|
+
return this.postPrivate('/api/v5/trade/cancel-algos', params);
|
|
100
|
+
}
|
|
101
|
+
cancelAdvanceAlgoOrder(params) {
|
|
102
|
+
return this.postPrivate('/api/v5/trade/cancel-advance-algos', params);
|
|
103
|
+
}
|
|
104
|
+
getAlgoOrderList(params) {
|
|
105
|
+
return this.getPrivate('/api/v5/trade/orders-algo-pending', params);
|
|
106
|
+
}
|
|
107
|
+
getAlgoOrderHistory(params) {
|
|
108
|
+
return this.getPrivate('/api/v5/trade/orders-algo-history', params);
|
|
109
|
+
}
|
|
110
|
+
/** Get easy convert currency list */
|
|
111
|
+
getEasyConvertCurrencies() {
|
|
112
|
+
return this.getPrivate('/api/v5/trade/easy-convert-currency-list');
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Place easy convert : Convert small currencies to mainstream currencies.
|
|
116
|
+
* Only applicable to the crypto balance less than $10.
|
|
117
|
+
*
|
|
118
|
+
* Maximum 5 currencies can be selected in one order.
|
|
119
|
+
* If there are multiple currencies, separate them with commas in the "from" field.
|
|
120
|
+
*/
|
|
121
|
+
submitEasyConvert(fromCcys, toCcy) {
|
|
122
|
+
return this.postPrivate('/api/v5/trade/easy-convert', {
|
|
123
|
+
fromCcy: fromCcys,
|
|
124
|
+
toCcy,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/** Get easy convert history : Get the history and status of easy convert trades. */
|
|
128
|
+
getEasyConvertHistory(params) {
|
|
129
|
+
return this.getPrivate('/api/v5/trade/easy-convert-history', params);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get one-click repay currency list : Get list of debt currency data and repay currencies.
|
|
133
|
+
* Debt currencies include both cross and isolated debts.
|
|
134
|
+
*/
|
|
135
|
+
getOneClickRepayCurrencyList(debtType) {
|
|
136
|
+
return this.getPrivate('/api/v5/trade/one-click-repay-currency-list', {
|
|
137
|
+
debtType,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Trade one-click repay to repay cross debts.
|
|
142
|
+
* Isolated debts are not applicable.
|
|
143
|
+
* The maximum repayment amount is based on the remaining available balance of funding and trading accounts.
|
|
144
|
+
*/
|
|
145
|
+
submitOneClickRepay(debtCcys, repayCcy) {
|
|
146
|
+
return this.postPrivate('/api/v5/trade/one-click-repay', {
|
|
147
|
+
debtCcy: debtCcys.join(','),
|
|
148
|
+
repayCcy,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
/** Get the history and status of one-click repay trades. */
|
|
152
|
+
getOneClickRepayHistory(params) {
|
|
153
|
+
return this.getPrivate('/api/v5/trade/one-click-repay-history', params);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
*
|
|
157
|
+
* Block trading endpoints (private)
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
getBlockCounterParties() {
|
|
161
|
+
return this.getPrivate('/api/v5/rfq/counterparties');
|
|
162
|
+
}
|
|
163
|
+
createBlockRFQ(params) {
|
|
164
|
+
return this.postPrivate('/api/v5/rfq/create-rfq', params);
|
|
165
|
+
}
|
|
166
|
+
cancelBlockRFQ(params) {
|
|
167
|
+
return this.postPrivate('/api/v5/rfq/cancel-rfq', params);
|
|
168
|
+
}
|
|
169
|
+
cancelMultipleBlockRFQs(params) {
|
|
170
|
+
return this.postPrivate('/api/v5/rfq/cancel-batch-rfqs', params);
|
|
171
|
+
}
|
|
172
|
+
cancelAllRFQs() {
|
|
173
|
+
return this.postPrivate('/api/v5/rfq/cancel-all-rfqs');
|
|
174
|
+
}
|
|
175
|
+
executeBlockQuote(params) {
|
|
176
|
+
return this.postPrivate('/api/v5/rfq/execute-quote', params);
|
|
177
|
+
}
|
|
178
|
+
createBlockQuote(params) {
|
|
179
|
+
return this.postPrivate('/api/v5/rfq/create-quote', params);
|
|
180
|
+
}
|
|
181
|
+
cancelBlockQuote(params) {
|
|
182
|
+
return this.postPrivate('/api/v5/rfq/cancel-quote', params);
|
|
183
|
+
}
|
|
184
|
+
cancelMultipleBlockQuotes(params) {
|
|
185
|
+
return this.postPrivate('/api/v5/rfq/cancel-batch-quotes', params);
|
|
186
|
+
}
|
|
187
|
+
cancelAllBlockQuotes() {
|
|
188
|
+
return this.postPrivate('/api/v5/rfq/cancel-all-quotes');
|
|
189
|
+
}
|
|
190
|
+
getBlockRFQs(params) {
|
|
191
|
+
return this.getPrivate('/api/v5/rfq/rfqs', params);
|
|
192
|
+
}
|
|
193
|
+
getBlockQuotes(params) {
|
|
194
|
+
return this.getPrivate('/api/v5/rfq/quotes', params);
|
|
195
|
+
}
|
|
196
|
+
getBlockTrades(params) {
|
|
197
|
+
return this.getPrivate('/api/v5/rfq/trades', params);
|
|
198
|
+
}
|
|
199
|
+
getPublicRFQBlockTrades(params) {
|
|
200
|
+
return this.get('/api/v5/rfq/public-trades', params);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
*
|
|
204
|
+
* Funding endpoints (private)
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
getCurrencies(ccy) {
|
|
208
|
+
return this.getPrivate('/api/v5/asset/currencies', { ccy });
|
|
209
|
+
}
|
|
210
|
+
getBalances(ccy) {
|
|
211
|
+
return this.getPrivate('/api/v5/asset/balances', { ccy });
|
|
212
|
+
}
|
|
213
|
+
getAccountAssetValuation(ccy) {
|
|
214
|
+
return this.getPrivate('/api/v5/asset/asset-valuation', { ccy });
|
|
215
|
+
}
|
|
216
|
+
fundsTransfer(params) {
|
|
217
|
+
return this.postPrivate('/api/v5/asset/transfer', params);
|
|
218
|
+
}
|
|
219
|
+
/** Either parameter transId or clientId is required. */
|
|
220
|
+
getFundsTransferState(params) {
|
|
221
|
+
return this.getPrivate('/api/v5/asset/transfer-state', params);
|
|
222
|
+
}
|
|
223
|
+
getAssetBillsDetails(params) {
|
|
224
|
+
return this.getPrivate('/api/v5/asset/bills', params);
|
|
225
|
+
}
|
|
226
|
+
getLightningDeposits(ccy, amt, to) {
|
|
227
|
+
return this.getPrivate('/api/v5/asset/deposit-lightning', { ccy, amt, to });
|
|
228
|
+
}
|
|
229
|
+
getDepositAddress(ccy) {
|
|
230
|
+
return this.getPrivate('/api/v5/asset/deposit-address', { ccy });
|
|
231
|
+
}
|
|
232
|
+
getDepositHistory(params) {
|
|
233
|
+
return this.getPrivate('/api/v5/asset/deposit-history', params);
|
|
234
|
+
}
|
|
235
|
+
submitWithdraw(params) {
|
|
236
|
+
return this.postPrivate('/api/v5/asset/withdrawal', params);
|
|
237
|
+
}
|
|
238
|
+
submitWithdrawLightning(ccy, invoice, memo) {
|
|
239
|
+
return this.postPrivate('/api/v5/asset/withdrawal-lightning', {
|
|
240
|
+
ccy,
|
|
241
|
+
invoice,
|
|
242
|
+
memo,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
cancelWithdrawal(wdId) {
|
|
246
|
+
return this.postPrivate('/api/v5/asset/cancel-withdrawal', { wdId });
|
|
247
|
+
}
|
|
248
|
+
getWithdrawalHistory(params) {
|
|
249
|
+
return this.getPrivate('/api/v5/asset/withdrawal-history', params);
|
|
250
|
+
}
|
|
251
|
+
smallAssetsConvert(ccy) {
|
|
252
|
+
return this.getPrivate('/api/v5/asset/convert-dust-assets', { ccy });
|
|
253
|
+
}
|
|
254
|
+
getSavingBalance(ccy) {
|
|
255
|
+
return this.getPrivate('/api/v5/asset/saving-balance', { ccy });
|
|
256
|
+
}
|
|
257
|
+
savingsPurchaseRedemption(ccy, amt, side, rate) {
|
|
258
|
+
return this.postPrivate('/api/v5/asset/purchase_redempt', {
|
|
259
|
+
ccy,
|
|
260
|
+
amt,
|
|
261
|
+
side,
|
|
262
|
+
rate,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
setLendingRate(ccy, rate) {
|
|
266
|
+
return this.postPrivate('/api/v5/asset/set-lending-rate', { ccy, rate });
|
|
267
|
+
}
|
|
268
|
+
getLendingHistory(params) {
|
|
269
|
+
return this.getPrivate('/api/v5/asset/lending-history', params);
|
|
270
|
+
}
|
|
271
|
+
getPublicBorrowInfo(ccy) {
|
|
272
|
+
return this.get('/api/v5/asset/lending-rate-summary', { ccy });
|
|
273
|
+
}
|
|
274
|
+
getPublicBorrowHistory(params) {
|
|
275
|
+
return this.get('/api/v5/asset/lending-rate-history', params);
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
*
|
|
279
|
+
* Convert endpoints (private)
|
|
280
|
+
*
|
|
281
|
+
*/
|
|
282
|
+
getConvertCurrencies() {
|
|
283
|
+
return this.getPrivate('/api/v5/asset/convert/currencies');
|
|
284
|
+
}
|
|
285
|
+
getConvertCurrencyPair(fromCcy, toCcy) {
|
|
286
|
+
return this.getPrivate('/api/v5/asset/convert/currency-pair', {
|
|
287
|
+
fromCcy,
|
|
288
|
+
toCcy,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
estimateConvertQuote(params) {
|
|
292
|
+
return this.postPrivate('/api/v5/asset/convert/estimate-quote', params);
|
|
293
|
+
}
|
|
294
|
+
convertTrade(params) {
|
|
295
|
+
return this.postPrivate('/api/v5/asset/convert/trade', params);
|
|
296
|
+
}
|
|
297
|
+
getConvertHistory(params) {
|
|
298
|
+
return this.getPrivate('/api/v5/asset/convert/history', params);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
*
|
|
302
|
+
* Account endpoints (private)
|
|
303
|
+
*
|
|
304
|
+
*/
|
|
305
|
+
getBalance(ccy) {
|
|
306
|
+
return this.getPrivate('/api/v5/account/balance', { ccy });
|
|
307
|
+
}
|
|
308
|
+
getPositions(params) {
|
|
309
|
+
return this.getPrivate('/api/v5/account/positions', params);
|
|
310
|
+
}
|
|
311
|
+
getPositionsHistory(params) {
|
|
312
|
+
return this.getPrivate('/api/v5/account/positions-history', params);
|
|
313
|
+
}
|
|
314
|
+
getAccountPositionRisk(instType) {
|
|
315
|
+
return this.getPrivate('/api/v5/account/account-position-risk', {
|
|
316
|
+
instType,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/** Up to last 7 days */
|
|
320
|
+
getBills(params) {
|
|
321
|
+
return this.getPrivate('/api/v5/account/bills', params);
|
|
322
|
+
}
|
|
323
|
+
/** Last 3 months */
|
|
324
|
+
getBillsArchive(params) {
|
|
325
|
+
return this.getPrivate('/api/v5/account/bills-archive', params);
|
|
326
|
+
}
|
|
327
|
+
getAccountConfiguration() {
|
|
328
|
+
return this.getPrivate('/api/v5/account/config');
|
|
329
|
+
}
|
|
330
|
+
setPositionMode(posMode) {
|
|
331
|
+
return this.postPrivate('/api/v5/account/set-position-mode', { posMode });
|
|
332
|
+
}
|
|
333
|
+
setLeverage(params) {
|
|
334
|
+
return this.postPrivate('/api/v5/account/set-leverage', params);
|
|
335
|
+
}
|
|
336
|
+
/** Max buy/sell amount or open amount */
|
|
337
|
+
getMaxBuySellAmount(params) {
|
|
338
|
+
return this.getPrivate('/api/v5/account/max-size', params);
|
|
339
|
+
}
|
|
340
|
+
getMaxAvailableTradableAmount(params) {
|
|
341
|
+
return this.getPrivate('/api/v5/account/max-avail-size', params);
|
|
342
|
+
}
|
|
343
|
+
changePositionMargin(params) {
|
|
344
|
+
return this.postPrivate('/api/v5/account/position/margin-balance', params);
|
|
345
|
+
}
|
|
346
|
+
getLeverage(instId, mgnMode) {
|
|
347
|
+
return this.getPrivate('/api/v5/account/leverage-info', {
|
|
348
|
+
instId,
|
|
349
|
+
mgnMode,
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
getMaxLoan(instId, mgnMode, mgnCcy) {
|
|
353
|
+
return this.getPrivate('/api/v5/account/max-loan', {
|
|
354
|
+
instId,
|
|
355
|
+
mgnMode,
|
|
356
|
+
mgnCcy,
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
getFeeRates(instType, instId, uly) {
|
|
360
|
+
return this.getPrivate('/api/v5/account/trade-fee', {
|
|
361
|
+
instType,
|
|
362
|
+
instId,
|
|
363
|
+
uly,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
getInterestAccrued(params) {
|
|
367
|
+
return this.getPrivate('/api/v5/account/interest-accrued', params);
|
|
368
|
+
}
|
|
369
|
+
getInterestRate(ccy) {
|
|
370
|
+
return this.getPrivate('/api/v5/account/interest-rate', { ccy });
|
|
371
|
+
}
|
|
372
|
+
setGreeksDisplayType(greeksType) {
|
|
373
|
+
return this.postPrivate('/api/v5/account/set-greeks', { greeksType });
|
|
374
|
+
}
|
|
375
|
+
setIsolatedMode(isoMode, type) {
|
|
376
|
+
return this.postPrivate('/api/v5/account/set-isolated-mode', {
|
|
377
|
+
isoMode,
|
|
378
|
+
type,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
getMaxWithdrawals(ccy) {
|
|
382
|
+
return this.getPrivate('/api/v5/account/max-withdrawal', { ccy });
|
|
383
|
+
}
|
|
384
|
+
getAccountRiskState() {
|
|
385
|
+
return this.getPrivate('/api/v5/account/risk-state');
|
|
386
|
+
}
|
|
387
|
+
borrowRepayVIPLoan(ccy, side, amt) {
|
|
388
|
+
return this.postPrivate('/api/v5/account/borrow-repay', { ccy, side, amt });
|
|
389
|
+
}
|
|
390
|
+
getVIPLoanBorrowRepayHistory(params) {
|
|
391
|
+
return this.getPrivate('/api/v5/account/borrow-repay-history', params);
|
|
392
|
+
}
|
|
393
|
+
getBorrowInterestLimits(params) {
|
|
394
|
+
return this.getPrivate('/api/v5/account/interest-limits', params);
|
|
395
|
+
}
|
|
396
|
+
positionBuilder(params) {
|
|
397
|
+
return this.postPrivate('/api/v5/account/simulated_margin', params);
|
|
398
|
+
}
|
|
399
|
+
getGreeks(ccy) {
|
|
400
|
+
return this.getPrivate('/api/v5/account/greeks', { ccy });
|
|
401
|
+
}
|
|
402
|
+
getPMLimitation(params) {
|
|
403
|
+
return this.getPrivate('/api/v5/account/position-tiers', params);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* SubAccount endpoints (private)
|
|
408
|
+
*
|
|
409
|
+
*/
|
|
410
|
+
/** View sub-account list */
|
|
411
|
+
getSubAccountList(params) {
|
|
412
|
+
return this.getPrivate('/api/v5/users/subaccount/list', params);
|
|
413
|
+
}
|
|
414
|
+
/** Reset the APIKey of a sub-account */
|
|
415
|
+
resetSubAccountAPIKey(subAcct, apiKey, options) {
|
|
416
|
+
return this.postPrivate('/api/v5/users/subaccount/modify-apikey', Object.assign({ subAcct,
|
|
417
|
+
apiKey }, options));
|
|
418
|
+
}
|
|
419
|
+
/** Get sub-account trading balance */
|
|
420
|
+
getSubAccountBalances(subAcct) {
|
|
421
|
+
return this.getPrivate('/api/v5/account/subaccount/balances', { subAcct });
|
|
422
|
+
}
|
|
423
|
+
/** Get sub-account funding balance */
|
|
424
|
+
getSubAccountFundingBalances(subAcct, ccy) {
|
|
425
|
+
return this.getPrivate('/api/v5/asset/subaccount/balances', {
|
|
426
|
+
subAcct,
|
|
427
|
+
ccy,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
/** History of sub-account transfer */
|
|
431
|
+
getSubAccountTransferHistory(params) {
|
|
432
|
+
return this.getPrivate('/api/v5/asset/subaccount/bills', params);
|
|
433
|
+
}
|
|
434
|
+
/** Master accounts manage the transfers between sub-accounts */
|
|
435
|
+
transferSubAccountBalance(params) {
|
|
436
|
+
return this.postPrivate('/api/v5/asset/subaccount/transfer', params);
|
|
437
|
+
}
|
|
438
|
+
/** Set Permission Of Transfer Out */
|
|
439
|
+
setSubAccountTransferOutPermission(subAcct, canTransOut = true) {
|
|
440
|
+
return this.postPrivate('/api/v5/users/subaccount/set-transfer-out', {
|
|
441
|
+
subAcct,
|
|
442
|
+
canTransOut,
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
/** Get custody trading sub-account list */
|
|
446
|
+
getSubAccountCustodyTradingList(subAcct) {
|
|
447
|
+
return this.getPrivate('/api/v5/users/entrust-subaccount-list', {
|
|
448
|
+
subAcct,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
*
|
|
453
|
+
* Grid trading endpoints (private)
|
|
454
|
+
*
|
|
455
|
+
*/
|
|
456
|
+
placeGridAlgoOrder(params) {
|
|
457
|
+
return this.postPrivate('/api/v5/tradingBot/grid/order-algo', params);
|
|
458
|
+
}
|
|
459
|
+
amendGridAlgoOrder(algoId, instId, triggerPx) {
|
|
460
|
+
return this.postPrivate('/api/v5/tradingBot/grid/amend-order-algo', Object.assign({ algoId,
|
|
461
|
+
instId }, triggerPx));
|
|
462
|
+
}
|
|
463
|
+
stopGridAlgoOrder(orders) {
|
|
464
|
+
return this.postPrivate('/api/v5/tradingBot/grid/stop-order-algo', orders);
|
|
465
|
+
}
|
|
466
|
+
getGridAlgoOrderList(params) {
|
|
467
|
+
return this.getPrivate('/api/v5/tradingBot/grid/orders-algo-pending', params);
|
|
468
|
+
}
|
|
469
|
+
getGridAlgoOrderHistory(params) {
|
|
470
|
+
return this.getPrivate('/api/v5/tradingBot/grid/orders-algo-history', params);
|
|
471
|
+
}
|
|
472
|
+
getGridAlgoOrderDetails(algoOrdType, algoId) {
|
|
473
|
+
return this.getPrivate('/api/v5/tradingBot/grid/orders-algo-details', {
|
|
474
|
+
algoOrdType,
|
|
475
|
+
algoId,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
getGridAlgoSubOrders(algoOrdType, algoId, type, groupId, pagination) {
|
|
479
|
+
return this.getPrivate('/api/v5/tradingBot/grid/sub-orders', Object.assign({ algoOrdType,
|
|
480
|
+
algoId,
|
|
481
|
+
type,
|
|
482
|
+
groupId }, pagination));
|
|
483
|
+
}
|
|
484
|
+
/** Only contract grid supports this method */
|
|
485
|
+
getGridAlgoOrderPositions(algoOrdType, algoId) {
|
|
486
|
+
return this.getPrivate('/api/v5/tradingBot/grid/positions', {
|
|
487
|
+
algoOrdType,
|
|
488
|
+
algoId,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
spotGridWithdrawIncome(algoId) {
|
|
492
|
+
return this.postPrivate('/api/v5/tradingBot/grid/withdraw-income', {
|
|
493
|
+
algoId,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
computeGridMarginBalance(algoId, type, amt) {
|
|
497
|
+
return this.postPrivate('/api/v5/tradingBot/grid/compute-margin-balance', {
|
|
498
|
+
algoId,
|
|
499
|
+
type,
|
|
500
|
+
amt,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
adjustGridMarginBalance(algoId, type, change) {
|
|
504
|
+
return this.postPrivate('/api/v5/tradingBot/grid/margin-balance', Object.assign({ algoId,
|
|
505
|
+
type }, change));
|
|
506
|
+
}
|
|
507
|
+
getGridAIParameter(algoOrdType, instId, direction, duration) {
|
|
508
|
+
return this.get('/api/v5/tradingBot/grid/ai-param', {
|
|
509
|
+
algoOrdType,
|
|
510
|
+
instId,
|
|
511
|
+
direction,
|
|
512
|
+
duration,
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
/**
|
|
516
|
+
*
|
|
517
|
+
* Earn/staking endpoints (private)
|
|
518
|
+
*
|
|
519
|
+
*/
|
|
520
|
+
/** Get earn offers */
|
|
521
|
+
getStakingOffers(params) {
|
|
522
|
+
return this.getPrivate('/api/v5/finance/staking-defi/offers', params);
|
|
523
|
+
}
|
|
524
|
+
/** Earn/staking purchase */
|
|
525
|
+
submitStake(productId, investData, term) {
|
|
526
|
+
return this.postPrivate('/api/v5/finance/staking-defi/purchase', {
|
|
527
|
+
productId,
|
|
528
|
+
investData,
|
|
529
|
+
term,
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/** Earn/staking redeem */
|
|
533
|
+
redeemStake(ordId, protocolType, allowEarlyRedeem) {
|
|
534
|
+
return this.postPrivate('/api/v5/finance/staking-defi/redeem', {
|
|
535
|
+
ordId,
|
|
536
|
+
protocolType,
|
|
537
|
+
allowEarlyRedeem,
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
/** Earn/staking cancel purchases/redemptions */
|
|
541
|
+
cancelStakingRequest(ordId, protocolType) {
|
|
542
|
+
return this.postPrivate('/api/v5/finance/staking-defi/cancel', {
|
|
543
|
+
ordId,
|
|
544
|
+
protocolType,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
/** Earn/staking get active orders */
|
|
548
|
+
getActiveStakingOrders(params) {
|
|
549
|
+
return this.getPrivate('/api/v5/finance/staking-defi/orders-active', params);
|
|
550
|
+
}
|
|
551
|
+
/** Earn/staking get order history */
|
|
552
|
+
getStakingOrderHistory(params) {
|
|
553
|
+
return this.getPrivate('/api/v5/finance/staking-defi/orders-history', params);
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
*
|
|
557
|
+
* Market data endpoints (public)
|
|
558
|
+
*
|
|
559
|
+
*/
|
|
560
|
+
getTickers(instrumentType, uly) {
|
|
561
|
+
return this.get('/api/v5/market/tickers', {
|
|
562
|
+
instType: instrumentType,
|
|
563
|
+
uly,
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
getTicker(instId) {
|
|
567
|
+
return this.get('/api/v5/market/ticker', {
|
|
568
|
+
instId,
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
getIndexTickers(params) {
|
|
572
|
+
return this.get('/api/v5/market/index-tickers', Object.assign({}, params));
|
|
573
|
+
}
|
|
574
|
+
getOrderBook(instId, sz) {
|
|
575
|
+
return this.get('/api/v5/market/books', { instId, sz });
|
|
576
|
+
}
|
|
577
|
+
getCandles(instId, bar = '1m', pagination) {
|
|
578
|
+
return this.get('/api/v5/market/candles', Object.assign({ instId,
|
|
579
|
+
bar }, pagination));
|
|
580
|
+
}
|
|
581
|
+
getHistoricCandles(instId, bar = '1m', pagination) {
|
|
582
|
+
return this.get('/api/v5/market/history-candles', Object.assign({ instId,
|
|
583
|
+
bar }, pagination));
|
|
584
|
+
}
|
|
585
|
+
getIndexCandles(instId, bar = '1m', pagination) {
|
|
586
|
+
return this.get('/api/v5/market/index-candles', Object.assign({ instId,
|
|
587
|
+
bar }, pagination));
|
|
588
|
+
}
|
|
589
|
+
getHistoricIndexCandles(instId, bar = '1m', pagination) {
|
|
590
|
+
return this.get('/api/v5/market/history-index-candles', Object.assign({ instId,
|
|
591
|
+
bar }, pagination));
|
|
592
|
+
}
|
|
593
|
+
getMarkPriceCandles(instId, bar = '1m', pagination) {
|
|
594
|
+
return this.get('/api/v5/market/mark-price-candles', Object.assign({ instId,
|
|
595
|
+
bar }, pagination));
|
|
596
|
+
}
|
|
597
|
+
getHistoricMarkPriceCandles(instId, bar = '1m', pagination) {
|
|
598
|
+
return this.get('/api/v5/market/historic-mark-price-candles', Object.assign({ instId,
|
|
599
|
+
bar }, pagination));
|
|
600
|
+
}
|
|
601
|
+
getTrades(instId, limit) {
|
|
602
|
+
return this.get('/api/v5/market/trades', { instId, limit });
|
|
603
|
+
}
|
|
604
|
+
getHistoricTrades(instId, pagination) {
|
|
605
|
+
return this.get('/api/v5/market/history-trades', Object.assign({ instId }, pagination));
|
|
606
|
+
}
|
|
607
|
+
get24hrTotalVolume() {
|
|
608
|
+
return this.get('/api/v5/market/platform-24-volume');
|
|
609
|
+
}
|
|
610
|
+
getOracle() {
|
|
611
|
+
return this.get('/api/v5/market/open-oracle');
|
|
612
|
+
}
|
|
613
|
+
getExchangeRate() {
|
|
614
|
+
return this.get('/api/v5/market/exchange-rate');
|
|
615
|
+
}
|
|
616
|
+
getIndexComponents(index) {
|
|
617
|
+
return this.get('/api/v5/market/index-components', { index });
|
|
618
|
+
}
|
|
619
|
+
getBlockTickers(instType, uly) {
|
|
620
|
+
return this.get('/api/v5/market/block-tickers', { instType, uly });
|
|
621
|
+
}
|
|
622
|
+
getBlockTicker(instId) {
|
|
623
|
+
return this.get('/api/v5/market/block-ticker', { instId });
|
|
624
|
+
}
|
|
625
|
+
getPublicBlockTrades(instId) {
|
|
626
|
+
return this.get('/api/v5/market/block-trades', { instId });
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
*
|
|
630
|
+
* Public data endpoints (public)
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
633
|
+
getInstruments(params) {
|
|
634
|
+
return this.get('/api/v5/public/instruments', params);
|
|
635
|
+
}
|
|
636
|
+
getDeliveryExerciseHistory(params) {
|
|
637
|
+
return this.get('/api/v5/public/delivery-exercise-history', params);
|
|
638
|
+
}
|
|
639
|
+
getOpenInterest(params) {
|
|
640
|
+
return this.get('/api/v5/public/open-interest', params);
|
|
641
|
+
}
|
|
642
|
+
getFundingRate(params) {
|
|
643
|
+
return this.get('/api/v5/public/funding-rate', params);
|
|
644
|
+
}
|
|
645
|
+
getFundingRateHistory(params) {
|
|
646
|
+
return this.get('/api/v5/public/funding-rate-history', params);
|
|
647
|
+
}
|
|
648
|
+
getMinMaxLimitPrice(params) {
|
|
649
|
+
return this.get('/api/v5/public/price-limit', params);
|
|
650
|
+
}
|
|
651
|
+
getOptionMarketData(params) {
|
|
652
|
+
return this.get('/api/v5/public/opt-summary', params);
|
|
653
|
+
}
|
|
654
|
+
getEstimatedDeliveryExercisePrice(params) {
|
|
655
|
+
return this.get('/api/v5/public/estimated-price', params);
|
|
656
|
+
}
|
|
657
|
+
getDiscountRateAndInterestFreeQuota(params) {
|
|
658
|
+
return this.get('/api/v5/public/discount-rate-interest-free-quota', params);
|
|
659
|
+
}
|
|
660
|
+
getSystemTime(params) {
|
|
661
|
+
return this.get('/api/v5/public/time', params);
|
|
662
|
+
}
|
|
663
|
+
getLiquidationOrders(params) {
|
|
664
|
+
return this.get('/api/v5/public/liquidation-orders', params);
|
|
665
|
+
}
|
|
666
|
+
getMarkPrice(params) {
|
|
667
|
+
return this.get('/api/v5/public/mark-price', params);
|
|
668
|
+
}
|
|
669
|
+
getPositionTiers(params) {
|
|
670
|
+
return this.get('/api/v5/public/position-tiers', params);
|
|
671
|
+
}
|
|
672
|
+
getInterestRateAndLoanQuota(params) {
|
|
673
|
+
return this.get('/api/v5/public/interest-rate-loan-quota', params);
|
|
674
|
+
}
|
|
675
|
+
getVIPInterestRateAndLoanQuota(params) {
|
|
676
|
+
return this.get('/api/v5/public/vip-interest-rate-loan-quota', params);
|
|
677
|
+
}
|
|
678
|
+
getUnderlying(params) {
|
|
679
|
+
return this.get('/api/v5/public/underlying', params);
|
|
680
|
+
}
|
|
681
|
+
getInsuranceFund(params) {
|
|
682
|
+
return this.get('/api/v5/public/insurance-fund', params);
|
|
683
|
+
}
|
|
684
|
+
getUnitConvert(params) {
|
|
685
|
+
return this.get('/api/v5/public/convert-contract-coin', params);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
*
|
|
689
|
+
* Trading data endpoints (public)
|
|
690
|
+
*
|
|
691
|
+
*/
|
|
692
|
+
getSupportCoin() {
|
|
693
|
+
return this.get('/api/v5/rubik/stat/trading-data/support-coin');
|
|
694
|
+
}
|
|
695
|
+
getTakerVolume() {
|
|
696
|
+
return this.get('/api/v5/rubik/stat/taker-volume');
|
|
697
|
+
}
|
|
698
|
+
getMarginLendingRatio(params) {
|
|
699
|
+
return this.get('/api/v5/rubik/stat/margin/loan-ratio', params);
|
|
700
|
+
}
|
|
701
|
+
getLongShortRatio(params) {
|
|
702
|
+
return this.get('/api/v5/rubik/stat/contracts/long-short-account-ratio', params);
|
|
703
|
+
}
|
|
704
|
+
getContractsOpenInterestAndVolume(params) {
|
|
705
|
+
return this.get('/api/v5/rubik/stat/contracts/open-interest-volume', params);
|
|
706
|
+
}
|
|
707
|
+
getOptionsOpenInterestAndVolume(params) {
|
|
708
|
+
return this.get('/api/v5/rubik/stat/option/open-interest-volume', params);
|
|
709
|
+
}
|
|
710
|
+
getPutCallRatio(params) {
|
|
711
|
+
return this.get('/api/v5/rubik/stat/option/open-interest-volume-ratio', params);
|
|
712
|
+
}
|
|
713
|
+
getOpenInterestAndVolumeExpiry(params) {
|
|
714
|
+
return this.get('/api/v5/rubik/stat/option/open-interest-volume-expiry', params);
|
|
715
|
+
}
|
|
716
|
+
getOpenInterestAndVolumeStrike(params) {
|
|
717
|
+
return this.get('/api/v5/rubik/stat/option/open-interest-volume-strike', params);
|
|
718
|
+
}
|
|
719
|
+
getTakerFlow(params) {
|
|
720
|
+
return this.get('/api/v5/rubik/stat/option/taker-block-volume', params);
|
|
721
|
+
}
|
|
722
|
+
/**
|
|
723
|
+
*
|
|
724
|
+
* Status endpoints (public)
|
|
725
|
+
*
|
|
726
|
+
*/
|
|
727
|
+
getSystemStatus(state) {
|
|
728
|
+
return this.get('/api/v5/system/status', { state });
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
*
|
|
732
|
+
* Broker endpoints (private)
|
|
733
|
+
*
|
|
734
|
+
*/
|
|
735
|
+
// TODO: add missing broker endpoints
|
|
736
|
+
getBrokerAccountInformation() {
|
|
737
|
+
return this.getPrivate('/api/v5/broker/nd/info');
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
exports.RestClient = RestClient;
|
|
741
|
+
//# sourceMappingURL=rest-client.js.map
|