ccxt 4.4.82 → 4.4.85
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 +5 -7
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +1 -9
- package/dist/cjs/src/apex.js +2 -1
- package/dist/cjs/src/base/Exchange.js +15 -2
- package/dist/cjs/src/bitget.js +1 -3
- package/dist/cjs/src/bitrue.js +14 -35
- package/dist/cjs/src/bitso.js +33 -0
- package/dist/cjs/src/bitstamp.js +33 -0
- package/dist/cjs/src/blofin.js +154 -13
- package/dist/cjs/src/btcbox.js +25 -5
- package/dist/cjs/src/bybit.js +16 -40
- package/dist/cjs/src/cex.js +2 -4
- package/dist/cjs/src/coinbase.js +56 -40
- package/dist/cjs/src/coinbaseexchange.js +142 -32
- package/dist/cjs/src/coincatch.js +14 -67
- package/dist/cjs/src/coinex.js +29 -32
- package/dist/cjs/src/coinlist.js +16 -15
- package/dist/cjs/src/coinmetro.js +22 -11
- package/dist/cjs/src/coinone.js +8 -10
- package/dist/cjs/src/coinsph.js +126 -1
- package/dist/cjs/src/cryptocom.js +111 -1
- package/dist/cjs/src/cryptomus.js +43 -89
- package/dist/cjs/src/delta.js +76 -36
- package/dist/cjs/src/derive.js +46 -10
- package/dist/cjs/src/ellipx.js +175 -79
- package/dist/cjs/src/gate.js +1 -1
- package/dist/cjs/src/gemini.js +3 -5
- package/dist/cjs/src/hitbtc.js +56 -69
- package/dist/cjs/src/hyperliquid.js +2 -2
- package/dist/cjs/src/kraken.js +29 -24
- package/dist/cjs/src/kucoinfutures.js +6 -0
- package/dist/cjs/src/lbank.js +1 -1
- package/dist/cjs/src/paradex.js +119 -3
- package/dist/cjs/src/pro/binance.js +31 -33
- package/dist/cjs/src/pro/bithumb.js +5 -3
- package/dist/cjs/src/pro/kraken.js +289 -79
- package/dist/cjs/src/pro/mexc.js +302 -8
- package/dist/cjs/src/pro/poloniex.js +6 -2
- package/examples/js/cli.js +127 -13
- package/js/ccxt.d.ts +2 -11
- package/js/ccxt.js +2 -8
- package/js/src/abstract/blofin.d.ts +8 -0
- package/js/src/abstract/btcbox.d.ts +1 -0
- package/js/src/apex.js +2 -1
- package/js/src/base/Exchange.d.ts +15 -1
- package/js/src/base/Exchange.js +15 -2
- package/js/src/base/types.d.ts +3 -0
- package/js/src/bitget.js +1 -3
- package/js/src/bitrue.js +14 -35
- package/js/src/bitso.js +33 -0
- package/js/src/bitstamp.js +33 -0
- package/js/src/blofin.d.ts +42 -2
- package/js/src/blofin.js +154 -13
- package/js/src/btcbox.js +25 -5
- package/js/src/bybit.js +16 -40
- package/js/src/cex.js +2 -4
- package/js/src/coinbase.js +56 -40
- package/js/src/coinbaseexchange.js +142 -32
- package/js/src/coincatch.js +14 -67
- package/js/src/coinex.js +28 -29
- package/js/src/coinlist.js +16 -15
- package/js/src/coinmetro.js +22 -11
- package/js/src/coinone.js +8 -10
- package/js/src/coinsph.d.ts +10 -1
- package/js/src/coinsph.js +126 -1
- package/js/src/cryptocom.d.ts +10 -1
- package/js/src/cryptocom.js +111 -1
- package/js/src/cryptomus.js +43 -89
- package/js/src/delta.js +76 -36
- package/js/src/derive.js +46 -10
- package/js/src/ellipx.d.ts +2 -3
- package/js/src/ellipx.js +175 -80
- package/js/src/gate.js +1 -1
- package/js/src/gemini.js +3 -5
- package/js/src/hitbtc.js +56 -69
- package/js/src/hyperliquid.js +2 -2
- package/js/src/kraken.js +29 -24
- package/js/src/kucoinfutures.d.ts +1 -0
- package/js/src/kucoinfutures.js +6 -0
- package/js/src/lbank.js +1 -1
- package/js/src/paradex.d.ts +12 -1
- package/js/src/paradex.js +119 -3
- package/js/src/pro/binance.d.ts +26 -26
- package/js/src/pro/binance.js +31 -33
- package/js/src/pro/bithumb.js +5 -3
- package/js/src/pro/kraken.d.ts +7 -6
- package/js/src/pro/kraken.js +290 -80
- package/js/src/pro/mexc.d.ts +58 -0
- package/js/src/pro/mexc.js +302 -8
- package/js/src/pro/poloniex.d.ts +1 -1
- package/js/src/pro/poloniex.js +6 -2
- package/package.json +1 -1
- package/js/src/abstract/bl3p.d.ts +0 -22
- package/js/src/abstract/bl3p.js +0 -11
- package/js/src/abstract/idex.d.ts +0 -29
- package/js/src/abstract/idex.js +0 -11
- package/js/src/bl3p.d.ts +0 -116
- package/js/src/bl3p.js +0 -552
- package/js/src/idex.d.ts +0 -312
- package/js/src/idex.js +0 -1961
- package/js/src/pro/idex.d.ts +0 -81
- package/js/src/pro/idex.js +0 -720
package/dist/cjs/src/blofin.js
CHANGED
|
@@ -48,6 +48,7 @@ class blofin extends blofin$1 {
|
|
|
48
48
|
'createStopMarketOrder': false,
|
|
49
49
|
'createStopOrder': false,
|
|
50
50
|
'createTakeProfitOrder': true,
|
|
51
|
+
'createTriggerOrder': true,
|
|
51
52
|
'editOrder': false,
|
|
52
53
|
'fetchAccounts': false,
|
|
53
54
|
'fetchBalance': true,
|
|
@@ -101,6 +102,7 @@ class blofin extends blofin$1 {
|
|
|
101
102
|
'fetchOrders': false,
|
|
102
103
|
'fetchOrderTrades': true,
|
|
103
104
|
'fetchPosition': true,
|
|
105
|
+
'fetchPositionMode': true,
|
|
104
106
|
'fetchPositions': true,
|
|
105
107
|
'fetchPositionsForSymbol': false,
|
|
106
108
|
'fetchPositionsRisk': false,
|
|
@@ -128,8 +130,8 @@ class blofin extends blofin$1 {
|
|
|
128
130
|
'repayCrossMargin': false,
|
|
129
131
|
'setLeverage': true,
|
|
130
132
|
'setMargin': false,
|
|
131
|
-
'setMarginMode':
|
|
132
|
-
'setPositionMode':
|
|
133
|
+
'setMarginMode': true,
|
|
134
|
+
'setPositionMode': true,
|
|
133
135
|
'signIn': false,
|
|
134
136
|
'transfer': true,
|
|
135
137
|
'withdraw': false,
|
|
@@ -192,10 +194,14 @@ class blofin extends blofin$1 {
|
|
|
192
194
|
'account/positions': 1,
|
|
193
195
|
'account/leverage-info': 1,
|
|
194
196
|
'account/margin-mode': 1,
|
|
197
|
+
'account/position-mode': 1,
|
|
195
198
|
'account/batch-leverage-info': 1,
|
|
196
199
|
'trade/orders-tpsl-pending': 1,
|
|
200
|
+
'trade/orders-algo-pending': 1,
|
|
197
201
|
'trade/orders-history': 1,
|
|
198
202
|
'trade/orders-tpsl-history': 1,
|
|
203
|
+
'trade/orders-algo-history': 1,
|
|
204
|
+
'trade/order/price-range': 1,
|
|
199
205
|
'user/query-apikey': 1,
|
|
200
206
|
'affiliate/basic': 1,
|
|
201
207
|
'copytrading/instruments': 1,
|
|
@@ -212,8 +218,12 @@ class blofin extends blofin$1 {
|
|
|
212
218
|
'copytrading/trade/pending-tpsl-by-order': 1,
|
|
213
219
|
},
|
|
214
220
|
'post': {
|
|
221
|
+
'account/set-margin-mode': 1,
|
|
222
|
+
'account/set-position-mode': 1,
|
|
215
223
|
'trade/order': 1,
|
|
224
|
+
'trade/order-algo': 1,
|
|
216
225
|
'trade/cancel-order': 1,
|
|
226
|
+
'trade/cancel-algo': 1,
|
|
217
227
|
'account/set-leverage': 1,
|
|
218
228
|
'trade/batch-orders': 1,
|
|
219
229
|
'trade/order-tpsl': 1,
|
|
@@ -1148,7 +1158,12 @@ class blofin extends blofin$1 {
|
|
|
1148
1158
|
let marginMode = undefined;
|
|
1149
1159
|
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params, 'cross');
|
|
1150
1160
|
request['marginMode'] = marginMode;
|
|
1161
|
+
const triggerPrice = this.safeString(params, 'triggerPrice');
|
|
1151
1162
|
const timeInForce = this.safeString(params, 'timeInForce', 'GTC');
|
|
1163
|
+
const isHedged = this.safeBool(params, 'hedged', false);
|
|
1164
|
+
if (isHedged) {
|
|
1165
|
+
request['positionSide'] = (side === 'buy') ? 'long' : 'short';
|
|
1166
|
+
}
|
|
1152
1167
|
const isMarketOrder = type === 'market';
|
|
1153
1168
|
params = this.omit(params, ['timeInForce']);
|
|
1154
1169
|
const ioc = (timeInForce === 'IOC') || (type === 'ioc');
|
|
@@ -1157,7 +1172,8 @@ class blofin extends blofin$1 {
|
|
|
1157
1172
|
request['orderType'] = 'market';
|
|
1158
1173
|
}
|
|
1159
1174
|
else {
|
|
1160
|
-
|
|
1175
|
+
const key = (triggerPrice !== undefined) ? 'orderPrice' : 'price';
|
|
1176
|
+
request[key] = this.priceToPrecision(symbol, price);
|
|
1161
1177
|
}
|
|
1162
1178
|
let postOnly = false;
|
|
1163
1179
|
[postOnly, params] = this.handlePostOnly(isMarketOrder, type === 'post_only', params);
|
|
@@ -1166,7 +1182,7 @@ class blofin extends blofin$1 {
|
|
|
1166
1182
|
}
|
|
1167
1183
|
const stopLoss = this.safeDict(params, 'stopLoss');
|
|
1168
1184
|
const takeProfit = this.safeDict(params, 'takeProfit');
|
|
1169
|
-
params = this.omit(params, ['stopLoss', 'takeProfit']);
|
|
1185
|
+
params = this.omit(params, ['stopLoss', 'takeProfit', 'hedged']);
|
|
1170
1186
|
const isStopLoss = stopLoss !== undefined;
|
|
1171
1187
|
const isTakeProfit = takeProfit !== undefined;
|
|
1172
1188
|
if (isStopLoss || isTakeProfit) {
|
|
@@ -1183,6 +1199,13 @@ class blofin extends blofin$1 {
|
|
|
1183
1199
|
request['tpOrderPrice'] = this.priceToPrecision(symbol, tpPrice);
|
|
1184
1200
|
}
|
|
1185
1201
|
}
|
|
1202
|
+
else if (triggerPrice !== undefined) {
|
|
1203
|
+
request['orderType'] = 'trigger';
|
|
1204
|
+
request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
1205
|
+
if (isMarketOrder) {
|
|
1206
|
+
request['orderPrice'] = '-1';
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1186
1209
|
return this.extend(request, params);
|
|
1187
1210
|
}
|
|
1188
1211
|
parseOrderStatus(status) {
|
|
@@ -1232,7 +1255,7 @@ class blofin extends blofin$1 {
|
|
|
1232
1255
|
// "instType": "SWAP", // only in WS
|
|
1233
1256
|
// }
|
|
1234
1257
|
//
|
|
1235
|
-
const id = this.
|
|
1258
|
+
const id = this.safeStringN(order, ['tpslId', 'orderId', 'algoId']);
|
|
1236
1259
|
const timestamp = this.safeInteger(order, 'createTime');
|
|
1237
1260
|
const lastUpdateTimestamp = this.safeInteger(order, 'updateTime');
|
|
1238
1261
|
const lastTradeTimestamp = this.safeInteger(order, 'fillTime');
|
|
@@ -1331,12 +1354,14 @@ class blofin extends blofin$1 {
|
|
|
1331
1354
|
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
1332
1355
|
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
1333
1356
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1357
|
+
* @param {string} [params.triggerPrice] the trigger price for a trigger order
|
|
1334
1358
|
* @param {bool} [params.reduceOnly] a mark to reduce the position size for margin, swap and future orders
|
|
1335
1359
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
1336
1360
|
* @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
|
|
1337
1361
|
* @param {float} [params.stopLossPrice] stop loss trigger price (will use privatePostTradeOrderTpsl)
|
|
1338
1362
|
* @param {float} [params.takeProfitPrice] take profit trigger price (will use privatePostTradeOrderTpsl)
|
|
1339
1363
|
* @param {string} [params.positionSide] *stopLossPrice/takeProfitPrice orders only* 'long' or 'short' or 'net' default is 'net'
|
|
1364
|
+
* @param {boolean} [params.hedged] if true, the positionSide will be set to long/short instead of net, default is false
|
|
1340
1365
|
* @param {string} [params.clientOrderId] a unique id for the order
|
|
1341
1366
|
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered
|
|
1342
1367
|
* @param {float} [params.takeProfit.triggerPrice] take profit trigger price
|
|
@@ -1355,16 +1380,30 @@ class blofin extends blofin$1 {
|
|
|
1355
1380
|
[method, params] = this.handleOptionAndParams(params, 'createOrder', 'method', 'privatePostTradeOrder');
|
|
1356
1381
|
const isStopLossPriceDefined = this.safeString(params, 'stopLossPrice') !== undefined;
|
|
1357
1382
|
const isTakeProfitPriceDefined = this.safeString(params, 'takeProfitPrice') !== undefined;
|
|
1383
|
+
const isTriggerOrder = this.safeString(params, 'triggerPrice') !== undefined;
|
|
1358
1384
|
const isType2Order = (isStopLossPriceDefined || isTakeProfitPriceDefined);
|
|
1359
1385
|
let response = undefined;
|
|
1386
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly');
|
|
1387
|
+
if (reduceOnly !== undefined) {
|
|
1388
|
+
params['reduceOnly'] = reduceOnly ? 'true' : 'false';
|
|
1389
|
+
}
|
|
1360
1390
|
if (tpsl || (method === 'privatePostTradeOrderTpsl') || isType2Order) {
|
|
1361
1391
|
const tpslRequest = this.createTpslOrderRequest(symbol, type, side, amount, price, params);
|
|
1362
1392
|
response = await this.privatePostTradeOrderTpsl(tpslRequest);
|
|
1363
1393
|
}
|
|
1394
|
+
else if (isTriggerOrder || (method === 'privatePostTradeOrderAlgo')) {
|
|
1395
|
+
const triggerRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1396
|
+
response = await this.privatePostTradeOrderAlgo(triggerRequest);
|
|
1397
|
+
}
|
|
1364
1398
|
else {
|
|
1365
1399
|
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
1366
1400
|
response = await this.privatePostTradeOrder(request);
|
|
1367
1401
|
}
|
|
1402
|
+
if (isTriggerOrder || (method === 'privatePostTradeOrderAlgo')) {
|
|
1403
|
+
const dataDict = this.safeDict(response, 'data', {});
|
|
1404
|
+
const triggerOrder = this.parseOrder(dataDict, market);
|
|
1405
|
+
return triggerOrder;
|
|
1406
|
+
}
|
|
1368
1407
|
const data = this.safeList(response, 'data', []);
|
|
1369
1408
|
const first = this.safeDict(data, 0);
|
|
1370
1409
|
const order = this.parseOrder(first, market);
|
|
@@ -1421,7 +1460,8 @@ class blofin extends blofin$1 {
|
|
|
1421
1460
|
* @param {string} id order id
|
|
1422
1461
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
1423
1462
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1424
|
-
* @param {boolean} [params.trigger] True if cancelling a trigger/conditional
|
|
1463
|
+
* @param {boolean} [params.trigger] True if cancelling a trigger/conditional
|
|
1464
|
+
* @param {boolean} [params.tpsl] True if cancelling a tpsl order
|
|
1425
1465
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1426
1466
|
*/
|
|
1427
1467
|
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
@@ -1433,25 +1473,34 @@ class blofin extends blofin$1 {
|
|
|
1433
1473
|
const request = {
|
|
1434
1474
|
'instId': market['id'],
|
|
1435
1475
|
};
|
|
1436
|
-
const isTrigger = this.safeBoolN(params, ['
|
|
1476
|
+
const isTrigger = this.safeBoolN(params, ['trigger'], false);
|
|
1477
|
+
const isTpsl = this.safeBool2(params, 'tpsl', 'TPSL', false);
|
|
1437
1478
|
const clientOrderId = this.safeString(params, 'clientOrderId');
|
|
1438
1479
|
if (clientOrderId !== undefined) {
|
|
1439
1480
|
request['clientOrderId'] = clientOrderId;
|
|
1440
1481
|
}
|
|
1441
1482
|
else {
|
|
1442
|
-
if (!isTrigger) {
|
|
1483
|
+
if (!isTrigger && !isTpsl) {
|
|
1443
1484
|
request['orderId'] = id.toString();
|
|
1444
1485
|
}
|
|
1445
|
-
else {
|
|
1486
|
+
else if (isTpsl) {
|
|
1446
1487
|
request['tpslId'] = id.toString();
|
|
1447
1488
|
}
|
|
1489
|
+
else if (isTrigger) {
|
|
1490
|
+
request['algoId'] = id.toString();
|
|
1491
|
+
}
|
|
1448
1492
|
}
|
|
1449
1493
|
const query = this.omit(params, ['orderId', 'clientOrderId', 'stop', 'trigger', 'tpsl']);
|
|
1450
|
-
if (
|
|
1494
|
+
if (isTpsl) {
|
|
1451
1495
|
const tpslResponse = await this.cancelOrders([id], symbol, params);
|
|
1452
1496
|
const first = this.safeDict(tpslResponse, 0);
|
|
1453
1497
|
return first;
|
|
1454
1498
|
}
|
|
1499
|
+
else if (isTrigger) {
|
|
1500
|
+
const triggerResponse = await this.privatePostTradeCancelAlgo(this.extend(request, query));
|
|
1501
|
+
const triggerData = this.safeDict(triggerResponse, 'data');
|
|
1502
|
+
return this.parseOrder(triggerData, market);
|
|
1503
|
+
}
|
|
1455
1504
|
const response = await this.privatePostTradeCancelOrder(this.extend(request, query));
|
|
1456
1505
|
const data = this.safeList(response, 'data', []);
|
|
1457
1506
|
const order = this.safeDict(data, 0);
|
|
@@ -1491,6 +1540,7 @@ class blofin extends blofin$1 {
|
|
|
1491
1540
|
* @description Fetch orders that are still open
|
|
1492
1541
|
* @see https://blofin.com/docs#get-active-orders
|
|
1493
1542
|
* @see https://blofin.com/docs#get-active-tpsl-orders
|
|
1543
|
+
* @see https://docs.blofin.com/index.html#get-active-algo-orders
|
|
1494
1544
|
* @param {string} symbol unified market symbol
|
|
1495
1545
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1496
1546
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
@@ -1515,14 +1565,19 @@ class blofin extends blofin$1 {
|
|
|
1515
1565
|
if (limit !== undefined) {
|
|
1516
1566
|
request['limit'] = limit; // default 100, max 100
|
|
1517
1567
|
}
|
|
1518
|
-
const isTrigger = this.safeBoolN(params, ['stop', 'trigger'
|
|
1568
|
+
const isTrigger = this.safeBoolN(params, ['stop', 'trigger'], false);
|
|
1569
|
+
const isTpSl = this.safeBool2(params, 'tpsl', 'TPSL', false);
|
|
1519
1570
|
let method = undefined;
|
|
1520
1571
|
[method, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'method', 'privateGetTradeOrdersPending');
|
|
1521
1572
|
const query = this.omit(params, ['method', 'stop', 'trigger', 'tpsl', 'TPSL']);
|
|
1522
1573
|
let response = undefined;
|
|
1523
|
-
if (
|
|
1574
|
+
if (isTpSl || (method === 'privateGetTradeOrdersTpslPending')) {
|
|
1524
1575
|
response = await this.privateGetTradeOrdersTpslPending(this.extend(request, query));
|
|
1525
1576
|
}
|
|
1577
|
+
else if (isTrigger || (method === 'privateGetTradeOrdersAlgoPending')) {
|
|
1578
|
+
request['orderType'] = 'trigger';
|
|
1579
|
+
response = await this.privateGetTradeOrdersAlgoPending(this.extend(request, query));
|
|
1580
|
+
}
|
|
1526
1581
|
else {
|
|
1527
1582
|
response = await this.privateGetTradeOrdersPending(this.extend(request, query));
|
|
1528
1583
|
}
|
|
@@ -2210,6 +2265,7 @@ class blofin extends blofin$1 {
|
|
|
2210
2265
|
* @param {string} symbol unified market symbol
|
|
2211
2266
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2212
2267
|
* @param {string} [params.marginMode] 'cross' or 'isolated'
|
|
2268
|
+
* @param {string} [params.positionSide] 'long' or 'short' - required for hedged mode in isolated margin
|
|
2213
2269
|
* @returns {object} response from the exchange
|
|
2214
2270
|
*/
|
|
2215
2271
|
async setLeverage(leverage, symbol = undefined, params = {}) {
|
|
@@ -2344,10 +2400,95 @@ class blofin extends blofin$1 {
|
|
|
2344
2400
|
parseMarginMode(marginMode, market = undefined) {
|
|
2345
2401
|
return {
|
|
2346
2402
|
'info': marginMode,
|
|
2347
|
-
'symbol': market
|
|
2403
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
2348
2404
|
'marginMode': this.safeString(marginMode, 'marginMode'),
|
|
2349
2405
|
};
|
|
2350
2406
|
}
|
|
2407
|
+
/**
|
|
2408
|
+
* @method
|
|
2409
|
+
* @name blofin#setMarginMode
|
|
2410
|
+
* @description set margin mode to 'cross' or 'isolated'
|
|
2411
|
+
* @see https://docs.blofin.com/index.html#set-margin-mode
|
|
2412
|
+
* @param {string} marginMode 'cross' or 'isolated'
|
|
2413
|
+
* @param {string} [symbol] unified market symbol (not used in blofin setMarginMode)
|
|
2414
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2415
|
+
* @returns {object} response from the exchange
|
|
2416
|
+
*/
|
|
2417
|
+
async setMarginMode(marginMode, symbol = undefined, params = {}) {
|
|
2418
|
+
this.checkRequiredArgument('setMarginMode', marginMode, 'marginMode', ['cross', 'isolated']);
|
|
2419
|
+
await this.loadMarkets();
|
|
2420
|
+
let market = undefined;
|
|
2421
|
+
if (symbol !== undefined) {
|
|
2422
|
+
market = this.market(symbol);
|
|
2423
|
+
}
|
|
2424
|
+
const request = {
|
|
2425
|
+
'marginMode': marginMode,
|
|
2426
|
+
};
|
|
2427
|
+
const response = await this.privatePostAccountSetMarginMode(this.extend(request, params));
|
|
2428
|
+
//
|
|
2429
|
+
// {
|
|
2430
|
+
// "code": "0",
|
|
2431
|
+
// "msg": "success",
|
|
2432
|
+
// "data": {
|
|
2433
|
+
// "marginMode": "isolated"
|
|
2434
|
+
// }
|
|
2435
|
+
// }
|
|
2436
|
+
//
|
|
2437
|
+
const data = this.safeDict(response, 'data', {});
|
|
2438
|
+
return this.parseMarginMode(data, market);
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* @method
|
|
2442
|
+
* @name blofin#fetchPositionMode
|
|
2443
|
+
* @description fetchs the position mode, hedged or one way
|
|
2444
|
+
* @see https://docs.blofin.com/index.html#get-position-mode
|
|
2445
|
+
* @param {string} [symbol] unified symbol of the market to fetch the position mode for (not used in blofin fetchPositionMode)
|
|
2446
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2447
|
+
* @returns {object} an object detailing whether the market is in hedged or one-way mode
|
|
2448
|
+
*/
|
|
2449
|
+
async fetchPositionMode(symbol = undefined, params = {}) {
|
|
2450
|
+
const response = await this.privateGetAccountPositionMode(params);
|
|
2451
|
+
const data = this.safeDict(response, 'data', {});
|
|
2452
|
+
const positionMode = this.safeString(data, 'positionMode');
|
|
2453
|
+
//
|
|
2454
|
+
// {
|
|
2455
|
+
// "code": "0",
|
|
2456
|
+
// "msg": "success",
|
|
2457
|
+
// "data": {
|
|
2458
|
+
// "positionMode": "long_short_mode"
|
|
2459
|
+
// }
|
|
2460
|
+
// }
|
|
2461
|
+
//
|
|
2462
|
+
return {
|
|
2463
|
+
'info': data,
|
|
2464
|
+
'hedged': positionMode === 'long_short_mode',
|
|
2465
|
+
};
|
|
2466
|
+
}
|
|
2467
|
+
/**
|
|
2468
|
+
* @method
|
|
2469
|
+
* @name blofin#setPositionMode
|
|
2470
|
+
* @description set hedged to true or false for a market
|
|
2471
|
+
* @see https://docs.blofin.com/index.html#set-position-mode
|
|
2472
|
+
* @param {bool} hedged set to true to use hedged mode, false for one-way mode
|
|
2473
|
+
* @param {string} [symbol] not used by blofin setPositionMode ()
|
|
2474
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2475
|
+
* @returns {object} response from the exchange
|
|
2476
|
+
*/
|
|
2477
|
+
async setPositionMode(hedged, symbol = undefined, params = {}) {
|
|
2478
|
+
const request = {
|
|
2479
|
+
'positionMode': hedged ? 'long_short_mode' : 'net_mode',
|
|
2480
|
+
};
|
|
2481
|
+
//
|
|
2482
|
+
// {
|
|
2483
|
+
// "code": "0",
|
|
2484
|
+
// "msg": "success",
|
|
2485
|
+
// "data": {
|
|
2486
|
+
// "positionMode": "net_mode"
|
|
2487
|
+
// }
|
|
2488
|
+
// }
|
|
2489
|
+
//
|
|
2490
|
+
return await this.privatePostAccountSetPositionMode(this.extend(request, params));
|
|
2491
|
+
}
|
|
2351
2492
|
handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
2352
2493
|
if (response === undefined) {
|
|
2353
2494
|
return undefined; // fallback to default error handler
|
package/dist/cjs/src/btcbox.js
CHANGED
|
@@ -106,6 +106,18 @@ class btcbox extends btcbox$1 {
|
|
|
106
106
|
'wallet',
|
|
107
107
|
],
|
|
108
108
|
},
|
|
109
|
+
'webApi': {
|
|
110
|
+
'get': [
|
|
111
|
+
'ajax/coin/coinInfo',
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
'options': {
|
|
116
|
+
'fetchMarkets': {
|
|
117
|
+
'webApiEnable': true,
|
|
118
|
+
'webApiRetries': 3,
|
|
119
|
+
},
|
|
120
|
+
'amountPrecision': '0.0001', // exchange has only few pairs and all of them
|
|
109
121
|
},
|
|
110
122
|
'features': {
|
|
111
123
|
'spot': {
|
|
@@ -191,9 +203,12 @@ class btcbox extends btcbox$1 {
|
|
|
191
203
|
* @returns {object[]} an array of objects representing market data
|
|
192
204
|
*/
|
|
193
205
|
async fetchMarkets(params = {}) {
|
|
194
|
-
const
|
|
206
|
+
const promise1 = this.publicGetTickers();
|
|
207
|
+
const promise2 = this.fetchWebEndpoint('fetchMarkets', 'webApiGetAjaxCoinCoinInfo', true);
|
|
208
|
+
const [response1, response2] = await Promise.all([promise1, promise2]);
|
|
195
209
|
//
|
|
196
|
-
const
|
|
210
|
+
const result2Data = this.safeDict(response2, 'data', {});
|
|
211
|
+
const marketIds = Object.keys(response1);
|
|
197
212
|
const markets = [];
|
|
198
213
|
for (let i = 0; i < marketIds.length; i++) {
|
|
199
214
|
const marketId = marketIds[i];
|
|
@@ -202,9 +217,11 @@ class btcbox extends btcbox$1 {
|
|
|
202
217
|
const quote = this.safeString(symbolParts, 1);
|
|
203
218
|
const quoteId = quote.toLowerCase();
|
|
204
219
|
const id = baseCurr.toLowerCase();
|
|
205
|
-
const res =
|
|
220
|
+
const res = response1[marketId];
|
|
206
221
|
const symbol = baseCurr + '/' + quote;
|
|
207
222
|
const fee = (id === 'BTC') ? this.parseNumber('0.0005') : this.parseNumber('0.0010');
|
|
223
|
+
const details = this.safeDict(result2Data, id, {});
|
|
224
|
+
const tradeDetails = this.safeDict(details, 'trade', {});
|
|
208
225
|
markets.push(this.safeMarketStructure({
|
|
209
226
|
'id': id,
|
|
210
227
|
'uppercaseId': undefined,
|
|
@@ -250,10 +267,10 @@ class btcbox extends btcbox$1 {
|
|
|
250
267
|
},
|
|
251
268
|
},
|
|
252
269
|
'precision': {
|
|
253
|
-
'price':
|
|
270
|
+
'price': this.parseNumber(this.parsePrecision(this.safeString(tradeDetails, 'pricedecimal'))),
|
|
254
271
|
'amount': undefined,
|
|
255
272
|
},
|
|
256
|
-
'active':
|
|
273
|
+
'active': this.safeString(tradeDetails, 'enable') === '1',
|
|
257
274
|
'created': undefined,
|
|
258
275
|
'info': res,
|
|
259
276
|
}));
|
|
@@ -727,6 +744,9 @@ class btcbox extends btcbox$1 {
|
|
|
727
744
|
url += '?' + this.urlencode(params);
|
|
728
745
|
}
|
|
729
746
|
}
|
|
747
|
+
else if (api === 'webApi') {
|
|
748
|
+
url = this.urls['www'] + '/' + path;
|
|
749
|
+
}
|
|
730
750
|
else {
|
|
731
751
|
this.checkRequiredCredentials();
|
|
732
752
|
const nonce = this.nonce().toString();
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -1640,82 +1640,58 @@ class bybit extends bybit$1 {
|
|
|
1640
1640
|
const name = this.safeString(currency, 'name');
|
|
1641
1641
|
const chains = this.safeList(currency, 'chains', []);
|
|
1642
1642
|
const networks = {};
|
|
1643
|
-
let minPrecision = undefined;
|
|
1644
|
-
let minWithdrawFeeString = undefined;
|
|
1645
|
-
let minWithdrawString = undefined;
|
|
1646
|
-
let minDepositString = undefined;
|
|
1647
|
-
let deposit = false;
|
|
1648
|
-
let withdraw = false;
|
|
1649
1643
|
for (let j = 0; j < chains.length; j++) {
|
|
1650
1644
|
const chain = chains[j];
|
|
1651
1645
|
const networkId = this.safeString(chain, 'chain');
|
|
1652
1646
|
const networkCode = this.networkIdToCode(networkId);
|
|
1653
|
-
const precision = this.parseNumber(this.parsePrecision(this.safeString(chain, 'minAccuracy')));
|
|
1654
|
-
minPrecision = (minPrecision === undefined) ? precision : Math.min(minPrecision, precision);
|
|
1655
|
-
const depositAllowed = this.safeInteger(chain, 'chainDeposit') === 1;
|
|
1656
|
-
deposit = (depositAllowed) ? depositAllowed : deposit;
|
|
1657
|
-
const withdrawAllowed = this.safeInteger(chain, 'chainWithdraw') === 1;
|
|
1658
|
-
withdraw = (withdrawAllowed) ? withdrawAllowed : withdraw;
|
|
1659
|
-
const withdrawFeeString = this.safeString(chain, 'withdrawFee');
|
|
1660
|
-
if (withdrawFeeString !== undefined) {
|
|
1661
|
-
minWithdrawFeeString = (minWithdrawFeeString === undefined) ? withdrawFeeString : Precise["default"].stringMin(withdrawFeeString, minWithdrawFeeString);
|
|
1662
|
-
}
|
|
1663
|
-
const minNetworkWithdrawString = this.safeString(chain, 'withdrawMin');
|
|
1664
|
-
if (minNetworkWithdrawString !== undefined) {
|
|
1665
|
-
minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : Precise["default"].stringMin(minNetworkWithdrawString, minWithdrawString);
|
|
1666
|
-
}
|
|
1667
|
-
const minNetworkDepositString = this.safeString(chain, 'depositMin');
|
|
1668
|
-
if (minNetworkDepositString !== undefined) {
|
|
1669
|
-
minDepositString = (minDepositString === undefined) ? minNetworkDepositString : Precise["default"].stringMin(minNetworkDepositString, minDepositString);
|
|
1670
|
-
}
|
|
1671
1647
|
networks[networkCode] = {
|
|
1672
1648
|
'info': chain,
|
|
1673
1649
|
'id': networkId,
|
|
1674
1650
|
'network': networkCode,
|
|
1675
|
-
'active':
|
|
1676
|
-
'deposit':
|
|
1677
|
-
'withdraw':
|
|
1678
|
-
'fee': this.
|
|
1679
|
-
'precision':
|
|
1651
|
+
'active': undefined,
|
|
1652
|
+
'deposit': this.safeInteger(chain, 'chainDeposit') === 1,
|
|
1653
|
+
'withdraw': this.safeInteger(chain, 'chainWithdraw') === 1,
|
|
1654
|
+
'fee': this.safeNumber(chain, 'withdrawFee'),
|
|
1655
|
+
'precision': this.parseNumber(this.parsePrecision(this.safeString(chain, 'minAccuracy'))),
|
|
1680
1656
|
'limits': {
|
|
1681
1657
|
'withdraw': {
|
|
1682
|
-
'min': this.
|
|
1658
|
+
'min': this.safeNumber(chain, 'withdrawMin'),
|
|
1683
1659
|
'max': undefined,
|
|
1684
1660
|
},
|
|
1685
1661
|
'deposit': {
|
|
1686
|
-
'min': this.
|
|
1662
|
+
'min': this.safeNumber(chain, 'depositMin'),
|
|
1687
1663
|
'max': undefined,
|
|
1688
1664
|
},
|
|
1689
1665
|
},
|
|
1690
1666
|
};
|
|
1691
1667
|
}
|
|
1692
|
-
result[code] = {
|
|
1668
|
+
result[code] = this.safeCurrencyStructure({
|
|
1693
1669
|
'info': currency,
|
|
1694
1670
|
'code': code,
|
|
1695
1671
|
'id': currencyId,
|
|
1696
1672
|
'name': name,
|
|
1697
|
-
'active':
|
|
1698
|
-
'deposit':
|
|
1699
|
-
'withdraw':
|
|
1700
|
-
'fee':
|
|
1701
|
-
'precision':
|
|
1673
|
+
'active': undefined,
|
|
1674
|
+
'deposit': undefined,
|
|
1675
|
+
'withdraw': undefined,
|
|
1676
|
+
'fee': undefined,
|
|
1677
|
+
'precision': undefined,
|
|
1702
1678
|
'limits': {
|
|
1703
1679
|
'amount': {
|
|
1704
1680
|
'min': undefined,
|
|
1705
1681
|
'max': undefined,
|
|
1706
1682
|
},
|
|
1707
1683
|
'withdraw': {
|
|
1708
|
-
'min':
|
|
1684
|
+
'min': undefined,
|
|
1709
1685
|
'max': undefined,
|
|
1710
1686
|
},
|
|
1711
1687
|
'deposit': {
|
|
1712
|
-
'min':
|
|
1688
|
+
'min': undefined,
|
|
1713
1689
|
'max': undefined,
|
|
1714
1690
|
},
|
|
1715
1691
|
},
|
|
1716
1692
|
'networks': networks,
|
|
1717
1693
|
'type': 'crypto', // atm exchange api provides only cryptos
|
|
1718
|
-
};
|
|
1694
|
+
});
|
|
1719
1695
|
}
|
|
1720
1696
|
return result;
|
|
1721
1697
|
}
|
package/dist/cjs/src/cex.js
CHANGED
|
@@ -302,8 +302,6 @@ class cex extends cex$1 {
|
|
|
302
302
|
const id = this.safeString(rawCurrency, 'currency');
|
|
303
303
|
const code = this.safeCurrencyCode(id);
|
|
304
304
|
const type = this.safeBool(rawCurrency, 'fiat') ? 'fiat' : 'crypto';
|
|
305
|
-
const currencyDepositEnabled = this.safeBool(rawCurrency, 'walletDeposit');
|
|
306
|
-
const currencyWithdrawEnabled = this.safeBool(rawCurrency, 'walletWithdrawal');
|
|
307
305
|
const currencyPrecision = this.parseNumber(this.parsePrecision(this.safeString(rawCurrency, 'precision')));
|
|
308
306
|
const networks = {};
|
|
309
307
|
const rawNetworks = this.safeDict(rawCurrency, 'blockchains', {});
|
|
@@ -342,8 +340,8 @@ class cex extends cex$1 {
|
|
|
342
340
|
'name': undefined,
|
|
343
341
|
'type': type,
|
|
344
342
|
'active': undefined,
|
|
345
|
-
'deposit':
|
|
346
|
-
'withdraw':
|
|
343
|
+
'deposit': this.safeBool(rawCurrency, 'walletDeposit'),
|
|
344
|
+
'withdraw': this.safeBool(rawCurrency, 'walletWithdrawal'),
|
|
347
345
|
'fee': undefined,
|
|
348
346
|
'precision': currencyPrecision,
|
|
349
347
|
'limits': {
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -1874,45 +1874,46 @@ class coinbase extends coinbase$1 {
|
|
|
1874
1874
|
* @returns {object} an associative dictionary of currencies
|
|
1875
1875
|
*/
|
|
1876
1876
|
async fetchCurrencies(params = {}) {
|
|
1877
|
-
const
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
// name: 'Isle of Man Pound',
|
|
1885
|
-
// min_size: '0.01'
|
|
1886
|
-
// },
|
|
1887
|
-
//
|
|
1888
|
-
// crypto
|
|
1889
|
-
//
|
|
1890
|
-
// {
|
|
1891
|
-
// asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
|
1892
|
-
// code: 'AERO',
|
|
1893
|
-
// name: 'Aerodrome Finance',
|
|
1894
|
-
// color: '#0433FF',
|
|
1895
|
-
// sort_index: '340',
|
|
1896
|
-
// exponent: '8',
|
|
1897
|
-
// type: 'crypto',
|
|
1898
|
-
// address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
|
1899
|
-
// }
|
|
1877
|
+
const promises = [
|
|
1878
|
+
this.v2PublicGetCurrencies(params),
|
|
1879
|
+
this.v2PublicGetCurrenciesCrypto(params),
|
|
1880
|
+
this.v2PublicGetExchangeRates(params),
|
|
1881
|
+
];
|
|
1882
|
+
const promisesResult = await Promise.all(promises);
|
|
1883
|
+
const fiatResponse = this.safeDict(promisesResult, 0, {});
|
|
1900
1884
|
//
|
|
1885
|
+
// [
|
|
1886
|
+
// "data": [
|
|
1887
|
+
// {
|
|
1888
|
+
// id: 'IMP',
|
|
1889
|
+
// name: 'Isle of Man Pound',
|
|
1890
|
+
// min_size: '0.01'
|
|
1891
|
+
// },
|
|
1892
|
+
// ...
|
|
1901
1893
|
//
|
|
1902
|
-
|
|
1903
|
-
// "data":{
|
|
1904
|
-
// "currency":"USD",
|
|
1905
|
-
// "rates":{
|
|
1906
|
-
// "AED":"3.67",
|
|
1907
|
-
// "AFN":"78.21",
|
|
1908
|
-
// "ALL":"110.42",
|
|
1909
|
-
// "AMD":"474.18",
|
|
1910
|
-
// "ANG":"1.75",
|
|
1911
|
-
// ...
|
|
1912
|
-
// },
|
|
1913
|
-
// }
|
|
1914
|
-
// }
|
|
1894
|
+
const cryptoResponse = this.safeDict(promisesResult, 1, {});
|
|
1915
1895
|
//
|
|
1896
|
+
// [
|
|
1897
|
+
// "data": [
|
|
1898
|
+
// {
|
|
1899
|
+
// asset_id: '9476e3be-b731-47fa-82be-347fabc573d9',
|
|
1900
|
+
// code: 'AERO',
|
|
1901
|
+
// name: 'Aerodrome Finance',
|
|
1902
|
+
// color: '#0433FF',
|
|
1903
|
+
// sort_index: '340',
|
|
1904
|
+
// exponent: '8',
|
|
1905
|
+
// type: 'crypto',
|
|
1906
|
+
// address_regex: '^(?:0x)?[0-9a-fA-F]{40}$'
|
|
1907
|
+
// },
|
|
1908
|
+
// ...
|
|
1909
|
+
//
|
|
1910
|
+
const ratesResponse = this.safeDict(promisesResult, 2, {});
|
|
1911
|
+
const fiatData = this.safeList(fiatResponse, 'data', []);
|
|
1912
|
+
const cryptoData = this.safeList(cryptoResponse, 'data', []);
|
|
1913
|
+
const ratesData = this.safeDict(ratesResponse, 'data', {});
|
|
1914
|
+
const rates = this.safeDict(ratesData, 'rates', {});
|
|
1915
|
+
const ratesIds = Object.keys(rates);
|
|
1916
|
+
const currencies = this.arrayConcat(fiatData, cryptoData);
|
|
1916
1917
|
const result = {};
|
|
1917
1918
|
const networks = {};
|
|
1918
1919
|
const networksById = {};
|
|
@@ -1924,12 +1925,13 @@ class coinbase extends coinbase$1 {
|
|
|
1924
1925
|
const name = this.safeString(currency, 'name');
|
|
1925
1926
|
this.options['networks'][code] = name.toLowerCase();
|
|
1926
1927
|
this.options['networksById'][code] = name.toLowerCase();
|
|
1927
|
-
|
|
1928
|
+
const type = (assetId !== undefined) ? 'crypto' : 'fiat';
|
|
1929
|
+
result[code] = this.safeCurrencyStructure({
|
|
1928
1930
|
'info': currency,
|
|
1929
1931
|
'id': id,
|
|
1930
1932
|
'code': code,
|
|
1931
|
-
'type':
|
|
1932
|
-
'name':
|
|
1933
|
+
'type': type,
|
|
1934
|
+
'name': name,
|
|
1933
1935
|
'active': true,
|
|
1934
1936
|
'deposit': undefined,
|
|
1935
1937
|
'withdraw': undefined,
|
|
@@ -1946,13 +1948,27 @@ class coinbase extends coinbase$1 {
|
|
|
1946
1948
|
'max': undefined,
|
|
1947
1949
|
},
|
|
1948
1950
|
},
|
|
1949
|
-
};
|
|
1951
|
+
});
|
|
1950
1952
|
if (assetId !== undefined) {
|
|
1951
1953
|
const lowerCaseName = name.toLowerCase();
|
|
1952
1954
|
networks[code] = lowerCaseName;
|
|
1953
1955
|
networksById[lowerCaseName] = code;
|
|
1954
1956
|
}
|
|
1955
1957
|
}
|
|
1958
|
+
// we have to add other currencies here ( https://discord.com/channels/1220414409550336183/1220464770239430761/1372215891940479098 )
|
|
1959
|
+
for (let i = 0; i < ratesIds.length; i++) {
|
|
1960
|
+
const currencyId = ratesIds[i];
|
|
1961
|
+
const code = this.safeCurrencyCode(currencyId);
|
|
1962
|
+
if (!(code in result)) {
|
|
1963
|
+
result[code] = this.safeCurrencyStructure({
|
|
1964
|
+
'info': {},
|
|
1965
|
+
'id': currencyId,
|
|
1966
|
+
'code': code,
|
|
1967
|
+
'type': 'crypto',
|
|
1968
|
+
'networks': {}, // todo
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1956
1972
|
this.options['networks'] = this.extend(networks, this.options['networks']);
|
|
1957
1973
|
this.options['networksById'] = this.extend(networksById, this.options['networksById']);
|
|
1958
1974
|
return result;
|