ccxt 4.4.25 → 4.4.26
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.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/alpaca.js +257 -11
- package/dist/cjs/src/base/Exchange.js +14 -1
- package/dist/cjs/src/binance.js +2 -3
- package/dist/cjs/src/bingx.js +7 -1
- package/dist/cjs/src/bitget.js +2 -2
- package/dist/cjs/src/bitmart.js +3 -3
- package/dist/cjs/src/bybit.js +3 -14
- package/dist/cjs/src/cex.js +40 -0
- package/dist/cjs/src/coinex.js +2 -4
- package/dist/cjs/src/digifinex.js +2 -2
- package/dist/cjs/src/exmo.js +1 -0
- package/dist/cjs/src/gate.js +3 -3
- package/dist/cjs/src/htx.js +2 -3
- package/dist/cjs/src/hyperliquid.js +14 -4
- package/dist/cjs/src/kucoin.js +2 -2
- package/dist/cjs/src/okx.js +3 -2
- package/dist/cjs/src/phemex.js +4 -2
- package/dist/cjs/src/pro/exmo.js +216 -3
- package/dist/cjs/src/whitebit.js +2 -2
- package/dist/cjs/src/xt.js +39 -27
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/alpaca.d.ts +1 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/phemex.d.ts +1 -0
- package/js/src/alpaca.d.ts +6 -1
- package/js/src/alpaca.js +258 -12
- package/js/src/base/Exchange.d.ts +7 -6
- package/js/src/base/Exchange.js +14 -1
- package/js/src/base/types.d.ts +3 -3
- package/js/src/binance.d.ts +3 -14
- package/js/src/binance.js +2 -3
- package/js/src/bingx.js +7 -1
- package/js/src/bitget.d.ts +3 -13
- package/js/src/bitget.js +2 -2
- package/js/src/bitmart.d.ts +3 -13
- package/js/src/bitmart.js +3 -3
- package/js/src/bybit.d.ts +3 -14
- package/js/src/bybit.js +3 -14
- package/js/src/cex.d.ts +2 -0
- package/js/src/cex.js +40 -0
- package/js/src/coinex.d.ts +3 -15
- package/js/src/coinex.js +2 -4
- package/js/src/digifinex.d.ts +3 -13
- package/js/src/digifinex.js +2 -2
- package/js/src/exmo.js +1 -0
- package/js/src/gate.d.ts +3 -13
- package/js/src/gate.js +3 -3
- package/js/src/htx.d.ts +3 -14
- package/js/src/htx.js +2 -3
- package/js/src/hyperliquid.js +14 -4
- package/js/src/kucoin.d.ts +3 -13
- package/js/src/kucoin.js +2 -2
- package/js/src/okx.d.ts +3 -13
- package/js/src/okx.js +3 -2
- package/js/src/phemex.js +4 -2
- package/js/src/pro/exmo.d.ts +5 -1
- package/js/src/pro/exmo.js +216 -3
- package/js/src/whitebit.d.ts +3 -13
- package/js/src/whitebit.js +2 -2
- package/js/src/woo.d.ts +1 -1
- package/js/src/xt.js +39 -27
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -197,7 +197,7 @@ var xt$1 = require('./src/pro/xt.js');
|
|
|
197
197
|
|
|
198
198
|
//-----------------------------------------------------------------------------
|
|
199
199
|
// this is updated by vss.js when building
|
|
200
|
-
const version = '4.4.
|
|
200
|
+
const version = '4.4.26';
|
|
201
201
|
Exchange["default"].ccxtVersion = version;
|
|
202
202
|
const exchanges = {
|
|
203
203
|
'ace': ace,
|
package/dist/cjs/src/alpaca.js
CHANGED
|
@@ -54,7 +54,7 @@ class alpaca extends alpaca$1 {
|
|
|
54
54
|
'fetchBidsAsks': false,
|
|
55
55
|
'fetchClosedOrders': true,
|
|
56
56
|
'fetchCurrencies': false,
|
|
57
|
-
'fetchDepositAddress':
|
|
57
|
+
'fetchDepositAddress': true,
|
|
58
58
|
'fetchDepositAddressesByNetwork': false,
|
|
59
59
|
'fetchDeposits': false,
|
|
60
60
|
'fetchDepositsWithdrawals': false,
|
|
@@ -65,7 +65,7 @@ class alpaca extends alpaca$1 {
|
|
|
65
65
|
'fetchL1OrderBook': true,
|
|
66
66
|
'fetchL2OrderBook': false,
|
|
67
67
|
'fetchMarkets': true,
|
|
68
|
-
'fetchMyTrades':
|
|
68
|
+
'fetchMyTrades': true,
|
|
69
69
|
'fetchOHLCV': true,
|
|
70
70
|
'fetchOpenOrder': false,
|
|
71
71
|
'fetchOpenOrders': true,
|
|
@@ -80,8 +80,8 @@ class alpaca extends alpaca$1 {
|
|
|
80
80
|
'fetchPositionsHistory': false,
|
|
81
81
|
'fetchPositionsRisk': false,
|
|
82
82
|
'fetchStatus': false,
|
|
83
|
-
'fetchTicker':
|
|
84
|
-
'fetchTickers':
|
|
83
|
+
'fetchTicker': true,
|
|
84
|
+
'fetchTickers': true,
|
|
85
85
|
'fetchTime': true,
|
|
86
86
|
'fetchTrades': true,
|
|
87
87
|
'fetchTradingFee': false,
|
|
@@ -119,6 +119,7 @@ class alpaca extends alpaca$1 {
|
|
|
119
119
|
'v2/assets/{symbol_or_asset_id}',
|
|
120
120
|
'v2/corporate_actions/announcements/{id}',
|
|
121
121
|
'v2/corporate_actions/announcements',
|
|
122
|
+
'v2/wallets',
|
|
122
123
|
],
|
|
123
124
|
'post': [
|
|
124
125
|
'v2/orders',
|
|
@@ -682,6 +683,136 @@ class alpaca extends alpaca$1 {
|
|
|
682
683
|
this.safeNumber(ohlcv, 'v'), // volume
|
|
683
684
|
];
|
|
684
685
|
}
|
|
686
|
+
async fetchTicker(symbol, params = {}) {
|
|
687
|
+
/**
|
|
688
|
+
* @method
|
|
689
|
+
* @name alpaca#fetchTicker
|
|
690
|
+
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
691
|
+
* @see https://docs.alpaca.markets/reference/cryptosnapshots-1
|
|
692
|
+
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
693
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
694
|
+
* @param {string} [params.loc] crypto location, default: us
|
|
695
|
+
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
696
|
+
*/
|
|
697
|
+
await this.loadMarkets();
|
|
698
|
+
symbol = this.symbol(symbol);
|
|
699
|
+
const tickers = await this.fetchTickers([symbol], params);
|
|
700
|
+
return this.safeDict(tickers, symbol);
|
|
701
|
+
}
|
|
702
|
+
async fetchTickers(symbols = undefined, params = {}) {
|
|
703
|
+
/**
|
|
704
|
+
* @method
|
|
705
|
+
* @name alpaca#fetchTickers
|
|
706
|
+
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
707
|
+
* @see https://docs.alpaca.markets/reference/cryptosnapshots-1
|
|
708
|
+
* @param {string[]} symbols unified symbols of the markets to fetch tickers for
|
|
709
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
710
|
+
* @param {string} [params.loc] crypto location, default: us
|
|
711
|
+
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
712
|
+
*/
|
|
713
|
+
if (symbols === undefined) {
|
|
714
|
+
throw new errors.ArgumentsRequired(this.id + ' fetchTickers() requires a symbols argument');
|
|
715
|
+
}
|
|
716
|
+
await this.loadMarkets();
|
|
717
|
+
symbols = this.marketSymbols(symbols);
|
|
718
|
+
const loc = this.safeString(params, 'loc', 'us');
|
|
719
|
+
const ids = this.marketIds(symbols);
|
|
720
|
+
const request = {
|
|
721
|
+
'symbols': ids.join(','),
|
|
722
|
+
'loc': loc,
|
|
723
|
+
};
|
|
724
|
+
params = this.omit(params, 'loc');
|
|
725
|
+
const response = await this.marketPublicGetV1beta3CryptoLocSnapshots(this.extend(request, params));
|
|
726
|
+
//
|
|
727
|
+
// {
|
|
728
|
+
// "snapshots": {
|
|
729
|
+
// "BTC/USD": {
|
|
730
|
+
// "dailyBar": {
|
|
731
|
+
// "c": 69403.554,
|
|
732
|
+
// "h": 69609.6515,
|
|
733
|
+
// "l": 69013.26,
|
|
734
|
+
// "n": 9,
|
|
735
|
+
// "o": 69536.7,
|
|
736
|
+
// "t": "2024-11-01T05:00:00Z",
|
|
737
|
+
// "v": 0.210809181,
|
|
738
|
+
// "vw": 69327.655393908
|
|
739
|
+
// },
|
|
740
|
+
// "latestQuote": {
|
|
741
|
+
// "ap": 69424.19,
|
|
742
|
+
// "as": 0.68149,
|
|
743
|
+
// "bp": 69366.086,
|
|
744
|
+
// "bs": 0.68312,
|
|
745
|
+
// "t": "2024-11-01T08:31:41.880246926Z"
|
|
746
|
+
// },
|
|
747
|
+
// "latestTrade": {
|
|
748
|
+
// "i": 5272941104897543146,
|
|
749
|
+
// "p": 69416.9,
|
|
750
|
+
// "s": 0.014017324,
|
|
751
|
+
// "t": "2024-11-01T08:14:28.245088803Z",
|
|
752
|
+
// "tks": "B"
|
|
753
|
+
// },
|
|
754
|
+
// "minuteBar": {
|
|
755
|
+
// "c": 69403.554,
|
|
756
|
+
// "h": 69403.554,
|
|
757
|
+
// "l": 69399.125,
|
|
758
|
+
// "n": 0,
|
|
759
|
+
// "o": 69399.125,
|
|
760
|
+
// "t": "2024-11-01T08:30:00Z",
|
|
761
|
+
// "v": 0,
|
|
762
|
+
// "vw": 0
|
|
763
|
+
// },
|
|
764
|
+
// "prevDailyBar": {
|
|
765
|
+
// "c": 69515.1415,
|
|
766
|
+
// "h": 72668.837,
|
|
767
|
+
// "l": 68796.85,
|
|
768
|
+
// "n": 129,
|
|
769
|
+
// "o": 72258.9,
|
|
770
|
+
// "t": "2024-10-31T05:00:00Z",
|
|
771
|
+
// "v": 2.217683307,
|
|
772
|
+
// "vw": 70782.6811608144
|
|
773
|
+
// }
|
|
774
|
+
// },
|
|
775
|
+
// }
|
|
776
|
+
// }
|
|
777
|
+
//
|
|
778
|
+
const results = [];
|
|
779
|
+
const snapshots = this.safeDict(response, 'snapshots', {});
|
|
780
|
+
const marketIds = Object.keys(snapshots);
|
|
781
|
+
for (let i = 0; i < marketIds.length; i++) {
|
|
782
|
+
const marketId = marketIds[i];
|
|
783
|
+
const market = this.safeMarket(marketId);
|
|
784
|
+
const entry = this.safeDict(snapshots, marketId);
|
|
785
|
+
const dailyBar = this.safeDict(entry, 'dailyBar', {});
|
|
786
|
+
const prevDailyBar = this.safeDict(entry, 'prevDailyBar', {});
|
|
787
|
+
const latestQuote = this.safeDict(entry, 'latestQuote', {});
|
|
788
|
+
const latestTrade = this.safeDict(entry, 'latestTrade', {});
|
|
789
|
+
const datetime = this.safeString(latestQuote, 't');
|
|
790
|
+
const ticker = this.safeTicker({
|
|
791
|
+
'info': entry,
|
|
792
|
+
'symbol': market['symbol'],
|
|
793
|
+
'timestamp': this.parse8601(datetime),
|
|
794
|
+
'datetime': datetime,
|
|
795
|
+
'high': this.safeString(dailyBar, 'h'),
|
|
796
|
+
'low': this.safeString(dailyBar, 'l'),
|
|
797
|
+
'bid': this.safeString(latestQuote, 'bp'),
|
|
798
|
+
'bidVolume': this.safeString(latestQuote, 'bs'),
|
|
799
|
+
'ask': this.safeString(latestQuote, 'ap'),
|
|
800
|
+
'askVolume': this.safeString(latestQuote, 'as'),
|
|
801
|
+
'vwap': this.safeString(dailyBar, 'vw'),
|
|
802
|
+
'open': this.safeString(dailyBar, 'o'),
|
|
803
|
+
'close': this.safeString(dailyBar, 'c'),
|
|
804
|
+
'last': this.safeString(latestTrade, 'p'),
|
|
805
|
+
'previousClose': this.safeString(prevDailyBar, 'c'),
|
|
806
|
+
'change': undefined,
|
|
807
|
+
'percentage': undefined,
|
|
808
|
+
'average': undefined,
|
|
809
|
+
'baseVolume': this.safeString(dailyBar, 'v'),
|
|
810
|
+
'quoteVolume': this.safeString(dailyBar, 'n'),
|
|
811
|
+
}, market);
|
|
812
|
+
results.push(ticker);
|
|
813
|
+
}
|
|
814
|
+
return this.filterByArray(results, 'symbol', symbols);
|
|
815
|
+
}
|
|
685
816
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
686
817
|
/**
|
|
687
818
|
* @method
|
|
@@ -1052,7 +1183,59 @@ class alpaca extends alpaca$1 {
|
|
|
1052
1183
|
};
|
|
1053
1184
|
return this.safeString(timeInForces, timeInForce, timeInForce);
|
|
1054
1185
|
}
|
|
1186
|
+
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1187
|
+
/**
|
|
1188
|
+
* @method
|
|
1189
|
+
* @name alpaca#fetchMyTrades
|
|
1190
|
+
* @description fetch all trades made by the user
|
|
1191
|
+
* @see https://docs.alpaca.markets/reference/getaccountactivitiesbyactivitytype-1
|
|
1192
|
+
* @param {string} [symbol] unified market symbol
|
|
1193
|
+
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1194
|
+
* @param {int} [limit] the maximum number of trade structures to retrieve
|
|
1195
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1196
|
+
* @param {int} [params.until] the latest time in ms to fetch trades for
|
|
1197
|
+
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1198
|
+
*/
|
|
1199
|
+
await this.loadMarkets();
|
|
1200
|
+
let market = undefined;
|
|
1201
|
+
let request = {
|
|
1202
|
+
'activity_type': 'FILL',
|
|
1203
|
+
};
|
|
1204
|
+
if (symbol !== undefined) {
|
|
1205
|
+
market = this.market(symbol);
|
|
1206
|
+
}
|
|
1207
|
+
if (since !== undefined) {
|
|
1208
|
+
request['after'] = since;
|
|
1209
|
+
}
|
|
1210
|
+
if (limit !== undefined) {
|
|
1211
|
+
request['page_size'] = limit;
|
|
1212
|
+
}
|
|
1213
|
+
[request, params] = this.handleUntilOption('until', request, params);
|
|
1214
|
+
const response = await this.traderPrivateGetV2AccountActivitiesActivityType(this.extend(request, params));
|
|
1215
|
+
//
|
|
1216
|
+
// [
|
|
1217
|
+
// {
|
|
1218
|
+
// "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
|
1219
|
+
// "activity_type": "FILL",
|
|
1220
|
+
// "transaction_time": "2022-12-28T12:19:29.579352Z",
|
|
1221
|
+
// "type": "fill",
|
|
1222
|
+
// "price": "67.31",
|
|
1223
|
+
// "qty": "0.07",
|
|
1224
|
+
// "side": "sell",
|
|
1225
|
+
// "symbol": "LTC/USD",
|
|
1226
|
+
// "leaves_qty": "0",
|
|
1227
|
+
// "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
|
1228
|
+
// "cum_qty": "0.07",
|
|
1229
|
+
// "order_status": "filled",
|
|
1230
|
+
// "swap_rate": "1"
|
|
1231
|
+
// },
|
|
1232
|
+
// ]
|
|
1233
|
+
//
|
|
1234
|
+
return this.parseTrades(response, market, since, limit);
|
|
1235
|
+
}
|
|
1055
1236
|
parseTrade(trade, market = undefined) {
|
|
1237
|
+
//
|
|
1238
|
+
// fetchTrades
|
|
1056
1239
|
//
|
|
1057
1240
|
// {
|
|
1058
1241
|
// "t":"2022-06-14T05:00:00.027869Z",
|
|
@@ -1063,27 +1246,45 @@ class alpaca extends alpaca$1 {
|
|
|
1063
1246
|
// "i":"355681339"
|
|
1064
1247
|
// }
|
|
1065
1248
|
//
|
|
1066
|
-
|
|
1249
|
+
// fetchMyTrades
|
|
1250
|
+
//
|
|
1251
|
+
// {
|
|
1252
|
+
// "id": "20221228071929579::ca2aafd0-1270-4b56-b0a9-85423b4a07c8",
|
|
1253
|
+
// "activity_type": "FILL",
|
|
1254
|
+
// "transaction_time": "2022-12-28T12:19:29.579352Z",
|
|
1255
|
+
// "type": "fill",
|
|
1256
|
+
// "price": "67.31",
|
|
1257
|
+
// "qty": "0.07",
|
|
1258
|
+
// "side": "sell",
|
|
1259
|
+
// "symbol": "LTC/USD",
|
|
1260
|
+
// "leaves_qty": "0",
|
|
1261
|
+
// "order_id": "82eebcf7-6e66-4b7e-93f8-be0df0e4f12e",
|
|
1262
|
+
// "cum_qty": "0.07",
|
|
1263
|
+
// "order_status": "filled",
|
|
1264
|
+
// "swap_rate": "1"
|
|
1265
|
+
// },
|
|
1266
|
+
//
|
|
1267
|
+
const marketId = this.safeString2(trade, 'S', 'symbol');
|
|
1067
1268
|
const symbol = this.safeSymbol(marketId, market);
|
|
1068
|
-
const datetime = this.
|
|
1269
|
+
const datetime = this.safeString2(trade, 't', 'transaction_time');
|
|
1069
1270
|
const timestamp = this.parse8601(datetime);
|
|
1070
1271
|
const alpacaSide = this.safeString(trade, 'tks');
|
|
1071
|
-
let side;
|
|
1272
|
+
let side = this.safeString(trade, 'side');
|
|
1072
1273
|
if (alpacaSide === 'B') {
|
|
1073
1274
|
side = 'buy';
|
|
1074
1275
|
}
|
|
1075
1276
|
else if (alpacaSide === 'S') {
|
|
1076
1277
|
side = 'sell';
|
|
1077
1278
|
}
|
|
1078
|
-
const priceString = this.
|
|
1079
|
-
const amountString = this.
|
|
1279
|
+
const priceString = this.safeString2(trade, 'p', 'price');
|
|
1280
|
+
const amountString = this.safeString2(trade, 's', 'qty');
|
|
1080
1281
|
return this.safeTrade({
|
|
1081
1282
|
'info': trade,
|
|
1082
|
-
'id': this.
|
|
1283
|
+
'id': this.safeString2(trade, 'i', 'id'),
|
|
1083
1284
|
'timestamp': timestamp,
|
|
1084
1285
|
'datetime': this.iso8601(timestamp),
|
|
1085
1286
|
'symbol': symbol,
|
|
1086
|
-
'order':
|
|
1287
|
+
'order': this.safeString(trade, 'order_id'),
|
|
1087
1288
|
'type': undefined,
|
|
1088
1289
|
'side': side,
|
|
1089
1290
|
'takerOrMaker': 'taker',
|
|
@@ -1093,6 +1294,51 @@ class alpaca extends alpaca$1 {
|
|
|
1093
1294
|
'fee': undefined,
|
|
1094
1295
|
}, market);
|
|
1095
1296
|
}
|
|
1297
|
+
async fetchDepositAddress(code, params = {}) {
|
|
1298
|
+
/**
|
|
1299
|
+
* @method
|
|
1300
|
+
* @name alpaca#fetchDepositAddress
|
|
1301
|
+
* @description fetch the deposit address for a currency associated with this account
|
|
1302
|
+
* @see https://docs.alpaca.markets/reference/listcryptofundingwallets
|
|
1303
|
+
* @param {string} code unified currency code
|
|
1304
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1305
|
+
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1306
|
+
*/
|
|
1307
|
+
await this.loadMarkets();
|
|
1308
|
+
const currency = this.currency(code);
|
|
1309
|
+
const request = {
|
|
1310
|
+
'asset': currency['id'],
|
|
1311
|
+
};
|
|
1312
|
+
const response = await this.traderPrivateGetV2Wallets(this.extend(request, params));
|
|
1313
|
+
//
|
|
1314
|
+
// {
|
|
1315
|
+
// "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
|
1316
|
+
// "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
|
1317
|
+
// "created_at": "2024-11-03T07:30:05.609976344Z"
|
|
1318
|
+
// }
|
|
1319
|
+
//
|
|
1320
|
+
return this.parseDepositAddress(response, currency);
|
|
1321
|
+
}
|
|
1322
|
+
parseDepositAddress(depositAddress, currency = undefined) {
|
|
1323
|
+
//
|
|
1324
|
+
// {
|
|
1325
|
+
// "asset_id": "4fa30c85-77b7-4cbc-92dd-7b7513640aad",
|
|
1326
|
+
// "address": "bc1q2fpskfnwem3uq9z8660e4z6pfv7aqfamysk75r",
|
|
1327
|
+
// "created_at": "2024-11-03T07:30:05.609976344Z"
|
|
1328
|
+
// }
|
|
1329
|
+
//
|
|
1330
|
+
let parsedCurrency = undefined;
|
|
1331
|
+
if (currency !== undefined) {
|
|
1332
|
+
parsedCurrency = currency['id'];
|
|
1333
|
+
}
|
|
1334
|
+
return {
|
|
1335
|
+
'info': depositAddress,
|
|
1336
|
+
'currency': parsedCurrency,
|
|
1337
|
+
'network': undefined,
|
|
1338
|
+
'address': this.safeString(depositAddress, 'address'),
|
|
1339
|
+
'tag': undefined,
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1096
1342
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1097
1343
|
let endpoint = '/' + this.implodeParams(path, params);
|
|
1098
1344
|
let url = this.implodeHostname(this.urls['api'][api[0]]);
|
|
@@ -57,6 +57,7 @@ const { isNode, selfIsDefined, deepExtend, extend, clone, flatten, unique, index
|
|
|
57
57
|
*/
|
|
58
58
|
class Exchange {
|
|
59
59
|
constructor(userConfig = {}) {
|
|
60
|
+
this.isSandboxModeEnabled = false;
|
|
60
61
|
this.throttleProp = undefined;
|
|
61
62
|
this.sleep = sleep;
|
|
62
63
|
this.api = undefined;
|
|
@@ -811,7 +812,15 @@ class Exchange {
|
|
|
811
812
|
}
|
|
812
813
|
else {
|
|
813
814
|
try {
|
|
814
|
-
|
|
815
|
+
// we should handle scientific notation here
|
|
816
|
+
// so if the exchanges returns 1e-8
|
|
817
|
+
// this function will return 0.00000001
|
|
818
|
+
// check https://github.com/ccxt/ccxt/issues/24135
|
|
819
|
+
const numberNormalized = this.numberToString(value);
|
|
820
|
+
if (numberNormalized.indexOf('e-') > -1) {
|
|
821
|
+
return this.number(numberToString(parseFloat(numberNormalized)));
|
|
822
|
+
}
|
|
823
|
+
return this.number(numberNormalized);
|
|
815
824
|
}
|
|
816
825
|
catch (e) {
|
|
817
826
|
return d;
|
|
@@ -1978,6 +1987,8 @@ class Exchange {
|
|
|
1978
1987
|
else {
|
|
1979
1988
|
throw new errors.NotSupported(this.id + ' does not have a sandbox URL');
|
|
1980
1989
|
}
|
|
1990
|
+
// set flag
|
|
1991
|
+
this.isSandboxModeEnabled = true;
|
|
1981
1992
|
}
|
|
1982
1993
|
else if ('apiBackup' in this.urls) {
|
|
1983
1994
|
if (typeof this.urls['api'] === 'string') {
|
|
@@ -1988,6 +1999,8 @@ class Exchange {
|
|
|
1988
1999
|
}
|
|
1989
2000
|
const newUrls = this.omit(this.urls, 'apiBackup');
|
|
1990
2001
|
this.urls = newUrls;
|
|
2002
|
+
// set flag
|
|
2003
|
+
this.isSandboxModeEnabled = false;
|
|
1991
2004
|
}
|
|
1992
2005
|
}
|
|
1993
2006
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -12375,16 +12375,15 @@ class binance extends binance$1 {
|
|
|
12375
12375
|
const timestamp = this.safeInteger(info, 'interestAccuredTime');
|
|
12376
12376
|
const marginMode = (symbol === undefined) ? 'cross' : 'isolated';
|
|
12377
12377
|
return {
|
|
12378
|
-
'
|
|
12378
|
+
'info': info,
|
|
12379
12379
|
'symbol': symbol,
|
|
12380
|
-
'marginMode': marginMode,
|
|
12381
12380
|
'currency': this.safeCurrencyCode(this.safeString(info, 'asset')),
|
|
12382
12381
|
'interest': this.safeNumber(info, 'interest'),
|
|
12383
12382
|
'interestRate': this.safeNumber(info, 'interestRate'),
|
|
12384
12383
|
'amountBorrowed': this.safeNumber(info, 'principal'),
|
|
12384
|
+
'marginMode': marginMode,
|
|
12385
12385
|
'timestamp': timestamp,
|
|
12386
12386
|
'datetime': this.iso8601(timestamp),
|
|
12387
|
-
'info': info,
|
|
12388
12387
|
};
|
|
12389
12388
|
}
|
|
12390
12389
|
async repayCrossMargin(code, amount, params = {}) {
|
package/dist/cjs/src/bingx.js
CHANGED
|
@@ -204,6 +204,7 @@ class bingx extends bingx$1 {
|
|
|
204
204
|
'market/markPriceKlines': 1,
|
|
205
205
|
'trade/batchCancelReplace': 5,
|
|
206
206
|
'trade/fullOrder': 2,
|
|
207
|
+
'positionMargin/history': 2,
|
|
207
208
|
},
|
|
208
209
|
'post': {
|
|
209
210
|
'trade/cancelReplace': 2,
|
|
@@ -2854,6 +2855,7 @@ class bingx extends bingx$1 {
|
|
|
2854
2855
|
* @see https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Bulk%20order
|
|
2855
2856
|
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
2856
2857
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2858
|
+
* @param {boolean} [params.sync] *spot only* if true, multiple orders are ordered serially and all orders do not require the same symbol/side/type
|
|
2857
2859
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2858
2860
|
*/
|
|
2859
2861
|
await this.loadMarkets();
|
|
@@ -2886,6 +2888,10 @@ class bingx extends bingx$1 {
|
|
|
2886
2888
|
response = await this.swapV2PrivatePostTradeBatchOrders(request);
|
|
2887
2889
|
}
|
|
2888
2890
|
else {
|
|
2891
|
+
const sync = this.safeBool(params, 'sync', false);
|
|
2892
|
+
if (sync) {
|
|
2893
|
+
request['sync'] = true;
|
|
2894
|
+
}
|
|
2889
2895
|
request['data'] = this.json(ordersRequests);
|
|
2890
2896
|
response = await this.spotV1PrivatePostTradeBatchOrders(request);
|
|
2891
2897
|
}
|
|
@@ -3339,7 +3345,7 @@ class bingx extends bingx$1 {
|
|
|
3339
3345
|
'cost': Precise["default"].stringAbs(feeCost),
|
|
3340
3346
|
},
|
|
3341
3347
|
'trades': undefined,
|
|
3342
|
-
'reduceOnly': this.
|
|
3348
|
+
'reduceOnly': this.safeBool2(order, 'reduceOnly', 'ro'),
|
|
3343
3349
|
}, market);
|
|
3344
3350
|
}
|
|
3345
3351
|
parseOrderStatus(status) {
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -8349,15 +8349,15 @@ class bitget extends bitget$1 {
|
|
|
8349
8349
|
const marginMode = (marketId !== undefined) ? 'isolated' : 'cross';
|
|
8350
8350
|
const timestamp = this.safeInteger(info, 'cTime');
|
|
8351
8351
|
return {
|
|
8352
|
+
'info': info,
|
|
8352
8353
|
'symbol': this.safeString(market, 'symbol'),
|
|
8353
|
-
'marginMode': marginMode,
|
|
8354
8354
|
'currency': this.safeCurrencyCode(this.safeString(info, 'interestCoin')),
|
|
8355
8355
|
'interest': this.safeNumber(info, 'interestAmount'),
|
|
8356
8356
|
'interestRate': this.safeNumber(info, 'dailyInterestRate'),
|
|
8357
8357
|
'amountBorrowed': undefined,
|
|
8358
|
+
'marginMode': marginMode,
|
|
8358
8359
|
'timestamp': timestamp,
|
|
8359
8360
|
'datetime': this.iso8601(timestamp),
|
|
8360
|
-
'info': info,
|
|
8361
8361
|
};
|
|
8362
8362
|
}
|
|
8363
8363
|
async closePosition(symbol, side = undefined, params = {}) {
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -1855,7 +1855,7 @@ class bitmart extends bitmart$1 {
|
|
|
1855
1855
|
}
|
|
1856
1856
|
}
|
|
1857
1857
|
else {
|
|
1858
|
-
const maxLimit =
|
|
1858
|
+
const maxLimit = 500;
|
|
1859
1859
|
if (limit === undefined) {
|
|
1860
1860
|
limit = maxLimit;
|
|
1861
1861
|
}
|
|
@@ -4336,15 +4336,15 @@ class bitmart extends bitmart$1 {
|
|
|
4336
4336
|
market = this.safeMarket(marketId, market);
|
|
4337
4337
|
const timestamp = this.safeInteger(info, 'create_time');
|
|
4338
4338
|
return {
|
|
4339
|
+
'info': info,
|
|
4339
4340
|
'symbol': this.safeString(market, 'symbol'),
|
|
4340
|
-
'marginMode': 'isolated',
|
|
4341
4341
|
'currency': this.safeCurrencyCode(this.safeString(info, 'currency')),
|
|
4342
4342
|
'interest': this.safeNumber(info, 'interest_amount'),
|
|
4343
4343
|
'interestRate': this.safeNumber(info, 'hourly_interest'),
|
|
4344
4344
|
'amountBorrowed': this.safeNumber(info, 'borrow_amount'),
|
|
4345
|
+
'marginMode': 'isolated',
|
|
4345
4346
|
'timestamp': timestamp,
|
|
4346
4347
|
'datetime': this.iso8601(timestamp),
|
|
4347
|
-
'info': info,
|
|
4348
4348
|
};
|
|
4349
4349
|
}
|
|
4350
4350
|
async fetchOpenInterest(symbol, params = {}) {
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -1002,7 +1002,6 @@ class bybit extends bybit$1 {
|
|
|
1002
1002
|
'precisionMode': number.TICK_SIZE,
|
|
1003
1003
|
'options': {
|
|
1004
1004
|
'usePrivateInstrumentsInfo': false,
|
|
1005
|
-
'sandboxMode': false,
|
|
1006
1005
|
'enableDemoTrading': false,
|
|
1007
1006
|
'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
|
|
1008
1007
|
'createOrder': {
|
|
@@ -1088,16 +1087,6 @@ class bybit extends bybit$1 {
|
|
|
1088
1087
|
},
|
|
1089
1088
|
});
|
|
1090
1089
|
}
|
|
1091
|
-
setSandboxMode(enable) {
|
|
1092
|
-
/**
|
|
1093
|
-
* @method
|
|
1094
|
-
* @name bybit#setSandboxMode
|
|
1095
|
-
* @description enables or disables sandbox mode
|
|
1096
|
-
* @param {boolean} [enable] true if demo trading should be enabled, false otherwise
|
|
1097
|
-
*/
|
|
1098
|
-
super.setSandboxMode(enable);
|
|
1099
|
-
this.options['sandboxMode'] = enable;
|
|
1100
|
-
}
|
|
1101
1090
|
enableDemoTrading(enable) {
|
|
1102
1091
|
/**
|
|
1103
1092
|
* @method
|
|
@@ -1106,7 +1095,7 @@ class bybit extends bybit$1 {
|
|
|
1106
1095
|
* @see https://bybit-exchange.github.io/docs/v5/demo
|
|
1107
1096
|
* @param {boolean} [enable] true if demo trading should be enabled, false otherwise
|
|
1108
1097
|
*/
|
|
1109
|
-
if (this.
|
|
1098
|
+
if (this.isSandboxModeEnabled) {
|
|
1110
1099
|
throw new errors.NotSupported(this.id + ' demo trading does not support in sandbox environment');
|
|
1111
1100
|
}
|
|
1112
1101
|
// enable demo trading in bybit, see: https://bybit-exchange.github.io/docs/v5/demo
|
|
@@ -7484,15 +7473,15 @@ class bybit extends bybit$1 {
|
|
|
7484
7473
|
// },
|
|
7485
7474
|
//
|
|
7486
7475
|
return {
|
|
7476
|
+
'info': info,
|
|
7487
7477
|
'symbol': undefined,
|
|
7488
|
-
'marginMode': 'cross',
|
|
7489
7478
|
'currency': this.safeCurrencyCode(this.safeString(info, 'tokenId')),
|
|
7490
7479
|
'interest': this.safeNumber(info, 'interest'),
|
|
7491
7480
|
'interestRate': undefined,
|
|
7492
7481
|
'amountBorrowed': this.safeNumber(info, 'loan'),
|
|
7482
|
+
'marginMode': 'cross',
|
|
7493
7483
|
'timestamp': undefined,
|
|
7494
7484
|
'datetime': undefined,
|
|
7495
|
-
'info': info,
|
|
7496
7485
|
};
|
|
7497
7486
|
}
|
|
7498
7487
|
async transfer(code, amount, fromAccount, toAccount, params = {}) {
|
package/dist/cjs/src/cex.js
CHANGED
|
@@ -32,6 +32,7 @@ class cex extends cex$1 {
|
|
|
32
32
|
'createOrder': true,
|
|
33
33
|
'fetchAccounts': true,
|
|
34
34
|
'fetchBalance': true,
|
|
35
|
+
'fetchClosedOrder': true,
|
|
35
36
|
'fetchClosedOrders': true,
|
|
36
37
|
'fetchCurrencies': true,
|
|
37
38
|
'fetchDepositAddress': true,
|
|
@@ -43,6 +44,7 @@ class cex extends cex$1 {
|
|
|
43
44
|
'fetchLedger': true,
|
|
44
45
|
'fetchMarkets': true,
|
|
45
46
|
'fetchOHLCV': true,
|
|
47
|
+
'fetchOpenOrder': true,
|
|
46
48
|
'fetchOpenOrders': true,
|
|
47
49
|
'fetchOrderBook': true,
|
|
48
50
|
'fetchTicker': true,
|
|
@@ -940,6 +942,7 @@ class cex extends cex$1 {
|
|
|
940
942
|
/**
|
|
941
943
|
* @method
|
|
942
944
|
* @name cex#fetchClosedOrders
|
|
945
|
+
* @see https://trade.cex.io/docs/#rest-private-api-calls-orders
|
|
943
946
|
* @description fetches information on multiple canceled orders made by the user
|
|
944
947
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
945
948
|
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
|
|
@@ -953,6 +956,7 @@ class cex extends cex$1 {
|
|
|
953
956
|
/**
|
|
954
957
|
* @method
|
|
955
958
|
* @name cex#fetchOpenOrders
|
|
959
|
+
* @see https://trade.cex.io/docs/#rest-private-api-calls-orders
|
|
956
960
|
* @description fetches information on multiple canceled orders made by the user
|
|
957
961
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
958
962
|
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
|
|
@@ -962,6 +966,42 @@ class cex extends cex$1 {
|
|
|
962
966
|
*/
|
|
963
967
|
return await this.fetchOrdersByStatus('open', symbol, since, limit, params);
|
|
964
968
|
}
|
|
969
|
+
async fetchOpenOrder(id, symbol = undefined, params = {}) {
|
|
970
|
+
/**
|
|
971
|
+
* @method
|
|
972
|
+
* @name cex#fetchOpenOrder
|
|
973
|
+
* @description fetches information on an open order made by the user
|
|
974
|
+
* @see https://trade.cex.io/docs/#rest-private-api-calls-orders
|
|
975
|
+
* @param {string} id order id
|
|
976
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
977
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
978
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
979
|
+
*/
|
|
980
|
+
await this.loadMarkets();
|
|
981
|
+
const request = {
|
|
982
|
+
'orderId': parseInt(id),
|
|
983
|
+
};
|
|
984
|
+
const result = await this.fetchOpenOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
985
|
+
return result[0];
|
|
986
|
+
}
|
|
987
|
+
async fetchClosedOrder(id, symbol = undefined, params = {}) {
|
|
988
|
+
/**
|
|
989
|
+
* @method
|
|
990
|
+
* @name cex#fetchClosedOrder
|
|
991
|
+
* @description fetches information on an closed order made by the user
|
|
992
|
+
* @see https://trade.cex.io/docs/#rest-private-api-calls-orders
|
|
993
|
+
* @param {string} id order id
|
|
994
|
+
* @param {string} [symbol] unified symbol of the market the order was made in
|
|
995
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
996
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
997
|
+
*/
|
|
998
|
+
await this.loadMarkets();
|
|
999
|
+
const request = {
|
|
1000
|
+
'orderId': parseInt(id),
|
|
1001
|
+
};
|
|
1002
|
+
const result = await this.fetchClosedOrders(symbol, undefined, undefined, this.extend(request, params));
|
|
1003
|
+
return result[0];
|
|
1004
|
+
}
|
|
965
1005
|
parseOrderStatus(status) {
|
|
966
1006
|
const statuses = {
|
|
967
1007
|
'FILLED': 'closed',
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -5339,17 +5339,15 @@ class coinex extends coinex$1 {
|
|
|
5339
5339
|
market = this.safeMarket(marketId, market, undefined, 'spot');
|
|
5340
5340
|
const timestamp = this.safeInteger(info, 'expired_at');
|
|
5341
5341
|
return {
|
|
5342
|
-
'
|
|
5342
|
+
'info': info,
|
|
5343
5343
|
'symbol': market['symbol'],
|
|
5344
|
-
'marginMode': 'isolated',
|
|
5345
|
-
'marginType': undefined,
|
|
5346
5344
|
'currency': this.safeCurrencyCode(this.safeString(info, 'ccy')),
|
|
5347
5345
|
'interest': this.safeNumber(info, 'to_repaied_amount'),
|
|
5348
5346
|
'interestRate': this.safeNumber(info, 'daily_interest_rate'),
|
|
5349
5347
|
'amountBorrowed': this.safeNumber(info, 'borrow_amount'),
|
|
5348
|
+
'marginMode': 'isolated',
|
|
5350
5349
|
'timestamp': timestamp,
|
|
5351
5350
|
'datetime': this.iso8601(timestamp),
|
|
5352
|
-
'info': info,
|
|
5353
5351
|
};
|
|
5354
5352
|
}
|
|
5355
5353
|
async borrowIsolatedMargin(symbol, code, amount, params = {}) {
|
|
@@ -3100,15 +3100,15 @@ class digifinex extends digifinex$1 {
|
|
|
3100
3100
|
const currency = (market === undefined) ? undefined : market['base'];
|
|
3101
3101
|
const symbol = this.safeSymbol(marketId, market);
|
|
3102
3102
|
return {
|
|
3103
|
-
'
|
|
3103
|
+
'info': info,
|
|
3104
3104
|
'symbol': symbol,
|
|
3105
3105
|
'currency': currency,
|
|
3106
3106
|
'interest': undefined,
|
|
3107
3107
|
'interestRate': 0.001,
|
|
3108
3108
|
'amountBorrowed': this.parseNumber(amountBorrowed),
|
|
3109
|
+
'marginMode': undefined,
|
|
3109
3110
|
'timestamp': undefined,
|
|
3110
3111
|
'datetime': undefined,
|
|
3111
|
-
'info': info,
|
|
3112
3112
|
};
|
|
3113
3113
|
}
|
|
3114
3114
|
async fetchCrossBorrowRate(code, params = {}) {
|