ccxt 4.1.26 → 4.1.27
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 +3 -3
- package/dist/ccxt.browser.js +180 -25
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/bitopro.js +22 -1
- package/dist/cjs/src/kucoin.js +146 -22
- package/dist/cjs/src/kucoinfutures.js +11 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/kucoin.d.ts +2 -0
- package/js/src/abstract/kucoinfutures.d.ts +3 -0
- package/js/src/bitopro.js +22 -1
- package/js/src/kucoin.d.ts +3 -1
- package/js/src/kucoin.js +146 -22
- package/js/src/kucoinfutures.js +11 -1
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
180
180
|
|
|
181
181
|
//-----------------------------------------------------------------------------
|
|
182
182
|
// this is updated by vss.js when building
|
|
183
|
-
const version = '4.1.
|
|
183
|
+
const version = '4.1.27';
|
|
184
184
|
Exchange["default"].ccxtVersion = version;
|
|
185
185
|
const exchanges = {
|
|
186
186
|
'ace': ace,
|
package/dist/cjs/src/bitopro.js
CHANGED
|
@@ -211,6 +211,7 @@ class bitopro extends bitopro$1 {
|
|
|
211
211
|
* @method
|
|
212
212
|
* @name bitopro#fetchCurrencies
|
|
213
213
|
* @description fetches all available currencies on an exchange
|
|
214
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
|
|
214
215
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
215
216
|
* @returns {object} an associative dictionary of currencies
|
|
216
217
|
*/
|
|
@@ -273,6 +274,7 @@ class bitopro extends bitopro$1 {
|
|
|
273
274
|
* @method
|
|
274
275
|
* @name bitopro#fetchMarkets
|
|
275
276
|
* @description retrieves data on all markets for bitopro
|
|
277
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trading_pair_info.md
|
|
276
278
|
* @param {object} [params] extra parameters specific to the exchange api endpoint
|
|
277
279
|
* @returns {object[]} an array of objects representing market data
|
|
278
280
|
*/
|
|
@@ -407,6 +409,7 @@ class bitopro extends bitopro$1 {
|
|
|
407
409
|
* @method
|
|
408
410
|
* @name bitopro#fetchTicker
|
|
409
411
|
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
412
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
|
|
410
413
|
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
411
414
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
412
415
|
* @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
|
|
@@ -438,6 +441,7 @@ class bitopro extends bitopro$1 {
|
|
|
438
441
|
* @method
|
|
439
442
|
* @name bitopro#fetchTickers
|
|
440
443
|
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
|
|
444
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
|
|
441
445
|
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
442
446
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
443
447
|
* @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
|
|
@@ -467,6 +471,7 @@ class bitopro extends bitopro$1 {
|
|
|
467
471
|
* @method
|
|
468
472
|
* @name bitopro#fetchOrderBook
|
|
469
473
|
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
474
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_orderbook_data.md
|
|
470
475
|
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
471
476
|
* @param {int} [limit] the maximum amount of order book entries to return
|
|
472
477
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
@@ -597,6 +602,7 @@ class bitopro extends bitopro$1 {
|
|
|
597
602
|
* @method
|
|
598
603
|
* @name bitopro#fetchTrades
|
|
599
604
|
* @description get the list of most recent trades for a particular symbol
|
|
605
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trades_data.md
|
|
600
606
|
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
601
607
|
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
602
608
|
* @param {int} [limit] the maximum amount of trades to fetch
|
|
@@ -629,6 +635,7 @@ class bitopro extends bitopro$1 {
|
|
|
629
635
|
* @method
|
|
630
636
|
* @name bitopro#fetchTradingFees
|
|
631
637
|
* @description fetch the trading fees for multiple markets
|
|
638
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_limitations_and_fees.md
|
|
632
639
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
633
640
|
* @returns {object} a dictionary of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure} indexed by market symbols
|
|
634
641
|
*/
|
|
@@ -728,6 +735,7 @@ class bitopro extends bitopro$1 {
|
|
|
728
735
|
* @method
|
|
729
736
|
* @name bitopro#fetchOHLCV
|
|
730
737
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
738
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ohlc_data.md
|
|
731
739
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
732
740
|
* @param {string} timeframe the length of time each candle represents
|
|
733
741
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
@@ -850,6 +858,7 @@ class bitopro extends bitopro$1 {
|
|
|
850
858
|
* @method
|
|
851
859
|
* @name bitopro#fetchBalance
|
|
852
860
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
861
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_account_balance.md
|
|
853
862
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
854
863
|
* @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
|
|
855
864
|
*/
|
|
@@ -977,6 +986,7 @@ class bitopro extends bitopro$1 {
|
|
|
977
986
|
* @method
|
|
978
987
|
* @name bitopro#createOrder
|
|
979
988
|
* @description create a trade order
|
|
989
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_order.md
|
|
980
990
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
981
991
|
* @param {string} type 'market' or 'limit'
|
|
982
992
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -1038,6 +1048,7 @@ class bitopro extends bitopro$1 {
|
|
|
1038
1048
|
* @method
|
|
1039
1049
|
* @name bitopro#cancelOrder
|
|
1040
1050
|
* @description cancels an open order
|
|
1051
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_an_order.md
|
|
1041
1052
|
* @param {string} id order id
|
|
1042
1053
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1043
1054
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
@@ -1069,6 +1080,7 @@ class bitopro extends bitopro$1 {
|
|
|
1069
1080
|
* @method
|
|
1070
1081
|
* @name bitopro#cancelOrders
|
|
1071
1082
|
* @description cancel multiple orders
|
|
1083
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_batch_orders.md
|
|
1072
1084
|
* @param {string[]} ids order ids
|
|
1073
1085
|
* @param {string} symbol unified market symbol
|
|
1074
1086
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
@@ -1100,6 +1112,7 @@ class bitopro extends bitopro$1 {
|
|
|
1100
1112
|
* @method
|
|
1101
1113
|
* @name bitopro#cancelAllOrders
|
|
1102
1114
|
* @description cancel all open orders
|
|
1115
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_all_orders.md
|
|
1103
1116
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
1104
1117
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
1105
1118
|
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
@@ -1134,6 +1147,7 @@ class bitopro extends bitopro$1 {
|
|
|
1134
1147
|
* @method
|
|
1135
1148
|
* @name bitopro#fetchOrder
|
|
1136
1149
|
* @description fetches information on an order made by the user
|
|
1150
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_order_data.md
|
|
1137
1151
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1138
1152
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
1139
1153
|
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
@@ -1178,6 +1192,7 @@ class bitopro extends bitopro$1 {
|
|
|
1178
1192
|
* @method
|
|
1179
1193
|
* @name bitopro#fetchOrders
|
|
1180
1194
|
* @description fetches information on multiple orders made by the user
|
|
1195
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
|
|
1181
1196
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1182
1197
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1183
1198
|
* @param {int} [limit] the maximum number of orde structures to retrieve
|
|
@@ -1246,6 +1261,7 @@ class bitopro extends bitopro$1 {
|
|
|
1246
1261
|
* @method
|
|
1247
1262
|
* @name bitopro#fetchClosedOrders
|
|
1248
1263
|
* @description fetches information on multiple closed orders made by the user
|
|
1264
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
|
|
1249
1265
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1250
1266
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1251
1267
|
* @param {int} [limit] the maximum number of orde structures to retrieve
|
|
@@ -1262,6 +1278,7 @@ class bitopro extends bitopro$1 {
|
|
|
1262
1278
|
* @method
|
|
1263
1279
|
* @name bitopro#fetchMyTrades
|
|
1264
1280
|
* @description fetch all trades made by the user
|
|
1281
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_trades_data.md
|
|
1265
1282
|
* @param {string} symbol unified market symbol
|
|
1266
1283
|
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1267
1284
|
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
@@ -1399,6 +1416,7 @@ class bitopro extends bitopro$1 {
|
|
|
1399
1416
|
* @method
|
|
1400
1417
|
* @name bitopro#fetchDeposits
|
|
1401
1418
|
* @description fetch all deposits made to an account
|
|
1419
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_deposit_invoices_data.md
|
|
1402
1420
|
* @param {string} code unified currency code
|
|
1403
1421
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
1404
1422
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
@@ -1450,6 +1468,7 @@ class bitopro extends bitopro$1 {
|
|
|
1450
1468
|
* @method
|
|
1451
1469
|
* @name bitopro#fetchWithdrawals
|
|
1452
1470
|
* @description fetch all withdrawals made from an account
|
|
1471
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_withdraw_invoices_data.md
|
|
1453
1472
|
* @param {string} code unified currency code
|
|
1454
1473
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
1455
1474
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
@@ -1500,6 +1519,7 @@ class bitopro extends bitopro$1 {
|
|
|
1500
1519
|
* @method
|
|
1501
1520
|
* @name bitopro#fetchWithdrawal
|
|
1502
1521
|
* @description fetch data on a currency withdrawal via the withdrawal id
|
|
1522
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_withdraw_invoice_data.md
|
|
1503
1523
|
* @param {string} id withdrawal id
|
|
1504
1524
|
* @param {string} code unified currency code of the currency withdrawn, default is undefined
|
|
1505
1525
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
@@ -1539,6 +1559,7 @@ class bitopro extends bitopro$1 {
|
|
|
1539
1559
|
* @method
|
|
1540
1560
|
* @name bitopro#withdraw
|
|
1541
1561
|
* @description make a withdrawal
|
|
1562
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_withdraw_invoice.md
|
|
1542
1563
|
* @param {string} code unified currency code
|
|
1543
1564
|
* @param {float} amount the amount to withdraw
|
|
1544
1565
|
* @param {string} address the address to withdraw to
|
|
@@ -1614,7 +1635,7 @@ class bitopro extends bitopro$1 {
|
|
|
1614
1635
|
* @method
|
|
1615
1636
|
* @name bitopro#fetchDepositWithdrawFees
|
|
1616
1637
|
* @description fetch deposit and withdraw fees
|
|
1617
|
-
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/v3
|
|
1638
|
+
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
|
|
1618
1639
|
* @param {string[]|undefined} codes list of unified currency codes
|
|
1619
1640
|
* @param {object} [params] extra parameters specific to the bitopro api endpoint
|
|
1620
1641
|
* @returns {object} a list of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
|
package/dist/cjs/src/kucoin.js
CHANGED
|
@@ -40,6 +40,7 @@ class kucoin extends kucoin$1 {
|
|
|
40
40
|
'cancelOrder': true,
|
|
41
41
|
'createDepositAddress': true,
|
|
42
42
|
'createOrder': true,
|
|
43
|
+
'createOrders': true,
|
|
43
44
|
'createPostOnlyOrder': true,
|
|
44
45
|
'createStopLimitOrder': true,
|
|
45
46
|
'createStopMarketOrder': true,
|
|
@@ -222,12 +223,14 @@ class kucoin extends kucoin$1 {
|
|
|
222
223
|
'deposit-addresses': 1,
|
|
223
224
|
'withdrawals': 1,
|
|
224
225
|
'orders': 4,
|
|
226
|
+
'orders/test': 4,
|
|
225
227
|
'orders/multi': 20,
|
|
226
228
|
'isolated/borrow': 2,
|
|
227
229
|
'isolated/repay/all': 2,
|
|
228
230
|
'isolated/repay/single': 2,
|
|
229
231
|
'margin/borrow': 1,
|
|
230
232
|
'margin/order': 1,
|
|
233
|
+
'margin/order/test': 1,
|
|
231
234
|
'margin/repay/all': 1,
|
|
232
235
|
'margin/repay/single': 1,
|
|
233
236
|
'margin/lend': 1,
|
|
@@ -1827,6 +1830,8 @@ class kucoin extends kucoin$1 {
|
|
|
1827
1830
|
* @see https://docs.kucoin.com/spot#place-a-new-order-2
|
|
1828
1831
|
* @see https://docs.kucoin.com/spot#place-a-margin-order
|
|
1829
1832
|
* @see https://docs.kucoin.com/spot-hf/#place-hf-order
|
|
1833
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order-test
|
|
1834
|
+
* @see https://www.kucoin.com/docs/rest/margin-trading/orders/place-margin-order-test
|
|
1830
1835
|
* @param {string} symbol Unified CCXT market symbol
|
|
1831
1836
|
* @param {string} type 'limit' or 'market'
|
|
1832
1837
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -1856,9 +1861,140 @@ class kucoin extends kucoin$1 {
|
|
|
1856
1861
|
* @param {string} [params.stp] '', // self trade prevention, CN, CO, CB or DC
|
|
1857
1862
|
* @param {bool} [params.autoBorrow] false, // The system will first borrow you funds at the optimal interest rate and then place an order for you
|
|
1858
1863
|
* @param {bool} [params.hf] false, // true for hf order
|
|
1864
|
+
* @param {bool} [params.test] set to true to test an order, no order will be created but the request will be validated
|
|
1859
1865
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1860
1866
|
*/
|
|
1861
1867
|
await this.loadMarkets();
|
|
1868
|
+
const market = this.market(symbol);
|
|
1869
|
+
const testOrder = this.safeValue(params, 'test', false);
|
|
1870
|
+
params = this.omit(params, 'test');
|
|
1871
|
+
const isHf = this.safeValue(params, 'hf', false);
|
|
1872
|
+
const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
|
|
1873
|
+
const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
|
|
1874
|
+
const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
|
|
1875
|
+
const marginResult = this.handleMarginModeAndParams('createOrder', params);
|
|
1876
|
+
const marginMode = this.safeString(marginResult, 0);
|
|
1877
|
+
const isMarginOrder = tradeType === 'MARGIN_TRADE' || marginMode !== undefined;
|
|
1878
|
+
// don't omit anything before calling createOrderRequest
|
|
1879
|
+
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1880
|
+
let response = undefined;
|
|
1881
|
+
if (testOrder) {
|
|
1882
|
+
if (isMarginOrder) {
|
|
1883
|
+
response = await this.privatePostMarginOrderTest(orderRequest);
|
|
1884
|
+
}
|
|
1885
|
+
else {
|
|
1886
|
+
response = await this.privatePostOrdersTest(orderRequest);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
else if (isHf) {
|
|
1890
|
+
response = await this.privatePostHfOrders(orderRequest);
|
|
1891
|
+
}
|
|
1892
|
+
else if (isTriggerOrder) {
|
|
1893
|
+
response = await this.privatePostStopOrder(orderRequest);
|
|
1894
|
+
}
|
|
1895
|
+
else if (isMarginOrder) {
|
|
1896
|
+
response = await this.privatePostMarginOrder(orderRequest);
|
|
1897
|
+
}
|
|
1898
|
+
else {
|
|
1899
|
+
response = await this.privatePostOrders(orderRequest);
|
|
1900
|
+
}
|
|
1901
|
+
//
|
|
1902
|
+
// {
|
|
1903
|
+
// code: '200000',
|
|
1904
|
+
// data: {
|
|
1905
|
+
// "orderId": "5bd6e9286d99522a52e458de"
|
|
1906
|
+
// }
|
|
1907
|
+
// }
|
|
1908
|
+
//
|
|
1909
|
+
const data = this.safeValue(response, 'data', {});
|
|
1910
|
+
return this.parseOrder(data, market);
|
|
1911
|
+
}
|
|
1912
|
+
async createOrders(orders, params = {}) {
|
|
1913
|
+
/**
|
|
1914
|
+
* @method
|
|
1915
|
+
* @name kucoin#createOrders
|
|
1916
|
+
* @description create a list of trade orders
|
|
1917
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-multiple-orders
|
|
1918
|
+
* @see https://www.kucoin.com/docs/rest/spot-trading/spot-hf-trade-pro-account/place-multiple-hf-orders
|
|
1919
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
1920
|
+
* @param {object} [params] Extra parameters specific to the exchange API endpoint
|
|
1921
|
+
* @param {bool} [params.hf] false, // true for hf orders
|
|
1922
|
+
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1923
|
+
*/
|
|
1924
|
+
await this.loadMarkets();
|
|
1925
|
+
const ordersRequests = [];
|
|
1926
|
+
let symbol = undefined;
|
|
1927
|
+
for (let i = 0; i < orders.length; i++) {
|
|
1928
|
+
const rawOrder = orders[i];
|
|
1929
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
1930
|
+
if (symbol === undefined) {
|
|
1931
|
+
symbol = marketId;
|
|
1932
|
+
}
|
|
1933
|
+
else {
|
|
1934
|
+
if (symbol !== marketId) {
|
|
1935
|
+
throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
const type = this.safeString(rawOrder, 'type');
|
|
1939
|
+
if (type !== 'limit') {
|
|
1940
|
+
throw new errors.BadRequest(this.id + ' createOrders() only supports limit orders');
|
|
1941
|
+
}
|
|
1942
|
+
const side = this.safeString(rawOrder, 'side');
|
|
1943
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
1944
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
1945
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
1946
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
1947
|
+
ordersRequests.push(orderRequest);
|
|
1948
|
+
}
|
|
1949
|
+
const market = this.market(symbol);
|
|
1950
|
+
const request = {
|
|
1951
|
+
'symbol': market['id'],
|
|
1952
|
+
'orderList': ordersRequests,
|
|
1953
|
+
};
|
|
1954
|
+
const hf = this.safeValue(params, 'hf', false);
|
|
1955
|
+
params = this.omit(params, 'hf');
|
|
1956
|
+
let response = undefined;
|
|
1957
|
+
if (hf) {
|
|
1958
|
+
response = await this.privatePostHfOrdersMulti(this.extend(request, params));
|
|
1959
|
+
}
|
|
1960
|
+
else {
|
|
1961
|
+
response = await this.privatePostOrdersMulti(this.extend(request, params));
|
|
1962
|
+
}
|
|
1963
|
+
//
|
|
1964
|
+
// {
|
|
1965
|
+
// "code": "200000",
|
|
1966
|
+
// "data": {
|
|
1967
|
+
// "data": [
|
|
1968
|
+
// {
|
|
1969
|
+
// "symbol": "LTC-USDT",
|
|
1970
|
+
// "type": "limit",
|
|
1971
|
+
// "side": "sell",
|
|
1972
|
+
// "price": "90",
|
|
1973
|
+
// "size": "0.1",
|
|
1974
|
+
// "funds": null,
|
|
1975
|
+
// "stp": "",
|
|
1976
|
+
// "stop": "",
|
|
1977
|
+
// "stopPrice": null,
|
|
1978
|
+
// "timeInForce": "GTC",
|
|
1979
|
+
// "cancelAfter": 0,
|
|
1980
|
+
// "postOnly": false,
|
|
1981
|
+
// "hidden": false,
|
|
1982
|
+
// "iceberge": false,
|
|
1983
|
+
// "iceberg": false,
|
|
1984
|
+
// "visibleSize": null,
|
|
1985
|
+
// "channel": "API",
|
|
1986
|
+
// "id": "6539148443fcf500079d15e5",
|
|
1987
|
+
// "status": "success",
|
|
1988
|
+
// "failMsg": null,
|
|
1989
|
+
// "clientOid": "5c4c5398-8ab2-4b4e-af8a-e2d90ad2488f"
|
|
1990
|
+
// },
|
|
1991
|
+
// }
|
|
1992
|
+
//
|
|
1993
|
+
let data = this.safeValue(response, 'data', {});
|
|
1994
|
+
data = this.safeValue(data, 'data', []);
|
|
1995
|
+
return this.parseOrders(data);
|
|
1996
|
+
}
|
|
1997
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
1862
1998
|
const market = this.market(symbol);
|
|
1863
1999
|
// required param, cannot be used twice
|
|
1864
2000
|
const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId', this.uuid());
|
|
@@ -1891,15 +2027,12 @@ class kucoin extends kucoin$1 {
|
|
|
1891
2027
|
request['size'] = amountString;
|
|
1892
2028
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
1893
2029
|
}
|
|
2030
|
+
const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
|
|
1894
2031
|
const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
|
|
2032
|
+
const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
|
|
2033
|
+
const isMarginOrder = tradeType === 'MARGIN_TRADE' || marginMode !== undefined;
|
|
1895
2034
|
params = this.omit(params, ['stopLossPrice', 'takeProfitPrice', 'triggerPrice', 'stopPrice']);
|
|
1896
|
-
|
|
1897
|
-
let method = 'privatePostOrders';
|
|
1898
|
-
const isHf = this.safeValue(params, 'hf', false);
|
|
1899
|
-
if (isHf) {
|
|
1900
|
-
method = 'privatePostHfOrders';
|
|
1901
|
-
}
|
|
1902
|
-
else if (triggerPrice || stopLossPrice || takeProfitPrice) {
|
|
2035
|
+
if (isTriggerOrder) {
|
|
1903
2036
|
if (triggerPrice) {
|
|
1904
2037
|
request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1905
2038
|
}
|
|
@@ -1913,7 +2046,6 @@ class kucoin extends kucoin$1 {
|
|
|
1913
2046
|
request['stopPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
1914
2047
|
}
|
|
1915
2048
|
}
|
|
1916
|
-
method = 'privatePostStopOrder';
|
|
1917
2049
|
if (marginMode === 'isolated') {
|
|
1918
2050
|
throw new errors.BadRequest(this.id + ' createOrder does not support isolated margin for stop orders');
|
|
1919
2051
|
}
|
|
@@ -1921,8 +2053,7 @@ class kucoin extends kucoin$1 {
|
|
|
1921
2053
|
request['tradeType'] = this.options['marginModes'][marginMode];
|
|
1922
2054
|
}
|
|
1923
2055
|
}
|
|
1924
|
-
else if (
|
|
1925
|
-
method = 'privatePostMarginOrder';
|
|
2056
|
+
else if (isMarginOrder) {
|
|
1926
2057
|
if (marginMode === 'isolated') {
|
|
1927
2058
|
request['marginModel'] = 'isolated';
|
|
1928
2059
|
}
|
|
@@ -1932,17 +2063,7 @@ class kucoin extends kucoin$1 {
|
|
|
1932
2063
|
if (postOnly) {
|
|
1933
2064
|
request['postOnly'] = true;
|
|
1934
2065
|
}
|
|
1935
|
-
|
|
1936
|
-
//
|
|
1937
|
-
// {
|
|
1938
|
-
// code: '200000',
|
|
1939
|
-
// data: {
|
|
1940
|
-
// "orderId": "5bd6e9286d99522a52e458de"
|
|
1941
|
-
// }
|
|
1942
|
-
// }
|
|
1943
|
-
//
|
|
1944
|
-
const data = this.safeValue(response, 'data', {});
|
|
1945
|
-
return this.parseOrder(data, market);
|
|
2066
|
+
return this.extend(request, params);
|
|
1946
2067
|
}
|
|
1947
2068
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
1948
2069
|
/**
|
|
@@ -2472,6 +2593,7 @@ class kucoin extends kucoin$1 {
|
|
|
2472
2593
|
const stop = responseStop !== undefined;
|
|
2473
2594
|
const stopTriggered = this.safeValue(order, 'stopTriggered', false);
|
|
2474
2595
|
const isActive = this.safeValue2(order, 'isActive', 'active');
|
|
2596
|
+
const responseStatus = this.safeString(order, 'status');
|
|
2475
2597
|
let status = undefined;
|
|
2476
2598
|
if (isActive !== undefined) {
|
|
2477
2599
|
if (isActive === true) {
|
|
@@ -2482,7 +2604,6 @@ class kucoin extends kucoin$1 {
|
|
|
2482
2604
|
}
|
|
2483
2605
|
}
|
|
2484
2606
|
if (stop) {
|
|
2485
|
-
const responseStatus = this.safeString(order, 'status');
|
|
2486
2607
|
if (responseStatus === 'NEW') {
|
|
2487
2608
|
status = 'open';
|
|
2488
2609
|
}
|
|
@@ -2493,6 +2614,9 @@ class kucoin extends kucoin$1 {
|
|
|
2493
2614
|
if (cancelExist) {
|
|
2494
2615
|
status = 'canceled';
|
|
2495
2616
|
}
|
|
2617
|
+
if (responseStatus === 'fail') {
|
|
2618
|
+
status = 'rejected';
|
|
2619
|
+
}
|
|
2496
2620
|
const stopPrice = this.safeNumber(order, 'stopPrice');
|
|
2497
2621
|
return this.safeOrder({
|
|
2498
2622
|
'info': order,
|
|
@@ -160,6 +160,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
160
160
|
'transfer-out': 1,
|
|
161
161
|
'transfer-in': 1,
|
|
162
162
|
'orders': 1.33,
|
|
163
|
+
'orders/test': 1.33,
|
|
163
164
|
'position/margin/auto-deposit-status': 1,
|
|
164
165
|
'position/margin/deposit-margin': 1,
|
|
165
166
|
'position/risk-limit-level/change': 1,
|
|
@@ -1106,6 +1107,7 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1106
1107
|
* @param {string} [params.stop] 'up' or 'down', the direction the stopPrice is triggered from, requires stopPrice. down: Triggers when the price reaches or goes below the stopPrice. up: Triggers when the price reaches or goes above the stopPrice.
|
|
1107
1108
|
* @param {string} [params.stopPriceType] TP, IP or MP, defaults to MP: Mark Price
|
|
1108
1109
|
* @param {bool} [params.closeOrder] set to true to close position
|
|
1110
|
+
* @param {bool} [params.test] set to true to use the test order endpoint (does not submit order, use to validate params)
|
|
1109
1111
|
* @param {bool} [params.forceHold] A mark to forcely hold the funds for an order, even though it's an order to reduce the position size. This helps the order stay on the order book and not get canceled when the position size changes. Set to false by default.
|
|
1110
1112
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
1111
1113
|
*/
|
|
@@ -1182,7 +1184,15 @@ class kucoinfutures extends kucoinfutures$1 {
|
|
|
1182
1184
|
}
|
|
1183
1185
|
}
|
|
1184
1186
|
params = this.omit(params, ['timeInForce', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']); // Time in force only valid for limit orders, exchange error when gtc for market orders
|
|
1185
|
-
|
|
1187
|
+
let response = undefined;
|
|
1188
|
+
const testOrder = this.safeValue(params, 'test', false);
|
|
1189
|
+
params = this.omit(params, 'test');
|
|
1190
|
+
if (testOrder) {
|
|
1191
|
+
response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
response = await this.futuresPrivatePostOrders(this.extend(request, params));
|
|
1195
|
+
}
|
|
1186
1196
|
//
|
|
1187
1197
|
// {
|
|
1188
1198
|
// code: "200000",
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.1.
|
|
7
|
+
declare const version = "4.1.26";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.1.
|
|
41
|
+
const version = '4.1.27';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -82,12 +82,14 @@ interface Exchange {
|
|
|
82
82
|
privatePostDepositAddresses(params?: {}): Promise<implicitReturnType>;
|
|
83
83
|
privatePostWithdrawals(params?: {}): Promise<implicitReturnType>;
|
|
84
84
|
privatePostOrders(params?: {}): Promise<implicitReturnType>;
|
|
85
|
+
privatePostOrdersTest(params?: {}): Promise<implicitReturnType>;
|
|
85
86
|
privatePostOrdersMulti(params?: {}): Promise<implicitReturnType>;
|
|
86
87
|
privatePostIsolatedBorrow(params?: {}): Promise<implicitReturnType>;
|
|
87
88
|
privatePostIsolatedRepayAll(params?: {}): Promise<implicitReturnType>;
|
|
88
89
|
privatePostIsolatedRepaySingle(params?: {}): Promise<implicitReturnType>;
|
|
89
90
|
privatePostMarginBorrow(params?: {}): Promise<implicitReturnType>;
|
|
90
91
|
privatePostMarginOrder(params?: {}): Promise<implicitReturnType>;
|
|
92
|
+
privatePostMarginOrderTest(params?: {}): Promise<implicitReturnType>;
|
|
91
93
|
privatePostMarginRepayAll(params?: {}): Promise<implicitReturnType>;
|
|
92
94
|
privatePostMarginRepaySingle(params?: {}): Promise<implicitReturnType>;
|
|
93
95
|
privatePostMarginLend(params?: {}): Promise<implicitReturnType>;
|
|
@@ -82,12 +82,14 @@ interface kucoin {
|
|
|
82
82
|
privatePostDepositAddresses(params?: {}): Promise<implicitReturnType>;
|
|
83
83
|
privatePostWithdrawals(params?: {}): Promise<implicitReturnType>;
|
|
84
84
|
privatePostOrders(params?: {}): Promise<implicitReturnType>;
|
|
85
|
+
privatePostOrdersTest(params?: {}): Promise<implicitReturnType>;
|
|
85
86
|
privatePostOrdersMulti(params?: {}): Promise<implicitReturnType>;
|
|
86
87
|
privatePostIsolatedBorrow(params?: {}): Promise<implicitReturnType>;
|
|
87
88
|
privatePostIsolatedRepayAll(params?: {}): Promise<implicitReturnType>;
|
|
88
89
|
privatePostIsolatedRepaySingle(params?: {}): Promise<implicitReturnType>;
|
|
89
90
|
privatePostMarginBorrow(params?: {}): Promise<implicitReturnType>;
|
|
90
91
|
privatePostMarginOrder(params?: {}): Promise<implicitReturnType>;
|
|
92
|
+
privatePostMarginOrderTest(params?: {}): Promise<implicitReturnType>;
|
|
91
93
|
privatePostMarginRepayAll(params?: {}): Promise<implicitReturnType>;
|
|
92
94
|
privatePostMarginRepaySingle(params?: {}): Promise<implicitReturnType>;
|
|
93
95
|
privatePostMarginLend(params?: {}): Promise<implicitReturnType>;
|
|
@@ -168,6 +170,7 @@ interface kucoin {
|
|
|
168
170
|
futuresPrivatePostPositionMarginDepositMargin(params?: {}): Promise<implicitReturnType>;
|
|
169
171
|
futuresPrivatePostBulletPrivate(params?: {}): Promise<implicitReturnType>;
|
|
170
172
|
futuresPrivatePostTransferIn(params?: {}): Promise<implicitReturnType>;
|
|
173
|
+
futuresPrivatePostOrdersTest(params?: {}): Promise<implicitReturnType>;
|
|
171
174
|
futuresPrivatePostPositionRiskLimitLevelChange(params?: {}): Promise<implicitReturnType>;
|
|
172
175
|
futuresPrivatePostSubApiKey(params?: {}): Promise<implicitReturnType>;
|
|
173
176
|
futuresPrivatePostSubApiKeyUpdate(params?: {}): Promise<implicitReturnType>;
|