ccxt 4.2.3 → 4.2.5
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 +4 -4
- package/dist/ccxt.browser.js +247 -47
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +7 -1
- package/dist/cjs/src/base/Exchange.js +5 -2
- package/dist/cjs/src/bingx.js +17 -18
- package/dist/cjs/src/bitmart.js +18 -8
- package/dist/cjs/src/bybit.js +4 -0
- package/dist/cjs/src/coinsph.js +20 -2
- package/dist/cjs/src/delta.js +2 -2
- package/dist/cjs/src/htx.js +166 -12
- package/dist/cjs/src/okx.js +5 -0
- package/dist/cjs/src/phemex.js +3 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +1 -0
- package/js/src/abstract/bybit.d.ts +2 -0
- package/js/src/alpaca.js +7 -1
- package/js/src/base/Exchange.js +5 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +17 -18
- package/js/src/bitmart.js +18 -8
- package/js/src/bybit.js +4 -0
- package/js/src/coinsph.js +20 -2
- package/js/src/delta.js +2 -2
- package/js/src/htx.js +166 -12
- package/js/src/okx.js +5 -0
- package/js/src/phemex.js +3 -2
- package/package.json +1 -1
- package/skip-tests.json +4 -1
package/js/src/bingx.js
CHANGED
|
@@ -1334,18 +1334,11 @@ export default class bingx extends Exchange {
|
|
|
1334
1334
|
const close = this.safeString(ticker, 'lastPrice');
|
|
1335
1335
|
const quoteVolume = this.safeString(ticker, 'quoteVolume');
|
|
1336
1336
|
const baseVolume = this.safeString(ticker, 'volume');
|
|
1337
|
-
let percentage =
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
change = this.safeString(ticker, 'priceChange');
|
|
1343
|
-
}
|
|
1344
|
-
// let percentage = this.safeString (ticker, 'priceChangePercent');
|
|
1345
|
-
// if (percentage !== undefined) {
|
|
1346
|
-
// percentage = percentage.replace ('%', '');
|
|
1347
|
-
// } similarly to change, it's not ccxt's percentage because it does priceChange/open, and priceChange is high-low
|
|
1348
|
-
// const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
|
|
1337
|
+
let percentage = this.safeString(ticker, 'priceChangePercent');
|
|
1338
|
+
if (percentage !== undefined) {
|
|
1339
|
+
percentage = percentage.replace('%', '');
|
|
1340
|
+
}
|
|
1341
|
+
const change = this.safeString(ticker, 'priceChange');
|
|
1349
1342
|
const ts = this.safeInteger(ticker, 'closeTime');
|
|
1350
1343
|
const datetime = this.iso8601(ts);
|
|
1351
1344
|
const bid = this.safeString(ticker, 'bidPrice');
|
|
@@ -1674,6 +1667,11 @@ export default class bingx extends Exchange {
|
|
|
1674
1667
|
};
|
|
1675
1668
|
const isMarketOrder = type === 'MARKET';
|
|
1676
1669
|
const isSpot = marketType === 'spot';
|
|
1670
|
+
const exchangeClientOrderId = isSpot ? 'newClientOrderId' : 'clientOrderID';
|
|
1671
|
+
const clientOrderId = this.safeString2(params, exchangeClientOrderId, 'clientOrderId');
|
|
1672
|
+
if (clientOrderId !== undefined) {
|
|
1673
|
+
request[exchangeClientOrderId] = clientOrderId;
|
|
1674
|
+
}
|
|
1677
1675
|
const timeInForce = this.safeStringUpper(params, 'timeInForce');
|
|
1678
1676
|
if (timeInForce === 'IOC') {
|
|
1679
1677
|
request['timeInForce'] = 'IOC';
|
|
@@ -1818,7 +1816,7 @@ export default class bingx extends Exchange {
|
|
|
1818
1816
|
}
|
|
1819
1817
|
request['positionSide'] = positionSide;
|
|
1820
1818
|
request['quantity'] = this.parseToNumeric(this.amountToPrecision(symbol, amount));
|
|
1821
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss']);
|
|
1819
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingPercent', 'takeProfit', 'stopLoss', 'clientOrderId']);
|
|
1822
1820
|
}
|
|
1823
1821
|
return this.extend(request, params);
|
|
1824
1822
|
}
|
|
@@ -1835,6 +1833,7 @@ export default class bingx extends Exchange {
|
|
|
1835
1833
|
* @param {float} amount how much you want to trade in units of the base currency
|
|
1836
1834
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
1837
1835
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1836
|
+
* @param {string} [params.clientOrderId] a unique id for the order
|
|
1838
1837
|
* @param {bool} [params.postOnly] true to place a post only order
|
|
1839
1838
|
* @param {string} [params.timeInForce] spot supports 'PO' and 'IOC', swap supports 'PO', 'GTC', 'IOC' and 'FOK'
|
|
1840
1839
|
* @param {bool} [params.reduceOnly] *swap only* true or false whether the order is reduce only
|
|
@@ -1899,7 +1898,7 @@ export default class bingx extends Exchange {
|
|
|
1899
1898
|
// }
|
|
1900
1899
|
//
|
|
1901
1900
|
if (typeof response === 'string') {
|
|
1902
|
-
response =
|
|
1901
|
+
response = this.parseJson(response);
|
|
1903
1902
|
}
|
|
1904
1903
|
const data = this.safeValue(response, 'data', {});
|
|
1905
1904
|
const order = this.safeValue(data, 'order', data);
|
|
@@ -2160,7 +2159,7 @@ export default class bingx extends Exchange {
|
|
|
2160
2159
|
'currency': feeCurrencyCode,
|
|
2161
2160
|
'cost': Precise.stringAbs(feeCost),
|
|
2162
2161
|
};
|
|
2163
|
-
const clientOrderId = this.
|
|
2162
|
+
const clientOrderId = this.safeStringN(order, ['clientOrderID', 'origClientOrderId', 'c']);
|
|
2164
2163
|
let stopLoss = this.safeValue(order, 'stopLoss');
|
|
2165
2164
|
let stopLossPrice = undefined;
|
|
2166
2165
|
if (stopLoss !== undefined) {
|
|
@@ -2169,7 +2168,7 @@ export default class bingx extends Exchange {
|
|
|
2169
2168
|
if ((stopLoss !== undefined) && (typeof stopLoss !== 'number')) {
|
|
2170
2169
|
// stopLoss: '{"stopPrice":50,"workingType":"MARK_PRICE","type":"STOP_MARKET","quantity":1}',
|
|
2171
2170
|
if (typeof stopLoss === 'string') {
|
|
2172
|
-
stopLoss =
|
|
2171
|
+
stopLoss = this.parseJson(stopLoss);
|
|
2173
2172
|
}
|
|
2174
2173
|
stopLossPrice = this.safeNumber(stopLoss, 'stopPrice');
|
|
2175
2174
|
}
|
|
@@ -2181,7 +2180,7 @@ export default class bingx extends Exchange {
|
|
|
2181
2180
|
if ((takeProfit !== undefined) && (typeof takeProfit !== 'number')) {
|
|
2182
2181
|
// takeProfit: '{"stopPrice":150,"workingType":"MARK_PRICE","type":"TAKE_PROFIT_MARKET","quantity":1}',
|
|
2183
2182
|
if (typeof takeProfit === 'string') {
|
|
2184
|
-
takeProfit =
|
|
2183
|
+
takeProfit = this.parseJson(takeProfit);
|
|
2185
2184
|
}
|
|
2186
2185
|
takeProfitPrice = this.safeNumber(takeProfit, 'stopPrice');
|
|
2187
2186
|
}
|
|
@@ -2421,7 +2420,7 @@ export default class bingx extends Exchange {
|
|
|
2421
2420
|
}
|
|
2422
2421
|
let response = undefined;
|
|
2423
2422
|
if (market['spot']) {
|
|
2424
|
-
const spotReqKey = areClientOrderIds ? '
|
|
2423
|
+
const spotReqKey = areClientOrderIds ? 'clientOrderIDs' : 'orderIds';
|
|
2425
2424
|
request[spotReqKey] = parsedIds.join(',');
|
|
2426
2425
|
response = await this.spotV1PrivatePostTradeCancelOrders(this.extend(request, params));
|
|
2427
2426
|
}
|
package/js/src/bitmart.js
CHANGED
|
@@ -199,6 +199,7 @@ export default class bitmart extends Exchange {
|
|
|
199
199
|
'contract/private/order-history': 10,
|
|
200
200
|
'contract/private/position': 10,
|
|
201
201
|
'contract/private/get-open-orders': 1.2,
|
|
202
|
+
'contract/private/current-plan-order': 1.2,
|
|
202
203
|
'contract/private/trades': 10,
|
|
203
204
|
},
|
|
204
205
|
'post': {
|
|
@@ -2681,6 +2682,7 @@ export default class bitmart extends Exchange {
|
|
|
2681
2682
|
* @name bitmart#fetchOpenOrders
|
|
2682
2683
|
* @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
|
|
2683
2684
|
* @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
|
|
2685
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
|
|
2684
2686
|
* @description fetch all unfilled currently open orders
|
|
2685
2687
|
* @param {string} symbol unified market symbol
|
|
2686
2688
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
@@ -2692,6 +2694,7 @@ export default class bitmart extends Exchange {
|
|
|
2692
2694
|
* @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
|
|
2693
2695
|
* @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
|
|
2694
2696
|
* @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
|
|
2697
|
+
* @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
|
|
2695
2698
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2696
2699
|
*/
|
|
2697
2700
|
await this.loadMarkets();
|
|
@@ -2724,16 +2727,23 @@ export default class bitmart extends Exchange {
|
|
|
2724
2727
|
response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
|
|
2725
2728
|
}
|
|
2726
2729
|
else if (type === 'swap') {
|
|
2727
|
-
const
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
orderType = 'trailing';
|
|
2730
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger');
|
|
2731
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
2732
|
+
if (isStop) {
|
|
2733
|
+
response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
|
|
2732
2734
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
+
else {
|
|
2736
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
2737
|
+
let orderType = this.safeString(params, 'orderType');
|
|
2738
|
+
params = this.omit(params, ['orderType', 'trailing']);
|
|
2739
|
+
if (trailing) {
|
|
2740
|
+
orderType = 'trailing';
|
|
2741
|
+
}
|
|
2742
|
+
if (orderType !== undefined) {
|
|
2743
|
+
request['type'] = orderType;
|
|
2744
|
+
}
|
|
2745
|
+
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2735
2746
|
}
|
|
2736
|
-
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2737
2747
|
}
|
|
2738
2748
|
else {
|
|
2739
2749
|
throw new NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
|
package/js/src/bybit.js
CHANGED
|
@@ -283,6 +283,7 @@ export default class bybit extends Exchange {
|
|
|
283
283
|
'v5/position/list': 5,
|
|
284
284
|
'v5/execution/list': 5,
|
|
285
285
|
'v5/position/closed-pnl': 5,
|
|
286
|
+
'v5/position/move-history': 5,
|
|
286
287
|
// pre-upgrade
|
|
287
288
|
'v5/pre-upgrade/order/history': 5,
|
|
288
289
|
'v5/pre-upgrade/execution/list': 5,
|
|
@@ -447,6 +448,7 @@ export default class bybit extends Exchange {
|
|
|
447
448
|
'v5/position/trading-stop': 5,
|
|
448
449
|
'v5/position/set-auto-add-margin': 5,
|
|
449
450
|
'v5/position/add-margin': 5,
|
|
451
|
+
'v5/position/move-positions': 5,
|
|
450
452
|
'v5/position/confirm-pending-mmr': 5,
|
|
451
453
|
// account
|
|
452
454
|
'v5/account/upgrade-to-uta': 5,
|
|
@@ -629,6 +631,8 @@ export default class bybit extends Exchange {
|
|
|
629
631
|
'131215': BadRequest,
|
|
630
632
|
'131216': ExchangeError,
|
|
631
633
|
'131217': ExchangeError,
|
|
634
|
+
'131231': NotSupported,
|
|
635
|
+
'131232': NotSupported,
|
|
632
636
|
'131002': BadRequest,
|
|
633
637
|
'131003': ExchangeError,
|
|
634
638
|
'131004': AuthenticationError,
|
package/js/src/coinsph.js
CHANGED
|
@@ -631,7 +631,16 @@ export default class coinsph extends Exchange {
|
|
|
631
631
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
632
632
|
const options = this.safeValue(this.options, 'fetchTickers', {});
|
|
633
633
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
634
|
-
|
|
634
|
+
let tickers = undefined;
|
|
635
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
636
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
637
|
+
}
|
|
638
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
639
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
643
|
+
}
|
|
635
644
|
return this.parseTickers(tickers, symbols, params);
|
|
636
645
|
}
|
|
637
646
|
async fetchTicker(symbol, params = {}) {
|
|
@@ -651,7 +660,16 @@ export default class coinsph extends Exchange {
|
|
|
651
660
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
652
661
|
const options = this.safeValue(this.options, 'fetchTicker', {});
|
|
653
662
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
654
|
-
|
|
663
|
+
let ticker = undefined;
|
|
664
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
665
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
666
|
+
}
|
|
667
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
668
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
672
|
+
}
|
|
655
673
|
return this.parseTicker(ticker, market);
|
|
656
674
|
}
|
|
657
675
|
parseTicker(ticker, market = undefined) {
|
package/js/src/delta.js
CHANGED
|
@@ -330,14 +330,14 @@ export default class delta extends Exchange {
|
|
|
330
330
|
const markets = this.markets_by_id[symbol];
|
|
331
331
|
return markets[0];
|
|
332
332
|
}
|
|
333
|
-
else if ((symbol.
|
|
333
|
+
else if ((symbol.endsWith('-C')) || (symbol.endsWith('-P')) || (symbol.startsWith('C-')) || (symbol.startsWith('P-'))) {
|
|
334
334
|
return this.createExpiredOptionMarket(symbol);
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
337
|
throw new BadSymbol(this.id + ' does not have market symbol ' + symbol);
|
|
338
338
|
}
|
|
339
339
|
safeMarket(marketId = undefined, market = undefined, delimiter = undefined, marketType = undefined) {
|
|
340
|
-
const isOption = (marketId !== undefined) && ((marketId.
|
|
340
|
+
const isOption = (marketId !== undefined) && ((marketId.endsWith('-C')) || (marketId.endsWith('-P')) || (marketId.startsWith('C-')) || (marketId.startsWith('P-')));
|
|
341
341
|
if (isOption && !(marketId in this.markets_by_id)) {
|
|
342
342
|
// handle expired option contracts
|
|
343
343
|
return this.createExpiredOptionMarket(marketId);
|