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