ccxt 4.2.1 → 4.2.3
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 +1375 -1169
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +1 -1
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/bingx.js +185 -44
- package/dist/cjs/src/bitget.js +4 -4
- package/dist/cjs/src/bitmart.js +2 -2
- package/dist/cjs/src/bitstamp.js +37 -13
- package/dist/cjs/src/kucoinfutures.js +6 -6
- package/dist/cjs/src/lykke.js +14 -3
- package/dist/cjs/src/okcoin.js +2 -2
- package/dist/cjs/src/okx.js +11 -9
- package/dist/cjs/src/poloniexfutures.js +22 -11
- package/dist/cjs/src/pro/binance.js +24 -21
- package/dist/cjs/src/pro/bingx.js +2 -1
- package/dist/cjs/src/pro/bybit.js +10 -15
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +3 -0
- package/js/src/alpaca.js +1 -1
- package/js/src/binance.js +1 -0
- package/js/src/bingx.js +185 -44
- package/js/src/bitget.js +4 -4
- package/js/src/bitmart.js +2 -2
- package/js/src/bitstamp.js +37 -13
- package/js/src/kucoinfutures.js +6 -6
- package/js/src/lykke.js +14 -3
- package/js/src/okcoin.js +2 -2
- package/js/src/okx.js +11 -9
- package/js/src/poloniexfutures.js +22 -11
- package/js/src/pro/binance.js +24 -21
- package/js/src/pro/bingx.js +2 -1
- package/js/src/pro/bybit.js +10 -15
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/package.json +1 -1
package/js/src/bingx.js
CHANGED
|
@@ -120,6 +120,7 @@ export default class bingx extends Exchange {
|
|
|
120
120
|
'trade/query': 3,
|
|
121
121
|
'trade/openOrders': 3,
|
|
122
122
|
'trade/historyOrders': 3,
|
|
123
|
+
'user/commissionRate': 3,
|
|
123
124
|
'account/balance': 3,
|
|
124
125
|
},
|
|
125
126
|
'post': {
|
|
@@ -127,6 +128,7 @@ export default class bingx extends Exchange {
|
|
|
127
128
|
'trade/cancel': 3,
|
|
128
129
|
'trade/batchOrders': 3,
|
|
129
130
|
'trade/cancelOrders': 3,
|
|
131
|
+
'trade/cancelOpenOrders': 3,
|
|
130
132
|
},
|
|
131
133
|
},
|
|
132
134
|
},
|
|
@@ -278,6 +280,9 @@ export default class bingx extends Exchange {
|
|
|
278
280
|
'post': {
|
|
279
281
|
'userDataStream': 1,
|
|
280
282
|
},
|
|
283
|
+
'put': {
|
|
284
|
+
'userDataStream': 1,
|
|
285
|
+
},
|
|
281
286
|
},
|
|
282
287
|
},
|
|
283
288
|
},
|
|
@@ -1317,22 +1322,30 @@ export default class bingx extends Exchange {
|
|
|
1317
1322
|
// }
|
|
1318
1323
|
//
|
|
1319
1324
|
const marketId = this.safeString(ticker, 'symbol');
|
|
1320
|
-
// const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
|
|
1321
1325
|
const lastQty = this.safeString(ticker, 'lastQty');
|
|
1322
1326
|
// in spot markets, lastQty is not present
|
|
1323
1327
|
// it's (bad, but) the only way we can check the tickers origin
|
|
1324
1328
|
const type = (lastQty === undefined) ? 'spot' : 'swap';
|
|
1325
|
-
|
|
1329
|
+
market = this.safeMarket(marketId, market, undefined, type);
|
|
1330
|
+
const symbol = market['symbol'];
|
|
1326
1331
|
const open = this.safeString(ticker, 'openPrice');
|
|
1327
1332
|
const high = this.safeString(ticker, 'highPrice');
|
|
1328
1333
|
const low = this.safeString(ticker, 'lowPrice');
|
|
1329
1334
|
const close = this.safeString(ticker, 'lastPrice');
|
|
1330
1335
|
const quoteVolume = this.safeString(ticker, 'quoteVolume');
|
|
1331
1336
|
const baseVolume = this.safeString(ticker, 'volume');
|
|
1337
|
+
let percentage = undefined;
|
|
1338
|
+
let change = undefined;
|
|
1339
|
+
if (market['swap']) {
|
|
1340
|
+
// right now only swap uses the 24h change, spot will be added soon
|
|
1341
|
+
percentage = this.safeString(ticker, 'priceChangePercent');
|
|
1342
|
+
change = this.safeString(ticker, 'priceChange');
|
|
1343
|
+
}
|
|
1332
1344
|
// let percentage = this.safeString (ticker, 'priceChangePercent');
|
|
1333
1345
|
// if (percentage !== undefined) {
|
|
1334
1346
|
// percentage = percentage.replace ('%', '');
|
|
1335
1347
|
// } similarly to change, it's not ccxt's percentage because it does priceChange/open, and priceChange is high-low
|
|
1348
|
+
// const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
|
|
1336
1349
|
const ts = this.safeInteger(ticker, 'closeTime');
|
|
1337
1350
|
const datetime = this.iso8601(ts);
|
|
1338
1351
|
const bid = this.safeString(ticker, 'bidPrice');
|
|
@@ -1354,8 +1367,8 @@ export default class bingx extends Exchange {
|
|
|
1354
1367
|
'close': close,
|
|
1355
1368
|
'last': undefined,
|
|
1356
1369
|
'previousClose': undefined,
|
|
1357
|
-
'change':
|
|
1358
|
-
'percentage':
|
|
1370
|
+
'change': change,
|
|
1371
|
+
'percentage': percentage,
|
|
1359
1372
|
'average': undefined,
|
|
1360
1373
|
'baseVolume': baseVolume,
|
|
1361
1374
|
'quoteVolume': quoteVolume,
|
|
@@ -1711,6 +1724,10 @@ export default class bingx extends Exchange {
|
|
|
1711
1724
|
const isTrailingAmountOrder = trailingAmount !== undefined;
|
|
1712
1725
|
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
1713
1726
|
const isTrailing = isTrailingAmountOrder || isTrailingPercentOrder;
|
|
1727
|
+
const stopLoss = this.safeValue(params, 'stopLoss');
|
|
1728
|
+
const takeProfit = this.safeValue(params, 'takeProfit');
|
|
1729
|
+
const isStopLoss = stopLoss !== undefined;
|
|
1730
|
+
const isTakeProfit = takeProfit !== undefined;
|
|
1714
1731
|
if (((type === 'LIMIT') || (type === 'TRIGGER_LIMIT') || (type === 'STOP') || (type === 'TAKE_PROFIT')) && !isTrailing) {
|
|
1715
1732
|
request['price'] = this.parseToNumeric(this.priceToPrecision(symbol, price));
|
|
1716
1733
|
}
|
|
@@ -1756,6 +1773,42 @@ export default class bingx extends Exchange {
|
|
|
1756
1773
|
request['priceRate'] = this.parseToNumeric(requestTrailingPercent);
|
|
1757
1774
|
}
|
|
1758
1775
|
}
|
|
1776
|
+
if (isStopLoss || isTakeProfit) {
|
|
1777
|
+
if (isStopLoss) {
|
|
1778
|
+
const slTriggerPrice = this.safeString2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
|
|
1779
|
+
const slWorkingType = this.safeString(stopLoss, 'workingType', 'MARK_PRICE');
|
|
1780
|
+
const slType = this.safeString(stopLoss, 'type', 'STOP_MARKET');
|
|
1781
|
+
const slRequest = {
|
|
1782
|
+
'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, slTriggerPrice)),
|
|
1783
|
+
'workingType': slWorkingType,
|
|
1784
|
+
'type': slType,
|
|
1785
|
+
};
|
|
1786
|
+
const slPrice = this.safeString(stopLoss, 'price');
|
|
1787
|
+
if (slPrice !== undefined) {
|
|
1788
|
+
slRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
|
|
1789
|
+
}
|
|
1790
|
+
const slQuantity = this.safeString(stopLoss, 'quantity', amount);
|
|
1791
|
+
slRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, slQuantity));
|
|
1792
|
+
request['stopLoss'] = this.json(slRequest);
|
|
1793
|
+
}
|
|
1794
|
+
if (isTakeProfit) {
|
|
1795
|
+
const tkTriggerPrice = this.safeString2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
|
|
1796
|
+
const tkWorkingType = this.safeString(takeProfit, 'workingType', 'MARK_PRICE');
|
|
1797
|
+
const tpType = this.safeString(takeProfit, 'type', 'TAKE_PROFIT_MARKET');
|
|
1798
|
+
const tpRequest = {
|
|
1799
|
+
'stopPrice': this.parseToNumeric(this.priceToPrecision(symbol, tkTriggerPrice)),
|
|
1800
|
+
'workingType': tkWorkingType,
|
|
1801
|
+
'type': tpType,
|
|
1802
|
+
};
|
|
1803
|
+
const slPrice = this.safeString(takeProfit, 'price');
|
|
1804
|
+
if (slPrice !== undefined) {
|
|
1805
|
+
tpRequest['price'] = this.parseToNumeric(this.priceToPrecision(symbol, slPrice));
|
|
1806
|
+
}
|
|
1807
|
+
const tkQuantity = this.safeString(takeProfit, 'quantity', amount);
|
|
1808
|
+
tpRequest['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, tkQuantity));
|
|
1809
|
+
request['takeProfit'] = this.json(tpRequest);
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1759
1812
|
let positionSide = undefined;
|
|
1760
1813
|
if (reduceOnly) {
|
|
1761
1814
|
positionSide = (side === 'buy') ? 'SHORT' : 'LONG';
|
|
@@ -1765,7 +1818,7 @@ export default class bingx extends Exchange {
|
|
|
1765
1818
|
}
|
|
1766
1819
|
request['positionSide'] = positionSide;
|
|
1767
1820
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
1768
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent']);
|
|
1821
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
|
|
1769
1822
|
}
|
|
1770
1823
|
return this.extend(request, params);
|
|
1771
1824
|
}
|
|
@@ -1775,6 +1828,7 @@ export default class bingx extends Exchange {
|
|
|
1775
1828
|
* @name bingx#createOrder
|
|
1776
1829
|
* @description create a trade order
|
|
1777
1830
|
* @see https://bingx-api.github.io/docs/#/en-us/swapV2/trade-api.html#Trade%20order
|
|
1831
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Create%20an%20Order
|
|
1778
1832
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1779
1833
|
* @param {string} type 'market' or 'limit'
|
|
1780
1834
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -1790,6 +1844,10 @@ export default class bingx extends Exchange {
|
|
|
1790
1844
|
* @param {float} [params.cost] the quote quantity that can be used as an alternative for the amount
|
|
1791
1845
|
* @param {float} [params.trailingAmount] *swap only* the quote amount to trail away from the current market price
|
|
1792
1846
|
* @param {float} [params.trailingPercent] *swap only* the percent to trail away from the current market price
|
|
1847
|
+
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
1848
|
+
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
1849
|
+
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
|
|
1850
|
+
* @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
|
|
1793
1851
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1794
1852
|
*/
|
|
1795
1853
|
await this.loadMarkets();
|
|
@@ -1840,6 +1898,9 @@ export default class bingx extends Exchange {
|
|
|
1840
1898
|
// }
|
|
1841
1899
|
// }
|
|
1842
1900
|
//
|
|
1901
|
+
if (typeof response === 'string') {
|
|
1902
|
+
response = JSON.parse(response);
|
|
1903
|
+
}
|
|
1843
1904
|
const data = this.safeValue(response, 'data', {});
|
|
1844
1905
|
const order = this.safeValue(data, 'order', data);
|
|
1845
1906
|
return this.parseOrder(order, market);
|
|
@@ -2044,6 +2105,24 @@ export default class bingx extends Exchange {
|
|
|
2044
2105
|
// "orderType": "",
|
|
2045
2106
|
// "workingType": "MARK_PRICE"
|
|
2046
2107
|
// }
|
|
2108
|
+
// with tp and sl
|
|
2109
|
+
// {
|
|
2110
|
+
// orderId: 1741440894764281900,
|
|
2111
|
+
// symbol: 'LTC-USDT',
|
|
2112
|
+
// positionSide: 'LONG',
|
|
2113
|
+
// side: 'BUY',
|
|
2114
|
+
// type: 'MARKET',
|
|
2115
|
+
// price: 0,
|
|
2116
|
+
// quantity: 1,
|
|
2117
|
+
// stopPrice: 0,
|
|
2118
|
+
// workingType: 'MARK_PRICE',
|
|
2119
|
+
// clientOrderID: '',
|
|
2120
|
+
// timeInForce: 'GTC',
|
|
2121
|
+
// priceRate: 0,
|
|
2122
|
+
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
2123
|
+
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
2124
|
+
// reduceOnly: false
|
|
2125
|
+
// }
|
|
2047
2126
|
//
|
|
2048
2127
|
const positionSide = this.safeString2(order, 'positionSide', 'ps');
|
|
2049
2128
|
const marketType = (positionSide === undefined) ? 'spot' : 'swap';
|
|
@@ -2082,6 +2161,30 @@ export default class bingx extends Exchange {
|
|
|
2082
2161
|
'cost': Precise.stringAbs(feeCost),
|
|
2083
2162
|
};
|
|
2084
2163
|
const clientOrderId = this.safeString2(order, 'clientOrderId', 'c');
|
|
2164
|
+
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
2165
|
+
let stopLossPrice = undefined;
|
|
2166
|
+
if (stopLoss !== undefined) {
|
|
2167
|
+
stopLossPrice = this.safeNumber(stopLoss, 'stopLoss');
|
|
2168
|
+
}
|
|
2169
|
+
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
|
|
2170
|
+
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
2171
|
+
if (typeof stopLoss === 'string') {
|
|
2172
|
+
stopLoss = JSON.parse(stopLoss);
|
|
2173
|
+
}
|
|
2174
|
+
stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
|
|
2175
|
+
}
|
|
2176
|
+
let takeProfit = this.safeValue(order, 'takeProfit');
|
|
2177
|
+
let takeProfitPrice = undefined;
|
|
2178
|
+
if (takeProfit !== undefined) {
|
|
2179
|
+
takeProfitPrice = this.safeNumber(takeProfit, 'takeProfit');
|
|
2180
|
+
}
|
|
2181
|
+
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
|
|
2182
|
+
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
2183
|
+
if (typeof takeProfit === 'string') {
|
|
2184
|
+
takeProfit = JSON.parse(takeProfit);
|
|
2185
|
+
}
|
|
2186
|
+
takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
|
|
2187
|
+
}
|
|
2085
2188
|
return this.safeOrder({
|
|
2086
2189
|
'info': order,
|
|
2087
2190
|
'id': orderId,
|
|
@@ -2098,8 +2201,8 @@ export default class bingx extends Exchange {
|
|
|
2098
2201
|
'price': price,
|
|
2099
2202
|
'stopPrice': this.safeNumber(order, 'stopPrice'),
|
|
2100
2203
|
'triggerPrice': this.safeNumber(order, 'stopPrice'),
|
|
2101
|
-
'stopLossPrice':
|
|
2102
|
-
'takeProfitPrice':
|
|
2204
|
+
'stopLossPrice': stopLossPrice,
|
|
2205
|
+
'takeProfitPrice': takeProfitPrice,
|
|
2103
2206
|
'average': average,
|
|
2104
2207
|
'cost': undefined,
|
|
2105
2208
|
'amount': amount,
|
|
@@ -2206,6 +2309,7 @@ export default class bingx extends Exchange {
|
|
|
2206
2309
|
* @method
|
|
2207
2310
|
* @name bingx#cancelAllOrders
|
|
2208
2311
|
* @description cancel all open orders
|
|
2312
|
+
* @see https://bingx-api.github.io/docs/#/en-us/spot/trade-api.html#Cancel%20orders%20by%20symbol
|
|
2209
2313
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Cancel%20All%20Orders
|
|
2210
2314
|
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
2211
2315
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2216,42 +2320,70 @@ export default class bingx extends Exchange {
|
|
|
2216
2320
|
}
|
|
2217
2321
|
await this.loadMarkets();
|
|
2218
2322
|
const market = this.market(symbol);
|
|
2219
|
-
if (market['type'] !== 'swap') {
|
|
2220
|
-
throw new BadRequest(this.id + ' cancelAllOrders is only supported for swap markets.');
|
|
2221
|
-
}
|
|
2222
2323
|
const request = {
|
|
2223
2324
|
'symbol': market['id'],
|
|
2224
2325
|
};
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2326
|
+
let response = undefined;
|
|
2327
|
+
if (market['spot']) {
|
|
2328
|
+
response = await this.spotV1PrivatePostTradeCancelOpenOrders(this.extend(request, params));
|
|
2329
|
+
//
|
|
2330
|
+
// {
|
|
2331
|
+
// "code": 0,
|
|
2332
|
+
// "msg": "",
|
|
2333
|
+
// "debugMsg": "",
|
|
2334
|
+
// "data": {
|
|
2335
|
+
// "orders": [{
|
|
2336
|
+
// "symbol": "ADA-USDT",
|
|
2337
|
+
// "orderId": 1740659971369992192,
|
|
2338
|
+
// "transactTime": 1703840651730,
|
|
2339
|
+
// "price": 5,
|
|
2340
|
+
// "stopPrice": 0,
|
|
2341
|
+
// "origQty": 10,
|
|
2342
|
+
// "executedQty": 0,
|
|
2343
|
+
// "cummulativeQuoteQty": 0,
|
|
2344
|
+
// "status": "CANCELED",
|
|
2345
|
+
// "type": "LIMIT",
|
|
2346
|
+
// "side": "SELL"
|
|
2347
|
+
// }]
|
|
2348
|
+
// }
|
|
2349
|
+
// }
|
|
2350
|
+
//
|
|
2351
|
+
}
|
|
2352
|
+
else if (market['swap']) {
|
|
2353
|
+
response = await this.swapV2PrivateDeleteTradeAllOpenOrders(this.extend(request, params));
|
|
2354
|
+
//
|
|
2355
|
+
// {
|
|
2356
|
+
// "code": 0,
|
|
2357
|
+
// "msg": "",
|
|
2358
|
+
// "data": {
|
|
2359
|
+
// "success": [
|
|
2360
|
+
// {
|
|
2361
|
+
// "symbol": "LINK-USDT",
|
|
2362
|
+
// "orderId": 1597783835095859200,
|
|
2363
|
+
// "side": "BUY",
|
|
2364
|
+
// "positionSide": "LONG",
|
|
2365
|
+
// "type": "TRIGGER_LIMIT",
|
|
2366
|
+
// "origQty": "5.0",
|
|
2367
|
+
// "price": "9.0000",
|
|
2368
|
+
// "executedQty": "0.0",
|
|
2369
|
+
// "avgPrice": "0.0000",
|
|
2370
|
+
// "cumQuote": "0",
|
|
2371
|
+
// "stopPrice": "9.5000",
|
|
2372
|
+
// "profit": "",
|
|
2373
|
+
// "commission": "",
|
|
2374
|
+
// "status": "NEW",
|
|
2375
|
+
// "time": 1669776326000,
|
|
2376
|
+
// "updateTime": 1669776326000
|
|
2377
|
+
// }
|
|
2378
|
+
// ],
|
|
2379
|
+
// "failed": null
|
|
2380
|
+
// }
|
|
2381
|
+
// }
|
|
2382
|
+
//
|
|
2383
|
+
}
|
|
2384
|
+
else {
|
|
2385
|
+
throw new BadRequest(this.id + ' cancelAllOrders is only supported for spot and swap markets.');
|
|
2386
|
+
}
|
|
2255
2387
|
return response;
|
|
2256
2388
|
}
|
|
2257
2389
|
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
@@ -2264,6 +2396,7 @@ export default class bingx extends Exchange {
|
|
|
2264
2396
|
* @param {string[]} ids order ids
|
|
2265
2397
|
* @param {string} symbol unified market symbol, default is undefined
|
|
2266
2398
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2399
|
+
* @param {string[]} [params.clientOrderIds] client order ids
|
|
2267
2400
|
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2268
2401
|
*/
|
|
2269
2402
|
if (symbol === undefined) {
|
|
@@ -2274,19 +2407,27 @@ export default class bingx extends Exchange {
|
|
|
2274
2407
|
const request = {
|
|
2275
2408
|
'symbol': market['id'],
|
|
2276
2409
|
};
|
|
2410
|
+
const clientOrderIds = this.safeValue(params, 'clientOrderIds');
|
|
2411
|
+
let idsToParse = ids;
|
|
2412
|
+
const areClientOrderIds = (clientOrderIds !== undefined);
|
|
2413
|
+
if (areClientOrderIds) {
|
|
2414
|
+
idsToParse = clientOrderIds;
|
|
2415
|
+
}
|
|
2277
2416
|
const parsedIds = [];
|
|
2278
|
-
for (let i = 0; i <
|
|
2279
|
-
const id =
|
|
2417
|
+
for (let i = 0; i < idsToParse.length; i++) {
|
|
2418
|
+
const id = idsToParse[i];
|
|
2280
2419
|
const stringId = id.toString();
|
|
2281
2420
|
parsedIds.push(stringId);
|
|
2282
2421
|
}
|
|
2283
2422
|
let response = undefined;
|
|
2284
2423
|
if (market['spot']) {
|
|
2285
|
-
|
|
2424
|
+
const spotReqKey = areClientOrderIds ? 'clientOrderIds' : 'orderIds';
|
|
2425
|
+
request[spotReqKey] = parsedIds.join(',');
|
|
2286
2426
|
response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
|
|
2287
2427
|
}
|
|
2288
2428
|
else {
|
|
2289
|
-
|
|
2429
|
+
const swapReqKey = areClientOrderIds ? 'ClientOrderIDList' : 'orderIdList';
|
|
2430
|
+
request[swapReqKey] = parsedIds;
|
|
2290
2431
|
response = await this.swapV2PrivateDeleteTradeBatchOrders(this.extend(request, params));
|
|
2291
2432
|
}
|
|
2292
2433
|
//
|
package/js/src/bitget.js
CHANGED
|
@@ -4745,8 +4745,8 @@ export default class bitget extends Exchange {
|
|
|
4745
4745
|
}
|
|
4746
4746
|
let marginMode = undefined;
|
|
4747
4747
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
|
|
4748
|
-
const stop = this.
|
|
4749
|
-
params = this.omit(params, 'stop');
|
|
4748
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
4749
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
4750
4750
|
const orderIdList = [];
|
|
4751
4751
|
for (let i = 0; i < ids.length; i++) {
|
|
4752
4752
|
const individualId = ids[i];
|
|
@@ -4842,8 +4842,8 @@ export default class bitget extends Exchange {
|
|
|
4842
4842
|
const request = {
|
|
4843
4843
|
'symbol': market['id'],
|
|
4844
4844
|
};
|
|
4845
|
-
const stop = this.
|
|
4846
|
-
params = this.omit(params, 'stop');
|
|
4845
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
4846
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
4847
4847
|
let response = undefined;
|
|
4848
4848
|
if (market['spot']) {
|
|
4849
4849
|
if (marginMode !== undefined) {
|
package/js/src/bitmart.js
CHANGED
|
@@ -2510,8 +2510,8 @@ export default class bitmart extends Exchange {
|
|
|
2510
2510
|
response = await this.privatePostSpotV3CancelOrder(this.extend(request, params));
|
|
2511
2511
|
}
|
|
2512
2512
|
else {
|
|
2513
|
-
const stop = this.
|
|
2514
|
-
params = this.omit(params, ['stop']);
|
|
2513
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
2514
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
2515
2515
|
if (!stop) {
|
|
2516
2516
|
response = await this.privatePostContractPrivateCancelOrder(this.extend(request, params));
|
|
2517
2517
|
}
|
package/js/src/bitstamp.js
CHANGED
|
@@ -1335,6 +1335,12 @@ export default class bitstamp extends Exchange {
|
|
|
1335
1335
|
* @method
|
|
1336
1336
|
* @name bitstamp#createOrder
|
|
1337
1337
|
* @description create a trade order
|
|
1338
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantBuyOrder
|
|
1339
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketBuyOrder
|
|
1340
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitBuyOrder
|
|
1341
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenInstantSellOrder
|
|
1342
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenMarketSellOrder
|
|
1343
|
+
* @see https://www.bitstamp.net/api/#tag/Orders/operation/OpenLimitSellOrder
|
|
1338
1344
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
1339
1345
|
* @param {string} type 'market' or 'limit'
|
|
1340
1346
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -1345,27 +1351,42 @@ export default class bitstamp extends Exchange {
|
|
|
1345
1351
|
*/
|
|
1346
1352
|
await this.loadMarkets();
|
|
1347
1353
|
const market = this.market(symbol);
|
|
1348
|
-
let method = 'privatePost' + this.capitalize(side);
|
|
1349
1354
|
const request = {
|
|
1350
1355
|
'pair': market['id'],
|
|
1351
1356
|
'amount': this.amountToPrecision(symbol, amount),
|
|
1352
1357
|
};
|
|
1358
|
+
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
1359
|
+
if (clientOrderId !== undefined) {
|
|
1360
|
+
request['client_order_id'] = clientOrderId;
|
|
1361
|
+
params = this.omit(params, ['clientOrderId']);
|
|
1362
|
+
}
|
|
1363
|
+
let response = undefined;
|
|
1364
|
+
const capitalizedSide = this.capitalize(side);
|
|
1353
1365
|
if (type === 'market') {
|
|
1354
|
-
|
|
1366
|
+
if (capitalizedSide === 'Buy') {
|
|
1367
|
+
response = await this.privatePostBuyMarketPair(this.extend(request, params));
|
|
1368
|
+
}
|
|
1369
|
+
else {
|
|
1370
|
+
response = await this.privatePostSellMarketPair(this.extend(request, params));
|
|
1371
|
+
}
|
|
1355
1372
|
}
|
|
1356
1373
|
else if (type === 'instant') {
|
|
1357
|
-
|
|
1374
|
+
if (capitalizedSide === 'Buy') {
|
|
1375
|
+
response = await this.privatePostBuyInstantPair(this.extend(request, params));
|
|
1376
|
+
}
|
|
1377
|
+
else {
|
|
1378
|
+
response = await this.privatePostSellInstantPair(this.extend(request, params));
|
|
1379
|
+
}
|
|
1358
1380
|
}
|
|
1359
1381
|
else {
|
|
1360
1382
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
1383
|
+
if (capitalizedSide === 'Buy') {
|
|
1384
|
+
response = await this.privatePostBuyPair(this.extend(request, params));
|
|
1385
|
+
}
|
|
1386
|
+
else {
|
|
1387
|
+
response = await this.privatePostSellPair(this.extend(request, params));
|
|
1388
|
+
}
|
|
1361
1389
|
}
|
|
1362
|
-
method += 'Pair';
|
|
1363
|
-
const clientOrderId = this.safeString2(params, 'client_order_id', 'clientOrderId');
|
|
1364
|
-
if (clientOrderId !== undefined) {
|
|
1365
|
-
request['client_order_id'] = clientOrderId;
|
|
1366
|
-
params = this.omit(params, ['client_order_id', 'clientOrderId']);
|
|
1367
|
-
}
|
|
1368
|
-
const response = await this[method](this.extend(request, params));
|
|
1369
1390
|
const order = this.parseOrder(response, market);
|
|
1370
1391
|
order['type'] = type;
|
|
1371
1392
|
return order;
|
|
@@ -1398,13 +1419,16 @@ export default class bitstamp extends Exchange {
|
|
|
1398
1419
|
await this.loadMarkets();
|
|
1399
1420
|
let market = undefined;
|
|
1400
1421
|
const request = {};
|
|
1401
|
-
let
|
|
1422
|
+
let response = undefined;
|
|
1402
1423
|
if (symbol !== undefined) {
|
|
1403
1424
|
market = this.market(symbol);
|
|
1404
1425
|
request['pair'] = market['id'];
|
|
1405
|
-
|
|
1426
|
+
response = await this.privatePostCancelAllOrdersPair(this.extend(request, params));
|
|
1427
|
+
}
|
|
1428
|
+
else {
|
|
1429
|
+
response = await this.privatePostCancelAllOrders(this.extend(request, params));
|
|
1406
1430
|
}
|
|
1407
|
-
return
|
|
1431
|
+
return response;
|
|
1408
1432
|
}
|
|
1409
1433
|
parseOrderStatus(status) {
|
|
1410
1434
|
const statuses = {
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -1281,7 +1281,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
1281
1281
|
* @see https://www.kucoin.com/docs/rest/futures-trading/orders/cancel-multiple-futures-stop-orders
|
|
1282
1282
|
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
1283
1283
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1284
|
-
* @param {object} [params.
|
|
1284
|
+
* @param {object} [params.trigger] When true, all the trigger orders will be cancelled
|
|
1285
1285
|
* @returns Response from the exchange
|
|
1286
1286
|
*/
|
|
1287
1287
|
await this.loadMarkets();
|
|
@@ -1289,8 +1289,8 @@ export default class kucoinfutures extends kucoin {
|
|
|
1289
1289
|
if (symbol !== undefined) {
|
|
1290
1290
|
request['symbol'] = this.marketId(symbol);
|
|
1291
1291
|
}
|
|
1292
|
-
const stop = this.
|
|
1293
|
-
params = this.omit(params, 'stop');
|
|
1292
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
1293
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
1294
1294
|
let response = undefined;
|
|
1295
1295
|
if (stop) {
|
|
1296
1296
|
response = await this.futuresPrivateDeleteStopOrders(this.extend(request, params));
|
|
@@ -1459,7 +1459,7 @@ export default class kucoinfutures extends kucoin {
|
|
|
1459
1459
|
* @param {int} [since] timestamp in ms of the earliest order to retrieve
|
|
1460
1460
|
* @param {int} [limit] The maximum number of orders to retrieve
|
|
1461
1461
|
* @param {object} [params] exchange specific parameters
|
|
1462
|
-
* @param {bool} [params.
|
|
1462
|
+
* @param {bool} [params.trigger] set to true to retrieve untriggered stop orders
|
|
1463
1463
|
* @param {int} [params.until] End time in ms
|
|
1464
1464
|
* @param {string} [params.side] buy or sell
|
|
1465
1465
|
* @param {string} [params.type] limit or market
|
|
@@ -1472,9 +1472,9 @@ export default class kucoinfutures extends kucoin {
|
|
|
1472
1472
|
if (paginate) {
|
|
1473
1473
|
return await this.fetchPaginatedCallDynamic('fetchOrdersByStatus', symbol, since, limit, params);
|
|
1474
1474
|
}
|
|
1475
|
-
const stop = this.
|
|
1475
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
1476
1476
|
const until = this.safeInteger2(params, 'until', 'till');
|
|
1477
|
-
params = this.omit(params, ['stop', 'until', 'till']);
|
|
1477
|
+
params = this.omit(params, ['stop', 'until', 'till', 'trigger']);
|
|
1478
1478
|
if (status === 'closed') {
|
|
1479
1479
|
status = 'done';
|
|
1480
1480
|
}
|
package/js/src/lykke.js
CHANGED
|
@@ -435,7 +435,13 @@ export default class lykke extends Exchange {
|
|
|
435
435
|
};
|
|
436
436
|
// publicGetTickers or publicGetPrices
|
|
437
437
|
const method = this.safeString(this.options, 'fetchTickerMethod', 'publicGetTickers');
|
|
438
|
-
|
|
438
|
+
let response = undefined;
|
|
439
|
+
if (method === 'publicGetPrices') {
|
|
440
|
+
response = await this.publicGetPrices(this.extend(request, params));
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
response = await this.publicGetTickers(this.extend(request, params));
|
|
444
|
+
}
|
|
439
445
|
const ticker = this.safeValue(response, 'payload', []);
|
|
440
446
|
//
|
|
441
447
|
// publicGetTickers
|
|
@@ -789,8 +795,13 @@ export default class lykke extends Exchange {
|
|
|
789
795
|
if (type === 'limit') {
|
|
790
796
|
query['price'] = parseFloat(this.priceToPrecision(market['symbol'], price));
|
|
791
797
|
}
|
|
792
|
-
|
|
793
|
-
|
|
798
|
+
let result = undefined;
|
|
799
|
+
if (this.capitalize(type) === 'Market') {
|
|
800
|
+
result = await this.privatePostOrdersMarket(this.extend(query, params));
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
result = await this.privatePostOrdersLimit(this.extend(query, params));
|
|
804
|
+
}
|
|
794
805
|
//
|
|
795
806
|
// market
|
|
796
807
|
//
|
package/js/src/okcoin.js
CHANGED
|
@@ -1974,7 +1974,7 @@ export default class okcoin extends Exchange {
|
|
|
1974
1974
|
// 'ordId': id,
|
|
1975
1975
|
};
|
|
1976
1976
|
const clientOrderId = this.safeString2(params, 'clOrdId', 'clientOrderId');
|
|
1977
|
-
const stop = this.
|
|
1977
|
+
const stop = this.safeValue2(params, 'stop', 'trigger');
|
|
1978
1978
|
if (stop) {
|
|
1979
1979
|
if (clientOrderId !== undefined) {
|
|
1980
1980
|
request['algoClOrdId'] = clientOrderId;
|
|
@@ -1991,7 +1991,7 @@ export default class okcoin extends Exchange {
|
|
|
1991
1991
|
request['ordId'] = id;
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
1994
|
-
const query = this.omit(params, ['clientOrderId', 'stop']);
|
|
1994
|
+
const query = this.omit(params, ['clientOrderId', 'stop', 'trigger']);
|
|
1995
1995
|
let response = undefined;
|
|
1996
1996
|
if (stop) {
|
|
1997
1997
|
response = await this.privateGetTradeOrderAlgo(this.extend(request, query));
|