ccxt 4.4.4 → 4.4.6
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.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +3 -3
- package/dist/cjs/src/binanceus.js +1 -0
- package/dist/cjs/src/bitflyer.js +2 -2
- package/dist/cjs/src/bitget.js +56 -95
- package/dist/cjs/src/bitmart.js +186 -127
- package/dist/cjs/src/bybit.js +90 -7
- package/dist/cjs/src/coinbase.js +6 -8
- package/dist/cjs/src/kraken.js +6 -1
- package/dist/cjs/src/lykke.js +2 -2
- package/dist/cjs/src/mexc.js +37 -7
- package/dist/cjs/src/paradex.js +1 -1
- package/dist/cjs/src/pro/binance.js +6 -2
- package/dist/cjs/src/pro/binanceus.js +2 -1
- package/dist/cjs/src/pro/htx.js +14 -0
- package/dist/cjs/src/pro/hyperliquid.js +16 -1
- package/dist/cjs/src/pro/kraken.js +60 -0
- package/dist/cjs/src/pro/paradex.js +1 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +4 -0
- package/js/src/binance.js +3 -3
- package/js/src/binanceus.js +1 -0
- package/js/src/bitflyer.js +2 -2
- package/js/src/bitget.d.ts +1 -1
- package/js/src/bitget.js +56 -95
- package/js/src/bitmart.js +186 -127
- package/js/src/bybit.js +90 -7
- package/js/src/coinbase.js +6 -8
- package/js/src/kraken.js +6 -1
- package/js/src/lykke.js +2 -2
- package/js/src/mexc.d.ts +1 -0
- package/js/src/mexc.js +37 -7
- package/js/src/paradex.js +1 -1
- package/js/src/pro/binance.d.ts +140 -0
- package/js/src/pro/binance.js +6 -2
- package/js/src/pro/binanceus.js +2 -1
- package/js/src/pro/htx.js +14 -0
- package/js/src/pro/hyperliquid.d.ts +1 -0
- package/js/src/pro/hyperliquid.js +16 -1
- package/js/src/pro/kraken.d.ts +3 -0
- package/js/src/pro/kraken.js +60 -0
- package/js/src/pro/paradex.js +1 -0
- package/js/src/static_dependencies/jsencrypt/lib/jsbn/jsbn.d.ts +1 -1
- package/js/src/static_dependencies/starknet/utils/calldata/parser/index.d.ts +1 -1
- package/package.json +1 -1
package/js/src/bitmart.js
CHANGED
|
@@ -252,6 +252,10 @@ export default class bitmart extends Exchange {
|
|
|
252
252
|
'contract/private/submit-plan-order': 2.5,
|
|
253
253
|
'contract/private/cancel-plan-order': 1.5,
|
|
254
254
|
'contract/private/submit-leverage': 2.5,
|
|
255
|
+
'contract/private/submit-tp-sl-order': 2.5,
|
|
256
|
+
'contract/private/modify-plan-order': 2.5,
|
|
257
|
+
'contract/private/modify-preset-plan-order': 2.5,
|
|
258
|
+
'contract/private/modify-tp-sl-order': 2.5,
|
|
255
259
|
},
|
|
256
260
|
},
|
|
257
261
|
},
|
|
@@ -874,43 +878,43 @@ export default class bitmart extends Exchange {
|
|
|
874
878
|
async fetchContractMarkets(params = {}) {
|
|
875
879
|
const response = await this.publicGetContractPublicDetails(params);
|
|
876
880
|
//
|
|
877
|
-
//
|
|
878
|
-
//
|
|
879
|
-
//
|
|
880
|
-
//
|
|
881
|
-
//
|
|
882
|
-
//
|
|
883
|
-
//
|
|
884
|
-
//
|
|
885
|
-
//
|
|
886
|
-
//
|
|
887
|
-
//
|
|
888
|
-
//
|
|
889
|
-
//
|
|
890
|
-
//
|
|
891
|
-
//
|
|
892
|
-
//
|
|
893
|
-
//
|
|
894
|
-
//
|
|
895
|
-
//
|
|
896
|
-
//
|
|
897
|
-
//
|
|
898
|
-
//
|
|
899
|
-
//
|
|
900
|
-
//
|
|
901
|
-
//
|
|
902
|
-
//
|
|
903
|
-
//
|
|
904
|
-
//
|
|
905
|
-
//
|
|
906
|
-
//
|
|
907
|
-
//
|
|
908
|
-
//
|
|
909
|
-
//
|
|
910
|
-
//
|
|
911
|
-
//
|
|
881
|
+
// {
|
|
882
|
+
// "code": 1000,
|
|
883
|
+
// "message": "Ok",
|
|
884
|
+
// "data": {
|
|
885
|
+
// "symbols": [
|
|
886
|
+
// {
|
|
887
|
+
// "symbol": "BTCUSDT",
|
|
888
|
+
// "product_type": 1,
|
|
889
|
+
// "open_timestamp": 1645977600000,
|
|
890
|
+
// "expire_timestamp": 0,
|
|
891
|
+
// "settle_timestamp": 0,
|
|
892
|
+
// "base_currency": "BTC",
|
|
893
|
+
// "quote_currency": "USDT",
|
|
894
|
+
// "last_price": "63547.4",
|
|
895
|
+
// "volume_24h": "110938430",
|
|
896
|
+
// "turnover_24h": "7004836342.6944",
|
|
897
|
+
// "index_price": "63587.85404255",
|
|
898
|
+
// "index_name": "BTCUSDT",
|
|
899
|
+
// "contract_size": "0.001",
|
|
900
|
+
// "min_leverage": "1",
|
|
901
|
+
// "max_leverage": "100",
|
|
902
|
+
// "price_precision": "0.1",
|
|
903
|
+
// "vol_precision": "1",
|
|
904
|
+
// "max_volume": "1000000",
|
|
905
|
+
// "min_volume": "1",
|
|
906
|
+
// "funding_rate": "0.0000801",
|
|
907
|
+
// "expected_funding_rate": "-0.0000035",
|
|
908
|
+
// "open_interest": "278214",
|
|
909
|
+
// "open_interest_value": "17555316.9355496",
|
|
910
|
+
// "high_24h": "64109.4",
|
|
911
|
+
// "low_24h": "61857.6",
|
|
912
|
+
// "change_24h": "0.0239264900886327",
|
|
913
|
+
// "funding_time": 1726819200000
|
|
914
|
+
// },
|
|
915
|
+
// ]
|
|
916
|
+
// }
|
|
912
917
|
// }
|
|
913
|
-
// }
|
|
914
918
|
//
|
|
915
919
|
const data = this.safeValue(response, 'data', {});
|
|
916
920
|
const symbols = this.safeValue(data, 'symbols', []);
|
|
@@ -1196,33 +1200,34 @@ export default class bitmart extends Exchange {
|
|
|
1196
1200
|
// swap
|
|
1197
1201
|
//
|
|
1198
1202
|
// {
|
|
1199
|
-
//
|
|
1200
|
-
//
|
|
1201
|
-
//
|
|
1202
|
-
//
|
|
1203
|
-
//
|
|
1204
|
-
//
|
|
1205
|
-
//
|
|
1206
|
-
//
|
|
1207
|
-
//
|
|
1208
|
-
//
|
|
1209
|
-
//
|
|
1210
|
-
//
|
|
1211
|
-
//
|
|
1212
|
-
//
|
|
1213
|
-
//
|
|
1214
|
-
//
|
|
1215
|
-
//
|
|
1216
|
-
//
|
|
1217
|
-
//
|
|
1218
|
-
//
|
|
1219
|
-
//
|
|
1220
|
-
//
|
|
1221
|
-
//
|
|
1222
|
-
//
|
|
1223
|
-
//
|
|
1224
|
-
//
|
|
1225
|
-
//
|
|
1203
|
+
// "symbol": "BTCUSDT",
|
|
1204
|
+
// "product_type": 1,
|
|
1205
|
+
// "open_timestamp": 1645977600000,
|
|
1206
|
+
// "expire_timestamp": 0,
|
|
1207
|
+
// "settle_timestamp": 0,
|
|
1208
|
+
// "base_currency": "BTC",
|
|
1209
|
+
// "quote_currency": "USDT",
|
|
1210
|
+
// "last_price": "63547.4",
|
|
1211
|
+
// "volume_24h": "110938430",
|
|
1212
|
+
// "turnover_24h": "7004836342.6944",
|
|
1213
|
+
// "index_price": "63587.85404255",
|
|
1214
|
+
// "index_name": "BTCUSDT",
|
|
1215
|
+
// "contract_size": "0.001",
|
|
1216
|
+
// "min_leverage": "1",
|
|
1217
|
+
// "max_leverage": "100",
|
|
1218
|
+
// "price_precision": "0.1",
|
|
1219
|
+
// "vol_precision": "1",
|
|
1220
|
+
// "max_volume": "1000000",
|
|
1221
|
+
// "min_volume": "1",
|
|
1222
|
+
// "funding_rate": "0.0000801",
|
|
1223
|
+
// "expected_funding_rate": "-0.0000035",
|
|
1224
|
+
// "open_interest": "278214",
|
|
1225
|
+
// "open_interest_value": "17555316.9355496",
|
|
1226
|
+
// "high_24h": "64109.4",
|
|
1227
|
+
// "low_24h": "61857.6",
|
|
1228
|
+
// "change_24h": "0.0239264900886327",
|
|
1229
|
+
// "funding_time": 1726819200000
|
|
1230
|
+
// }
|
|
1226
1231
|
//
|
|
1227
1232
|
const result = this.safeList(ticker, 'result', []);
|
|
1228
1233
|
const average = this.safeString2(ticker, 'avg_price', 'index_price');
|
|
@@ -1319,27 +1324,43 @@ export default class bitmart extends Exchange {
|
|
|
1319
1324
|
request['symbol'] = market['id'];
|
|
1320
1325
|
response = await this.publicGetContractPublicDetails(this.extend(request, params));
|
|
1321
1326
|
//
|
|
1322
|
-
//
|
|
1323
|
-
//
|
|
1324
|
-
//
|
|
1325
|
-
//
|
|
1326
|
-
//
|
|
1327
|
-
//
|
|
1328
|
-
//
|
|
1329
|
-
//
|
|
1330
|
-
//
|
|
1331
|
-
//
|
|
1332
|
-
//
|
|
1333
|
-
//
|
|
1334
|
-
//
|
|
1335
|
-
//
|
|
1336
|
-
//
|
|
1337
|
-
//
|
|
1338
|
-
//
|
|
1339
|
-
//
|
|
1340
|
-
//
|
|
1341
|
-
//
|
|
1342
|
-
//
|
|
1327
|
+
// {
|
|
1328
|
+
// "code": 1000,
|
|
1329
|
+
// "message": "Ok",
|
|
1330
|
+
// "data": {
|
|
1331
|
+
// "symbols": [
|
|
1332
|
+
// {
|
|
1333
|
+
// "symbol": "BTCUSDT",
|
|
1334
|
+
// "product_type": 1,
|
|
1335
|
+
// "open_timestamp": 1645977600000,
|
|
1336
|
+
// "expire_timestamp": 0,
|
|
1337
|
+
// "settle_timestamp": 0,
|
|
1338
|
+
// "base_currency": "BTC",
|
|
1339
|
+
// "quote_currency": "USDT",
|
|
1340
|
+
// "last_price": "63547.4",
|
|
1341
|
+
// "volume_24h": "110938430",
|
|
1342
|
+
// "turnover_24h": "7004836342.6944",
|
|
1343
|
+
// "index_price": "63587.85404255",
|
|
1344
|
+
// "index_name": "BTCUSDT",
|
|
1345
|
+
// "contract_size": "0.001",
|
|
1346
|
+
// "min_leverage": "1",
|
|
1347
|
+
// "max_leverage": "100",
|
|
1348
|
+
// "price_precision": "0.1",
|
|
1349
|
+
// "vol_precision": "1",
|
|
1350
|
+
// "max_volume": "1000000",
|
|
1351
|
+
// "min_volume": "1",
|
|
1352
|
+
// "funding_rate": "0.0000801",
|
|
1353
|
+
// "expected_funding_rate": "-0.0000035",
|
|
1354
|
+
// "open_interest": "278214",
|
|
1355
|
+
// "open_interest_value": "17555316.9355496",
|
|
1356
|
+
// "high_24h": "64109.4",
|
|
1357
|
+
// "low_24h": "61857.6",
|
|
1358
|
+
// "change_24h": "0.0239264900886327",
|
|
1359
|
+
// "funding_time": 1726819200000
|
|
1360
|
+
// },
|
|
1361
|
+
// ]
|
|
1362
|
+
// }
|
|
1363
|
+
// }
|
|
1343
1364
|
//
|
|
1344
1365
|
}
|
|
1345
1366
|
else if (market['spot']) {
|
|
@@ -1435,43 +1456,43 @@ export default class bitmart extends Exchange {
|
|
|
1435
1456
|
else if (type === 'swap') {
|
|
1436
1457
|
response = await this.publicGetContractPublicDetails(params);
|
|
1437
1458
|
//
|
|
1438
|
-
//
|
|
1439
|
-
//
|
|
1440
|
-
//
|
|
1441
|
-
//
|
|
1442
|
-
//
|
|
1443
|
-
//
|
|
1444
|
-
//
|
|
1445
|
-
//
|
|
1446
|
-
//
|
|
1447
|
-
//
|
|
1448
|
-
//
|
|
1449
|
-
//
|
|
1450
|
-
//
|
|
1451
|
-
//
|
|
1452
|
-
//
|
|
1453
|
-
//
|
|
1454
|
-
//
|
|
1455
|
-
//
|
|
1456
|
-
//
|
|
1457
|
-
//
|
|
1458
|
-
//
|
|
1459
|
-
//
|
|
1460
|
-
//
|
|
1461
|
-
//
|
|
1462
|
-
//
|
|
1463
|
-
//
|
|
1464
|
-
//
|
|
1465
|
-
//
|
|
1466
|
-
//
|
|
1467
|
-
//
|
|
1468
|
-
//
|
|
1469
|
-
//
|
|
1470
|
-
//
|
|
1471
|
-
//
|
|
1472
|
-
//
|
|
1473
|
-
//
|
|
1474
|
-
//
|
|
1459
|
+
// {
|
|
1460
|
+
// "code": 1000,
|
|
1461
|
+
// "message": "Ok",
|
|
1462
|
+
// "data": {
|
|
1463
|
+
// "symbols": [
|
|
1464
|
+
// {
|
|
1465
|
+
// "symbol": "BTCUSDT",
|
|
1466
|
+
// "product_type": 1,
|
|
1467
|
+
// "open_timestamp": 1645977600000,
|
|
1468
|
+
// "expire_timestamp": 0,
|
|
1469
|
+
// "settle_timestamp": 0,
|
|
1470
|
+
// "base_currency": "BTC",
|
|
1471
|
+
// "quote_currency": "USDT",
|
|
1472
|
+
// "last_price": "63547.4",
|
|
1473
|
+
// "volume_24h": "110938430",
|
|
1474
|
+
// "turnover_24h": "7004836342.6944",
|
|
1475
|
+
// "index_price": "63587.85404255",
|
|
1476
|
+
// "index_name": "BTCUSDT",
|
|
1477
|
+
// "contract_size": "0.001",
|
|
1478
|
+
// "min_leverage": "1",
|
|
1479
|
+
// "max_leverage": "100",
|
|
1480
|
+
// "price_precision": "0.1",
|
|
1481
|
+
// "vol_precision": "1",
|
|
1482
|
+
// "max_volume": "1000000",
|
|
1483
|
+
// "min_volume": "1",
|
|
1484
|
+
// "funding_rate": "0.0000801",
|
|
1485
|
+
// "expected_funding_rate": "-0.0000035",
|
|
1486
|
+
// "open_interest": "278214",
|
|
1487
|
+
// "open_interest_value": "17555316.9355496",
|
|
1488
|
+
// "high_24h": "64109.4",
|
|
1489
|
+
// "low_24h": "61857.6",
|
|
1490
|
+
// "change_24h": "0.0239264900886327",
|
|
1491
|
+
// "funding_time": 1726819200000
|
|
1492
|
+
// },
|
|
1493
|
+
// ]
|
|
1494
|
+
// }
|
|
1495
|
+
// }
|
|
1475
1496
|
//
|
|
1476
1497
|
}
|
|
1477
1498
|
else {
|
|
@@ -2466,6 +2487,7 @@ export default class bitmart extends Exchange {
|
|
|
2466
2487
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2467
2488
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
|
|
2468
2489
|
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
|
|
2490
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-tp-or-sl-order-signed
|
|
2469
2491
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2470
2492
|
* @param {string} type 'market', 'limit' or 'trailing' for swap markets only
|
|
2471
2493
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2483,6 +2505,9 @@ export default class bitmart extends Exchange {
|
|
|
2483
2505
|
* @param {int} [params.activation_price_type] *swap trailing order only* 1: last price, 2: fair price, default is 1
|
|
2484
2506
|
* @param {string} [params.trailingPercent] *swap only* the percent to trail away from the current market price, min 0.1 max 5
|
|
2485
2507
|
* @param {string} [params.trailingTriggerPrice] *swap only* the price to trigger a trailing order, default uses the price argument
|
|
2508
|
+
* @param {string} [params.stopLossPrice] *swap only* the price to trigger a stop-loss order
|
|
2509
|
+
* @param {string} [params.takeProfitPrice] *swap only* the price to trigger a take-profit order
|
|
2510
|
+
* @param {int} [params.plan_category] *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
|
|
2486
2511
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2487
2512
|
*/
|
|
2488
2513
|
await this.loadMarkets();
|
|
@@ -2490,6 +2515,10 @@ export default class bitmart extends Exchange {
|
|
|
2490
2515
|
const result = this.handleMarginModeAndParams('createOrder', params);
|
|
2491
2516
|
const marginMode = this.safeString(result, 0);
|
|
2492
2517
|
const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 'trigger_price']);
|
|
2518
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
2519
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
2520
|
+
const isStopLoss = stopLossPrice !== undefined;
|
|
2521
|
+
const isTakeProfit = takeProfitPrice !== undefined;
|
|
2493
2522
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
2494
2523
|
let response = undefined;
|
|
2495
2524
|
if (market['spot']) {
|
|
@@ -2506,6 +2535,9 @@ export default class bitmart extends Exchange {
|
|
|
2506
2535
|
if (isTriggerOrder) {
|
|
2507
2536
|
response = await this.privatePostContractPrivateSubmitPlanOrder(swapRequest);
|
|
2508
2537
|
}
|
|
2538
|
+
else if (isStopLoss || isTakeProfit) {
|
|
2539
|
+
response = await this.privatePostContractPrivateSubmitTpSlOrder(swapRequest);
|
|
2540
|
+
}
|
|
2509
2541
|
else {
|
|
2510
2542
|
response = await this.privatePostContractPrivateSubmitOrder(swapRequest);
|
|
2511
2543
|
}
|
|
@@ -2612,8 +2644,9 @@ export default class bitmart extends Exchange {
|
|
|
2612
2644
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-order-signed
|
|
2613
2645
|
* @see https://developer-pro.bitmart.com/en/futures/#submit-plan-order-signed
|
|
2614
2646
|
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-plan-order-signed
|
|
2647
|
+
* @see https://developer-pro.bitmart.com/en/futuresv2/#submit-tp-or-sl-order-signed
|
|
2615
2648
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2616
|
-
* @param {string} type 'market', 'limit' or '
|
|
2649
|
+
* @param {string} type 'market', 'limit', 'trailing', 'stop_loss', or 'take_profit'
|
|
2617
2650
|
* @param {string} side 'buy' or 'sell'
|
|
2618
2651
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
2619
2652
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
@@ -2628,9 +2661,22 @@ export default class bitmart extends Exchange {
|
|
|
2628
2661
|
* @param {int} [params.activation_price_type] *swap trailing order only* 1: last price, 2: fair price, default is 1
|
|
2629
2662
|
* @param {string} [params.trailingPercent] *swap only* the percent to trail away from the current market price, min 0.1 max 5
|
|
2630
2663
|
* @param {string} [params.trailingTriggerPrice] *swap only* the price to trigger a trailing order, default uses the price argument
|
|
2664
|
+
* @param {string} [params.stopLossPrice] *swap only* the price to trigger a stop-loss order
|
|
2665
|
+
* @param {string} [params.takeProfitPrice] *swap only* the price to trigger a take-profit order
|
|
2666
|
+
* @param {int} [params.plan_category] *swap tp/sl only* 1: tp/sl, 2: position tp/sl, default is 1
|
|
2631
2667
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2632
2668
|
*/
|
|
2633
2669
|
const market = this.market(symbol);
|
|
2670
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
2671
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
2672
|
+
const isStopLoss = stopLossPrice !== undefined;
|
|
2673
|
+
const isTakeProfit = takeProfitPrice !== undefined;
|
|
2674
|
+
if (isStopLoss) {
|
|
2675
|
+
type = 'stop_loss';
|
|
2676
|
+
}
|
|
2677
|
+
else if (isTakeProfit) {
|
|
2678
|
+
type = 'take_profit';
|
|
2679
|
+
}
|
|
2634
2680
|
const request = {
|
|
2635
2681
|
'symbol': market['id'],
|
|
2636
2682
|
'type': type,
|
|
@@ -2640,7 +2686,7 @@ export default class bitmart extends Exchange {
|
|
|
2640
2686
|
const mode = this.safeInteger(params, 'mode'); // only for swap
|
|
2641
2687
|
const isMarketOrder = type === 'market';
|
|
2642
2688
|
let postOnly = undefined;
|
|
2643
|
-
|
|
2689
|
+
let reduceOnly = this.safeBool(params, 'reduceOnly');
|
|
2644
2690
|
const isExchangeSpecificPo = (mode === 4);
|
|
2645
2691
|
[postOnly, params] = this.handlePostOnly(isMarketOrder, isExchangeSpecificPo, params);
|
|
2646
2692
|
const ioc = ((timeInForce === 'IOC') || (mode === 3));
|
|
@@ -2693,6 +2739,22 @@ export default class bitmart extends Exchange {
|
|
|
2693
2739
|
}
|
|
2694
2740
|
}
|
|
2695
2741
|
}
|
|
2742
|
+
let marginMode = undefined;
|
|
2743
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params, 'cross');
|
|
2744
|
+
if (isStopLoss || isTakeProfit) {
|
|
2745
|
+
reduceOnly = true;
|
|
2746
|
+
request['price_type'] = this.safeInteger(params, 'price_type', 1);
|
|
2747
|
+
request['executive_price'] = this.priceToPrecision(symbol, price);
|
|
2748
|
+
if (isStopLoss) {
|
|
2749
|
+
request['trigger_price'] = this.priceToPrecision(symbol, stopLossPrice);
|
|
2750
|
+
}
|
|
2751
|
+
else {
|
|
2752
|
+
request['trigger_price'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
else {
|
|
2756
|
+
request['open_type'] = marginMode;
|
|
2757
|
+
}
|
|
2696
2758
|
if (side === 'buy') {
|
|
2697
2759
|
if (reduceOnly) {
|
|
2698
2760
|
request['side'] = 2; // buy close short
|
|
@@ -2709,16 +2771,13 @@ export default class bitmart extends Exchange {
|
|
|
2709
2771
|
request['side'] = 4; // sell open short
|
|
2710
2772
|
}
|
|
2711
2773
|
}
|
|
2712
|
-
let marginMode = undefined;
|
|
2713
|
-
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params, 'cross');
|
|
2714
|
-
request['open_type'] = marginMode;
|
|
2715
2774
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
2716
2775
|
if (clientOrderId !== undefined) {
|
|
2717
2776
|
params = this.omit(params, 'clientOrderId');
|
|
2718
2777
|
request['client_order_id'] = clientOrderId;
|
|
2719
2778
|
}
|
|
2720
2779
|
const leverage = this.safeInteger(params, 'leverage');
|
|
2721
|
-
params = this.omit(params, ['timeInForce', 'postOnly', 'reduceOnly', 'leverage', 'trailingTriggerPrice', 'trailingPercent', 'triggerPrice', 'stopPrice']);
|
|
2780
|
+
params = this.omit(params, ['timeInForce', 'postOnly', 'reduceOnly', 'leverage', 'trailingTriggerPrice', 'trailingPercent', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
2722
2781
|
if (leverage !== undefined) {
|
|
2723
2782
|
request['leverage'] = this.numberToString(leverage);
|
|
2724
2783
|
}
|
package/js/src/bybit.js
CHANGED
|
@@ -101,7 +101,7 @@ export default class bybit extends Exchange {
|
|
|
101
101
|
'fetchOpenOrders': true,
|
|
102
102
|
'fetchOption': true,
|
|
103
103
|
'fetchOptionChain': true,
|
|
104
|
-
'fetchOrder':
|
|
104
|
+
'fetchOrder': true,
|
|
105
105
|
'fetchOrderBook': true,
|
|
106
106
|
'fetchOrders': false,
|
|
107
107
|
'fetchOrderTrades': true,
|
|
@@ -1645,13 +1645,20 @@ export default class bybit extends Exchange {
|
|
|
1645
1645
|
async fetchFutureMarkets(params) {
|
|
1646
1646
|
params = this.extend(params);
|
|
1647
1647
|
params['limit'] = 1000; // minimize number of requests
|
|
1648
|
+
let preLaunchMarkets = [];
|
|
1648
1649
|
const usePrivateInstrumentsInfo = this.safeBool(this.options, 'usePrivateInstrumentsInfo', false);
|
|
1649
1650
|
let response = undefined;
|
|
1650
1651
|
if (usePrivateInstrumentsInfo) {
|
|
1651
1652
|
response = await this.privateGetV5MarketInstrumentsInfo(params);
|
|
1652
1653
|
}
|
|
1653
1654
|
else {
|
|
1654
|
-
|
|
1655
|
+
const linearPromises = [
|
|
1656
|
+
this.publicGetV5MarketInstrumentsInfo(params),
|
|
1657
|
+
this.publicGetV5MarketInstrumentsInfo(this.extend(params, { 'status': 'PreLaunch' })),
|
|
1658
|
+
];
|
|
1659
|
+
const promises = await Promise.all(linearPromises);
|
|
1660
|
+
response = this.safeDict(promises, 0, {});
|
|
1661
|
+
preLaunchMarkets = this.safeDict(promises, 1, {});
|
|
1655
1662
|
}
|
|
1656
1663
|
const data = this.safeDict(response, 'result', {});
|
|
1657
1664
|
let markets = this.safeList(data, 'list', []);
|
|
@@ -1720,6 +1727,9 @@ export default class bybit extends Exchange {
|
|
|
1720
1727
|
// "time": 1672712495660
|
|
1721
1728
|
// }
|
|
1722
1729
|
//
|
|
1730
|
+
const preLaunchData = this.safeDict(preLaunchMarkets, 'result', {});
|
|
1731
|
+
const preLaunchMarketsList = this.safeList(preLaunchData, 'list', []);
|
|
1732
|
+
markets = this.arrayConcat(markets, preLaunchMarketsList);
|
|
1723
1733
|
const result = [];
|
|
1724
1734
|
let category = this.safeString(data, 'category');
|
|
1725
1735
|
for (let i = 0; i < markets.length; i++) {
|
|
@@ -4876,14 +4886,87 @@ export default class bybit extends Exchange {
|
|
|
4876
4886
|
* @param {string} id the order id
|
|
4877
4887
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
4878
4888
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4889
|
+
* @param {object} [params.acknowledged] to suppress the warning, set to true
|
|
4879
4890
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4880
4891
|
*/
|
|
4881
|
-
|
|
4882
|
-
const enableUnifiedAccount = this.
|
|
4883
|
-
|
|
4884
|
-
|
|
4892
|
+
await this.loadMarkets();
|
|
4893
|
+
const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
|
|
4894
|
+
const isUnifiedAccount = (enableUnifiedMargin || enableUnifiedAccount);
|
|
4895
|
+
if (!isUnifiedAccount) {
|
|
4896
|
+
return await this.fetchOrderClassic(id, symbol, params);
|
|
4897
|
+
}
|
|
4898
|
+
let acknowledge = false;
|
|
4899
|
+
[acknowledge, params] = this.handleOptionAndParams(params, 'fetchOrder', 'acknowledged');
|
|
4900
|
+
if (!acknowledge) {
|
|
4901
|
+
throw new ArgumentsRequired(this.id + ' fetchOrder() can only access an order if it is in last 500 orders (of any status) for your account. Set params["acknowledged"] = true to hide this warning. Alternatively, we suggest to use fetchOpenOrder or fetchClosedOrder');
|
|
4885
4902
|
}
|
|
4886
|
-
|
|
4903
|
+
const market = this.market(symbol);
|
|
4904
|
+
let marketType = undefined;
|
|
4905
|
+
[marketType, params] = this.getBybitType('fetchOrder', market, params);
|
|
4906
|
+
const request = {
|
|
4907
|
+
'symbol': market['id'],
|
|
4908
|
+
'orderId': id,
|
|
4909
|
+
'category': marketType,
|
|
4910
|
+
};
|
|
4911
|
+
let isTrigger = undefined;
|
|
4912
|
+
[isTrigger, params] = this.handleParamBool2(params, 'trigger', 'stop', false);
|
|
4913
|
+
if (isTrigger) {
|
|
4914
|
+
request['orderFilter'] = 'StopOrder';
|
|
4915
|
+
}
|
|
4916
|
+
const response = await this.privateGetV5OrderRealtime(this.extend(request, params));
|
|
4917
|
+
//
|
|
4918
|
+
// {
|
|
4919
|
+
// "retCode": 0,
|
|
4920
|
+
// "retMsg": "OK",
|
|
4921
|
+
// "result": {
|
|
4922
|
+
// "nextPageCursor": "1321052653536515584%3A1672217748287%2C1321052653536515584%3A1672217748287",
|
|
4923
|
+
// "category": "spot",
|
|
4924
|
+
// "list": [
|
|
4925
|
+
// {
|
|
4926
|
+
// "symbol": "ETHUSDT",
|
|
4927
|
+
// "orderType": "Limit",
|
|
4928
|
+
// "orderLinkId": "1672217748277652",
|
|
4929
|
+
// "orderId": "1321052653536515584",
|
|
4930
|
+
// "cancelType": "UNKNOWN",
|
|
4931
|
+
// "avgPrice": "",
|
|
4932
|
+
// "stopOrderType": "tpslOrder",
|
|
4933
|
+
// "lastPriceOnCreated": "",
|
|
4934
|
+
// "orderStatus": "Cancelled",
|
|
4935
|
+
// "takeProfit": "",
|
|
4936
|
+
// "cumExecValue": "0",
|
|
4937
|
+
// "triggerDirection": 0,
|
|
4938
|
+
// "isLeverage": "0",
|
|
4939
|
+
// "rejectReason": "",
|
|
4940
|
+
// "price": "1000",
|
|
4941
|
+
// "orderIv": "",
|
|
4942
|
+
// "createdTime": "1672217748287",
|
|
4943
|
+
// "tpTriggerBy": "",
|
|
4944
|
+
// "positionIdx": 0,
|
|
4945
|
+
// "timeInForce": "GTC",
|
|
4946
|
+
// "leavesValue": "500",
|
|
4947
|
+
// "updatedTime": "1672217748287",
|
|
4948
|
+
// "side": "Buy",
|
|
4949
|
+
// "triggerPrice": "1500",
|
|
4950
|
+
// "cumExecFee": "0",
|
|
4951
|
+
// "leavesQty": "0",
|
|
4952
|
+
// "slTriggerBy": "",
|
|
4953
|
+
// "closeOnTrigger": false,
|
|
4954
|
+
// "cumExecQty": "0",
|
|
4955
|
+
// "reduceOnly": false,
|
|
4956
|
+
// "qty": "0.5",
|
|
4957
|
+
// "stopLoss": "",
|
|
4958
|
+
// "triggerBy": "1192.5"
|
|
4959
|
+
// }
|
|
4960
|
+
// ]
|
|
4961
|
+
// },
|
|
4962
|
+
// "retExtInfo": {},
|
|
4963
|
+
// "time": 1672219526294
|
|
4964
|
+
// }
|
|
4965
|
+
//
|
|
4966
|
+
const result = this.safeDict(response, 'result', {});
|
|
4967
|
+
const innerList = this.safeList(result, 'list', []);
|
|
4968
|
+
const order = this.safeDict(innerList, 0, {});
|
|
4969
|
+
return this.parseOrder(order, market);
|
|
4887
4970
|
}
|
|
4888
4971
|
async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
4889
4972
|
const res = await this.isUnifiedEnabled();
|
package/js/src/coinbase.js
CHANGED
|
@@ -770,30 +770,28 @@ export default class coinbase extends Exchange {
|
|
|
770
770
|
/**
|
|
771
771
|
* @method
|
|
772
772
|
* @name coinbase#fetchWithdrawals
|
|
773
|
-
* @description
|
|
774
|
-
* @see https://docs.
|
|
773
|
+
* @description Fetch all withdrawals made from an account. Won't return crypto withdrawals. Use fetchLedger for those.
|
|
774
|
+
* @see https://docs.cdp.coinbase.com/coinbase-app/docs/api-withdrawals#list-withdrawals
|
|
775
775
|
* @param {string} code unified currency code
|
|
776
776
|
* @param {int} [since] the earliest time in ms to fetch withdrawals for
|
|
777
777
|
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
|
|
778
778
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
779
779
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
780
780
|
*/
|
|
781
|
-
// fiat only, for crypto transactions use fetchLedger
|
|
782
781
|
return await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdWithdrawals', code, since, limit, params);
|
|
783
782
|
}
|
|
784
783
|
async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
785
784
|
/**
|
|
786
785
|
* @method
|
|
787
786
|
* @name coinbase#fetchDeposits
|
|
788
|
-
* @description
|
|
789
|
-
* @see https://docs.
|
|
787
|
+
* @description Fetch all fiat deposits made to an account. Won't return crypto deposits or staking rewards. Use fetchLedger for those.
|
|
788
|
+
* @see https://docs.cdp.coinbase.com/coinbase-app/docs/api-deposits#list-deposits
|
|
790
789
|
* @param {string} code unified currency code
|
|
791
790
|
* @param {int} [since] the earliest time in ms to fetch deposits for
|
|
792
791
|
* @param {int} [limit] the maximum number of deposits structures to retrieve
|
|
793
792
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
794
793
|
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
795
794
|
*/
|
|
796
|
-
// fiat only, for crypto transactions use fetchLedger
|
|
797
795
|
return await this.fetchTransactionsWithMethod('v2PrivateGetAccountsAccountIdDeposits', code, since, limit, params);
|
|
798
796
|
}
|
|
799
797
|
parseTransactionStatus(status) {
|
|
@@ -2260,8 +2258,8 @@ export default class coinbase extends Exchange {
|
|
|
2260
2258
|
/**
|
|
2261
2259
|
* @method
|
|
2262
2260
|
* @name coinbase#fetchLedger
|
|
2263
|
-
* @description
|
|
2264
|
-
* @see https://docs.
|
|
2261
|
+
* @description Fetch the history of changes, i.e. actions done by the user or operations that altered the balance. Will return staking rewards, and crypto deposits or withdrawals.
|
|
2262
|
+
* @see https://docs.cdp.coinbase.com/coinbase-app/docs/api-transactions#list-transactions
|
|
2265
2263
|
* @param {string} [code] unified currency code, default is undefined
|
|
2266
2264
|
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
|
|
2267
2265
|
* @param {int} [limit] max number of ledger entries to return, default is undefined
|