ccxt 4.2.47 → 4.2.48

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/dist/cjs/ccxt.js CHANGED
@@ -177,7 +177,7 @@ var woo$1 = require('./src/pro/woo.js');
177
177
 
178
178
  //-----------------------------------------------------------------------------
179
179
  // this is updated by vss.js when building
180
- const version = '4.2.47';
180
+ const version = '4.2.48';
181
181
  Exchange["default"].ccxtVersion = version;
182
182
  const exchanges = {
183
183
  'ace': ace,
@@ -5771,12 +5771,14 @@ class binance extends binance$1 {
5771
5771
  const trailingDelta = this.safeString(params, 'trailingDelta');
5772
5772
  const trailingTriggerPrice = this.safeString2(params, 'trailingTriggerPrice', 'activationPrice', this.numberToString(price));
5773
5773
  const trailingPercent = this.safeString2(params, 'trailingPercent', 'callbackRate');
5774
+ const priceMatch = this.safeString(params, 'priceMatch');
5774
5775
  const isTrailingPercentOrder = trailingPercent !== undefined;
5775
5776
  const isStopLoss = stopLossPrice !== undefined || trailingDelta !== undefined;
5776
5777
  const isTakeProfit = takeProfitPrice !== undefined;
5777
5778
  const isTriggerOrder = triggerPrice !== undefined;
5778
5779
  const isConditional = isTriggerOrder || isTrailingPercentOrder || isStopLoss || isTakeProfit;
5779
5780
  const isPortfolioMarginConditional = (isPortfolioMargin && isConditional);
5781
+ const isPriceMatch = priceMatch !== undefined;
5780
5782
  let uppercaseType = type.toUpperCase();
5781
5783
  let stopPrice = undefined;
5782
5784
  if (isTrailingPercentOrder) {
@@ -5957,7 +5959,7 @@ class binance extends binance$1 {
5957
5959
  request['quantity'] = this.amountToPrecision(symbol, amount);
5958
5960
  }
5959
5961
  }
5960
- if (priceIsRequired) {
5962
+ if (priceIsRequired && !isPriceMatch) {
5961
5963
  if (price === undefined) {
5962
5964
  throw new errors.InvalidOrder(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
5963
5965
  }
@@ -81,8 +81,10 @@ class idex extends idex$1 {
81
81
  'fetchPositions': false,
82
82
  'fetchPositionsRisk': false,
83
83
  'fetchPremiumIndexOHLCV': false,
84
+ 'fetchStatus': true,
84
85
  'fetchTicker': true,
85
86
  'fetchTickers': true,
87
+ 'fetchTime': true,
86
88
  'fetchTrades': true,
87
89
  'fetchTradingFee': false,
88
90
  'fetchTradingFees': true,
@@ -196,6 +198,7 @@ class idex extends idex$1 {
196
198
  * @method
197
199
  * @name idex#fetchMarkets
198
200
  * @description retrieves data on all markets for idex
201
+ * @see https://api-docs-v3.idex.io/#get-markets
199
202
  * @param {object} [params] extra parameters specific to the exchange API endpoint
200
203
  * @returns {object[]} an array of objects representing market data
201
204
  */
@@ -326,6 +329,7 @@ class idex extends idex$1 {
326
329
  * @method
327
330
  * @name idex#fetchTicker
328
331
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
332
+ * @see https://api-docs-v3.idex.io/#get-tickers
329
333
  * @param {string} symbol unified symbol of the market to fetch the ticker for
330
334
  * @param {object} [params] extra parameters specific to the exchange API endpoint
331
335
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -362,6 +366,7 @@ class idex extends idex$1 {
362
366
  * @method
363
367
  * @name idex#fetchTickers
364
368
  * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
369
+ * @see https://api-docs-v3.idex.io/#get-tickers
365
370
  * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
366
371
  * @param {object} [params] extra parameters specific to the exchange API endpoint
367
372
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -438,6 +443,7 @@ class idex extends idex$1 {
438
443
  * @method
439
444
  * @name idex#fetchOHLCV
440
445
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
446
+ * @see https://api-docs-v3.idex.io/#get-candles
441
447
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
442
448
  * @param {string} timeframe the length of time each candle represents
443
449
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -500,6 +506,7 @@ class idex extends idex$1 {
500
506
  * @method
501
507
  * @name idex#fetchTrades
502
508
  * @description get the list of most recent trades for a particular symbol
509
+ * @see https://api-docs-v3.idex.io/#get-trades
503
510
  * @param {string} symbol unified symbol of the market to fetch trades for
504
511
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
505
512
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -613,6 +620,7 @@ class idex extends idex$1 {
613
620
  * @method
614
621
  * @name idex#fetchTradingFees
615
622
  * @description fetch the trading fees for multiple markets
623
+ * @see https://api-docs-v3.idex.io/#get-api-account
616
624
  * @param {object} [params] extra parameters specific to the exchange API endpoint
617
625
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
618
626
  */
@@ -658,6 +666,7 @@ class idex extends idex$1 {
658
666
  * @method
659
667
  * @name idex#fetchOrderBook
660
668
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
669
+ * @see https://api-docs-v3.idex.io/#get-order-books
661
670
  * @param {string} symbol unified symbol of the market to fetch the order book for
662
671
  * @param {int} [limit] the maximum amount of order book entries to return
663
672
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -721,6 +730,7 @@ class idex extends idex$1 {
721
730
  * @method
722
731
  * @name idex#fetchCurrencies
723
732
  * @description fetches all available currencies on an exchange
733
+ * @see https://api-docs-v3.idex.io/#get-assets
724
734
  * @param {object} [params] extra parameters specific to the exchange API endpoint
725
735
  * @returns {object} an associative dictionary of currencies
726
736
  */
@@ -786,6 +796,7 @@ class idex extends idex$1 {
786
796
  * @method
787
797
  * @name idex#fetchBalance
788
798
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
799
+ * @see https://api-docs-v3.idex.io/#get-balances
789
800
  * @param {object} [params] extra parameters specific to the exchange API endpoint
790
801
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
791
802
  */
@@ -830,6 +841,7 @@ class idex extends idex$1 {
830
841
  * @method
831
842
  * @name idex#fetchMyTrades
832
843
  * @description fetch all trades made by the user
844
+ * @see https://api-docs-v3.idex.io/#get-fills
833
845
  * @param {string} symbol unified market symbol
834
846
  * @param {int} [since] the earliest time in ms to fetch trades for
835
847
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -898,6 +910,7 @@ class idex extends idex$1 {
898
910
  * @method
899
911
  * @name idex#fetchOrder
900
912
  * @description fetches information on an order made by the user
913
+ * @see https://api-docs-v3.idex.io/#get-orders
901
914
  * @param {string} symbol unified symbol of the market the order was made in
902
915
  * @param {object} [params] extra parameters specific to the exchange API endpoint
903
916
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -912,6 +925,7 @@ class idex extends idex$1 {
912
925
  * @method
913
926
  * @name idex#fetchOpenOrders
914
927
  * @description fetch all unfilled currently open orders
928
+ * @see https://api-docs-v3.idex.io/#get-orders
915
929
  * @param {string} symbol unified market symbol
916
930
  * @param {int} [since] the earliest time in ms to fetch open orders for
917
931
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -928,6 +942,7 @@ class idex extends idex$1 {
928
942
  * @method
929
943
  * @name idex#fetchClosedOrders
930
944
  * @description fetches information on multiple closed orders made by the user
945
+ * @see https://api-docs-v3.idex.io/#get-orders
931
946
  * @param {string} symbol unified market symbol of the market orders were made in
932
947
  * @param {int} [since] the earliest time in ms to fetch orders for
933
948
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1139,16 +1154,20 @@ class idex extends idex$1 {
1139
1154
  * @method
1140
1155
  * @name idex#createOrder
1141
1156
  * @description create a trade order, https://docs.idex.io/#create-order
1157
+ * @see https://api-docs-v3.idex.io/#create-order
1142
1158
  * @param {string} symbol unified symbol of the market to create an order in
1143
1159
  * @param {string} type 'market' or 'limit'
1144
1160
  * @param {string} side 'buy' or 'sell'
1145
1161
  * @param {float} amount how much of currency you want to trade in units of base currency
1146
1162
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1147
1163
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1164
+ * @param {bool} [params.test] set to true to test an order, no order will be created but the request will be validated
1148
1165
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1149
1166
  */
1150
1167
  this.checkRequiredCredentials();
1151
1168
  await this.loadMarkets();
1169
+ const testOrder = this.safeBool(params, 'test', false);
1170
+ params = this.omit(params, 'test');
1152
1171
  const market = this.market(symbol);
1153
1172
  const nonce = this.uuidv1();
1154
1173
  let typeEnum = undefined;
@@ -1329,7 +1348,13 @@ class idex extends idex$1 {
1329
1348
  // "avgExecutionPrice": "0.09905990"
1330
1349
  // }
1331
1350
  // we don't use extend here because it is a signed endpoint
1332
- const response = await this.privatePostOrders(request);
1351
+ let response = undefined;
1352
+ if (testOrder) {
1353
+ response = await this.privatePostOrdersTest(request);
1354
+ }
1355
+ else {
1356
+ response = await this.privatePostOrders(request);
1357
+ }
1333
1358
  return this.parseOrder(response, market);
1334
1359
  }
1335
1360
  async withdraw(code, amount, address, tag = undefined, params = {}) {
@@ -1337,6 +1362,7 @@ class idex extends idex$1 {
1337
1362
  * @method
1338
1363
  * @name idex#withdraw
1339
1364
  * @description make a withdrawal
1365
+ * @see https://api-docs-v3.idex.io/#withdraw-funds
1340
1366
  * @param {string} code unified currency code
1341
1367
  * @param {float} amount the amount to withdraw
1342
1368
  * @param {string} address the address to withdraw to
@@ -1390,6 +1416,7 @@ class idex extends idex$1 {
1390
1416
  * @method
1391
1417
  * @name idex#cancelAllOrders
1392
1418
  * @description cancel all open orders
1419
+ * @see https://api-docs-v3.idex.io/#cancel-order
1393
1420
  * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
1394
1421
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1395
1422
  * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -1429,6 +1456,7 @@ class idex extends idex$1 {
1429
1456
  * @method
1430
1457
  * @name idex#cancelOrder
1431
1458
  * @description cancels an open order
1459
+ * @see https://api-docs-v3.idex.io/#cancel-order
1432
1460
  * @param {string} id order id
1433
1461
  * @param {string} symbol unified symbol of the market the order was made in
1434
1462
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1480,6 +1508,7 @@ class idex extends idex$1 {
1480
1508
  * @method
1481
1509
  * @name idex#fetchDeposit
1482
1510
  * @description fetch information on a deposit
1511
+ * @see https://api-docs-v3.idex.io/#get-deposits
1483
1512
  * @param {string} id deposit id
1484
1513
  * @param {string} code not used by idex fetchDeposit ()
1485
1514
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1500,6 +1529,7 @@ class idex extends idex$1 {
1500
1529
  * @method
1501
1530
  * @name idex#fetchDeposits
1502
1531
  * @description fetch all deposits made to an account
1532
+ * @see https://api-docs-v3.idex.io/#get-deposits
1503
1533
  * @param {string} code unified currency code
1504
1534
  * @param {int} [since] the earliest time in ms to fetch deposits for
1505
1535
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -1511,11 +1541,30 @@ class idex extends idex$1 {
1511
1541
  }, params);
1512
1542
  return await this.fetchTransactionsHelper(code, since, limit, params);
1513
1543
  }
1544
+ async fetchStatus(params = {}) {
1545
+ /**
1546
+ * @method
1547
+ * @name idex#fetchStatus
1548
+ * @description the latest known information on the availability of the exchange API
1549
+ * @see https://api-docs-v3.idex.io/#get-ping
1550
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1551
+ * @returns {object} a [status structure]{@link https://docs.ccxt.com/#/?id=exchange-status-structure}
1552
+ */
1553
+ const response = await this.publicGetPing(params);
1554
+ return {
1555
+ 'status': 'ok',
1556
+ 'updated': undefined,
1557
+ 'eta': undefined,
1558
+ 'url': undefined,
1559
+ 'info': response,
1560
+ };
1561
+ }
1514
1562
  async fetchTime(params = {}) {
1515
1563
  /**
1516
1564
  * @method
1517
1565
  * @name idex#fetchTime
1518
1566
  * @description fetches the current integer timestamp in milliseconds from the exchange server
1567
+ * @see https://api-docs-v3.idex.io/#get-time
1519
1568
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1520
1569
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
1521
1570
  */
@@ -1530,6 +1579,7 @@ class idex extends idex$1 {
1530
1579
  * @method
1531
1580
  * @name idex#fetchWithdrawal
1532
1581
  * @description fetch data on a currency withdrawal via the withdrawal id
1582
+ * @see https://api-docs-v3.idex.io/#get-withdrawals
1533
1583
  * @param {string} id withdrawal id
1534
1584
  * @param {string} code not used by idex.fetchWithdrawal
1535
1585
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1550,6 +1600,7 @@ class idex extends idex$1 {
1550
1600
  * @method
1551
1601
  * @name idex#fetchWithdrawals
1552
1602
  * @description fetch all withdrawals made from an account
1603
+ * @see https://api-docs-v3.idex.io/#get-withdrawals
1553
1604
  * @param {string} code unified currency code
1554
1605
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
1555
1606
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
@@ -97,7 +97,7 @@ class indodax extends indodax$1 {
97
97
  'urls': {
98
98
  'logo': 'https://user-images.githubusercontent.com/51840849/87070508-9358c880-c221-11ea-8dc5-5391afbbb422.jpg',
99
99
  'api': {
100
- 'public': 'https://indodax.com/api',
100
+ 'public': 'https://indodax.com',
101
101
  'private': 'https://indodax.com/tapi',
102
102
  },
103
103
  'www': 'https://www.indodax.com',
@@ -107,14 +107,15 @@ class indodax extends indodax$1 {
107
107
  'api': {
108
108
  'public': {
109
109
  'get': {
110
- 'server_time': 5,
111
- 'pairs': 5,
112
- 'price_increments': 5,
113
- 'summaries': 5,
114
- 'ticker_all': 5,
115
- '{pair}/ticker': 5,
116
- '{pair}/trades': 5,
117
- '{pair}/depth': 5,
110
+ 'api/server_time': 5,
111
+ 'api/pairs': 5,
112
+ 'api/price_increments': 5,
113
+ 'api/summaries': 5,
114
+ 'api/ticker/{pair}': 5,
115
+ 'api/ticker_all': 5,
116
+ 'api/trades/{pair}': 5,
117
+ 'api/depth/{pair}': 5,
118
+ 'tradingview/history_v2': 5,
118
119
  },
119
120
  },
120
121
  'private': {
@@ -179,6 +180,16 @@ class indodax extends indodax$1 {
179
180
  // 'ETH': 'eth'
180
181
  // 'BASE': 'base'
181
182
  },
183
+ 'timeframes': {
184
+ '1m': '1',
185
+ '15m': '15',
186
+ '30m': '30',
187
+ '1h': '60',
188
+ '4h': '240',
189
+ '1d': '1D',
190
+ '3d': '3D',
191
+ '1w': '1W',
192
+ },
182
193
  },
183
194
  'commonCurrencies': {
184
195
  'STR': 'XLM',
@@ -198,10 +209,11 @@ class indodax extends indodax$1 {
198
209
  * @method
199
210
  * @name indodax#fetchTime
200
211
  * @description fetches the current integer timestamp in milliseconds from the exchange server
212
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#server-time
201
213
  * @param {object} [params] extra parameters specific to the exchange API endpoint
202
214
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
203
215
  */
204
- const response = await this.publicGetServerTime(params);
216
+ const response = await this.publicGetApiServerTime(params);
205
217
  //
206
218
  // {
207
219
  // "timezone": "UTC",
@@ -215,10 +227,11 @@ class indodax extends indodax$1 {
215
227
  * @method
216
228
  * @name indodax#fetchMarkets
217
229
  * @description retrieves data on all markets for indodax
230
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#pairs
218
231
  * @param {object} [params] extra parameters specific to the exchange API endpoint
219
232
  * @returns {object[]} an array of objects representing market data
220
233
  */
221
- const response = await this.publicGetPairs(params);
234
+ const response = await this.publicGetApiPairs(params);
222
235
  //
223
236
  // [
224
237
  // {
@@ -335,6 +348,7 @@ class indodax extends indodax$1 {
335
348
  * @method
336
349
  * @name indodax#fetchBalance
337
350
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
351
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-info-endpoint
338
352
  * @param {object} [params] extra parameters specific to the exchange API endpoint
339
353
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
340
354
  */
@@ -377,6 +391,7 @@ class indodax extends indodax$1 {
377
391
  * @method
378
392
  * @name indodax#fetchOrderBook
379
393
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
394
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#depth
380
395
  * @param {string} symbol unified symbol of the market to fetch the order book for
381
396
  * @param {int} [limit] the maximum amount of order book entries to return
382
397
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -385,9 +400,9 @@ class indodax extends indodax$1 {
385
400
  await this.loadMarkets();
386
401
  const market = this.market(symbol);
387
402
  const request = {
388
- 'pair': market['id'],
403
+ 'pair': market['base'] + market['quote'],
389
404
  };
390
- const orderbook = await this.publicGetPairDepth(this.extend(request, params));
405
+ const orderbook = await this.publicGetApiDepthPair(this.extend(request, params));
391
406
  return this.parseOrderBook(orderbook, market['symbol'], undefined, 'buy', 'sell');
392
407
  }
393
408
  parseTicker(ticker, market = undefined) {
@@ -436,6 +451,7 @@ class indodax extends indodax$1 {
436
451
  * @method
437
452
  * @name indodax#fetchTicker
438
453
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
454
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#ticker
439
455
  * @param {string} symbol unified symbol of the market to fetch the ticker for
440
456
  * @param {object} [params] extra parameters specific to the exchange API endpoint
441
457
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -443,9 +459,9 @@ class indodax extends indodax$1 {
443
459
  await this.loadMarkets();
444
460
  const market = this.market(symbol);
445
461
  const request = {
446
- 'pair': market['id'],
462
+ 'pair': market['base'] + market['quote'],
447
463
  };
448
- const response = await this.publicGetPairTicker(this.extend(request, params));
464
+ const response = await this.publicGetApiTickerPair(this.extend(request, params));
449
465
  //
450
466
  // {
451
467
  // "ticker": {
@@ -490,7 +506,7 @@ class indodax extends indodax$1 {
490
506
  // }
491
507
  // }
492
508
  //
493
- const response = await this.publicGetTickerAll(params);
509
+ const response = await this.publicGetApiTickerAll(params);
494
510
  const tickers = this.safeValue(response, 'tickers');
495
511
  return this.parseTickers(tickers, symbols);
496
512
  }
@@ -517,6 +533,7 @@ class indodax extends indodax$1 {
517
533
  * @method
518
534
  * @name indodax#fetchTrades
519
535
  * @description get the list of most recent trades for a particular symbol
536
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Public-RestAPI.md#trades
520
537
  * @param {string} symbol unified symbol of the market to fetch trades for
521
538
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
522
539
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -526,11 +543,81 @@ class indodax extends indodax$1 {
526
543
  await this.loadMarkets();
527
544
  const market = this.market(symbol);
528
545
  const request = {
529
- 'pair': market['id'],
546
+ 'pair': market['base'] + market['quote'],
530
547
  };
531
- const response = await this.publicGetPairTrades(this.extend(request, params));
548
+ const response = await this.publicGetApiTradesPair(this.extend(request, params));
532
549
  return this.parseTrades(response, market, since, limit);
533
550
  }
551
+ parseOHLCV(ohlcv, market = undefined) {
552
+ //
553
+ // {
554
+ // "Time": 1708416900,
555
+ // "Open": 51707.52,
556
+ // "High": 51707.52,
557
+ // "Low": 51707.52,
558
+ // "Close": 51707.52,
559
+ // "Volume": "0"
560
+ // }
561
+ //
562
+ return [
563
+ this.safeTimestamp(ohlcv, 'Time'),
564
+ this.safeNumber(ohlcv, 'Open'),
565
+ this.safeNumber(ohlcv, 'High'),
566
+ this.safeNumber(ohlcv, 'Low'),
567
+ this.safeNumber(ohlcv, 'Close'),
568
+ this.safeNumber(ohlcv, 'Volume'),
569
+ ];
570
+ }
571
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
572
+ /**
573
+ * @method
574
+ * @name indodax#fetchOHLCV
575
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
576
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
577
+ * @param {string} timeframe the length of time each candle represents
578
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
579
+ * @param {int} [limit] the maximum amount of candles to fetch
580
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
581
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
582
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
583
+ */
584
+ await this.loadMarkets();
585
+ const market = this.market(symbol);
586
+ const timeframes = this.options['timeframes'];
587
+ const selectedTimeframe = this.safeString(timeframes, timeframe, timeframe);
588
+ const now = this.seconds();
589
+ const until = this.safeInteger2(params, 'until', 'till', now);
590
+ params = this.omit(params, ['until', 'till']);
591
+ const request = {
592
+ 'to': until,
593
+ 'tf': selectedTimeframe,
594
+ 'symbol': market['base'] + market['quote'],
595
+ };
596
+ if (limit === undefined) {
597
+ limit = 1000;
598
+ }
599
+ if (since !== undefined) {
600
+ request['from'] = Math.floor(since / 1000);
601
+ }
602
+ else {
603
+ const duration = this.parseTimeframe(timeframe);
604
+ request['from'] = now - limit * duration - 1;
605
+ }
606
+ const response = await this.publicGetTradingviewHistoryV2(this.extend(request, params));
607
+ //
608
+ // [
609
+ // {
610
+ // "Time": 1708416900,
611
+ // "Open": 51707.52,
612
+ // "High": 51707.52,
613
+ // "Low": 51707.52,
614
+ // "Close": 51707.52,
615
+ // "Volume": "0"
616
+ // }
617
+ // ]
618
+ //
619
+ return this.parseOHLCVs(response, market, timeframe, since, limit);
620
+ }
534
621
  parseOrderStatus(status) {
535
622
  const statuses = {
536
623
  'open': 'open',
@@ -622,6 +709,7 @@ class indodax extends indodax$1 {
622
709
  * @method
623
710
  * @name indodax#fetchOrder
624
711
  * @description fetches information on an order made by the user
712
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#get-order-endpoints
625
713
  * @param {string} symbol unified symbol of the market the order was made in
626
714
  * @param {object} [params] extra parameters specific to the exchange API endpoint
627
715
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -646,6 +734,7 @@ class indodax extends indodax$1 {
646
734
  * @method
647
735
  * @name indodax#fetchOpenOrders
648
736
  * @description fetch all unfilled currently open orders
737
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#open-orders-endpoints
649
738
  * @param {string} symbol unified market symbol
650
739
  * @param {int} [since] the earliest time in ms to fetch open orders for
651
740
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -686,6 +775,7 @@ class indodax extends indodax$1 {
686
775
  * @method
687
776
  * @name indodax#fetchClosedOrders
688
777
  * @description fetches information on multiple closed orders made by the user
778
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#order-history
689
779
  * @param {string} symbol unified market symbol of the market orders were made in
690
780
  * @param {int} [since] the earliest time in ms to fetch orders for
691
781
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -710,6 +800,7 @@ class indodax extends indodax$1 {
710
800
  * @method
711
801
  * @name indodax#createOrder
712
802
  * @description create a trade order
803
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#trade-endpoints
713
804
  * @param {string} symbol unified symbol of the market to create an order in
714
805
  * @param {string} type 'market' or 'limit'
715
806
  * @param {string} side 'buy' or 'sell'
@@ -749,6 +840,7 @@ class indodax extends indodax$1 {
749
840
  * @method
750
841
  * @name indodax#cancelOrder
751
842
  * @description cancels an open order
843
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#cancel-order-endpoints
752
844
  * @param {string} id order id
753
845
  * @param {string} symbol unified symbol of the market the order was made in
754
846
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -775,6 +867,7 @@ class indodax extends indodax$1 {
775
867
  * @method
776
868
  * @name indodax#fetchTransactionFee
777
869
  * @description fetch the fee for a transaction
870
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-fee-endpoints
778
871
  * @param {string} code unified currency code
779
872
  * @param {object} [params] extra parameters specific to the exchange API endpoint
780
873
  * @returns {object} a [fee structure]{@link https://docs.ccxt.com/#/?id=fee-structure}
@@ -808,6 +901,7 @@ class indodax extends indodax$1 {
808
901
  * @method
809
902
  * @name indodax#fetchDepositsWithdrawals
810
903
  * @description fetch history of deposits and withdrawals
904
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#transaction-history-endpoints
811
905
  * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
812
906
  * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
813
907
  * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
@@ -909,6 +1003,7 @@ class indodax extends indodax$1 {
909
1003
  * @method
910
1004
  * @name indodax#withdraw
911
1005
  * @description make a withdrawal
1006
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#withdraw-coin-endpoints
912
1007
  * @param {string} code unified currency code
913
1008
  * @param {float} amount the amount to withdraw
914
1009
  * @param {string} address the address to withdraw to
@@ -1042,6 +1137,7 @@ class indodax extends indodax$1 {
1042
1137
  * @method
1043
1138
  * @name indodax#fetchDepositAddresses
1044
1139
  * @description fetch deposit addresses for multiple currencies and chain types
1140
+ * @see https://github.com/btcid/indodax-official-api-docs/blob/master/Private-RestAPI.md#general-information-on-endpoints
1045
1141
  * @param {string[]} [codes] list of unified currency codes, default is undefined
1046
1142
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1047
1143
  * @returns {object} a list of [address structures]{@link https://docs.ccxt.com/#/?id=address-structure}
@@ -1124,7 +1220,12 @@ class indodax extends indodax$1 {
1124
1220
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1125
1221
  let url = this.urls['api'][api];
1126
1222
  if (api === 'public') {
1127
- url += '/' + this.implodeParams(path, params);
1223
+ const query = this.omit(params, this.extractParams(path));
1224
+ const requestPath = '/' + this.implodeParams(path, params);
1225
+ url = url + requestPath;
1226
+ if (Object.keys(query).length) {
1227
+ url += '?' + this.urlencodeWithArrayRepeat(query);
1228
+ }
1128
1229
  }
1129
1230
  else {
1130
1231
  this.checkRequiredCredentials();
@@ -5228,6 +5228,7 @@ class okx extends okx$1 {
5228
5228
  * @method
5229
5229
  * @name okx#fetchPositions
5230
5230
  * @see https://www.okx.com/docs-v5/en/#rest-api-account-get-positions
5231
+ * @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history history
5231
5232
  * @description fetch all open positions
5232
5233
  * @param {string[]|undefined} symbols list of unified market symbols
5233
5234
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -5368,13 +5369,38 @@ class okx extends okx$1 {
5368
5369
  // "vegaBS": "",
5369
5370
  // "vegaPA": ""
5370
5371
  // }
5372
+ // history
5373
+ // {
5374
+ // "cTime":"1708351230102",
5375
+ // "ccy":"USDT",
5376
+ // "closeAvgPx":"1.2567",
5377
+ // "closeTotalPos":"40",
5378
+ // "direction":"short",
5379
+ // "fee":"-0.0351036",
5380
+ // "fundingFee":"0",
5381
+ // "instId":"SUSHI-USDT-SWAP",
5382
+ // "instType":"SWAP",
5383
+ // "lever":"10.0",
5384
+ // "liqPenalty":"0",
5385
+ // "mgnMode":"isolated",
5386
+ // "openAvgPx":"1.2462",
5387
+ // "openMaxPos":"40",
5388
+ // "pnl":"-0.42",
5389
+ // "pnlRatio":"-0.0912982667308618",
5390
+ // "posId":"666159086676836352",
5391
+ // "realizedPnl":"-0.4551036",
5392
+ // "triggerPx":"",
5393
+ // "type":"2",
5394
+ // "uTime":"1708354805699",
5395
+ // "uly":"SUSHI-USDT"
5396
+ // }
5371
5397
  //
5372
5398
  const marketId = this.safeString(position, 'instId');
5373
5399
  market = this.safeMarket(marketId, market);
5374
5400
  const symbol = market['symbol'];
5375
5401
  const pos = this.safeString(position, 'pos'); // 'pos' field: One way mode: 0 if position is not open, 1 if open | Two way (hedge) mode: -1 if short, 1 if long, 0 if position is not open
5376
5402
  const contractsAbs = Precise["default"].stringAbs(pos);
5377
- let side = this.safeString(position, 'posSide');
5403
+ let side = this.safeString2(position, 'posSide', 'direction');
5378
5404
  const hedged = side !== 'net';
5379
5405
  const contracts = this.parseNumber(contractsAbs);
5380
5406
  if (market['margin']) {
@@ -5415,7 +5441,7 @@ class okx extends okx$1 {
5415
5441
  const notional = this.parseNumber(notionalString);
5416
5442
  const marginMode = this.safeString(position, 'mgnMode');
5417
5443
  let initialMarginString = undefined;
5418
- const entryPriceString = this.safeString(position, 'avgPx');
5444
+ const entryPriceString = this.safeString2(position, 'avgPx', 'openAvgPx');
5419
5445
  const unrealizedPnlString = this.safeString(position, 'upl');
5420
5446
  const leverageString = this.safeString(position, 'lever');
5421
5447
  let initialMarginPercentage = undefined;
@@ -5446,23 +5472,24 @@ class okx extends okx$1 {
5446
5472
  const marginRatio = this.parseNumber(Precise["default"].stringDiv(maintenanceMarginString, collateralString, 4));
5447
5473
  return this.safePosition({
5448
5474
  'info': position,
5449
- 'id': undefined,
5475
+ 'id': this.safeString(position, 'posId'),
5450
5476
  'symbol': symbol,
5451
5477
  'notional': notional,
5452
5478
  'marginMode': marginMode,
5453
5479
  'liquidationPrice': liquidationPrice,
5454
5480
  'entryPrice': this.parseNumber(entryPriceString),
5455
5481
  'unrealizedPnl': this.parseNumber(unrealizedPnlString),
5482
+ 'realizedPnl': this.safeNumber(position, 'realizedPnl'),
5456
5483
  'percentage': percentage,
5457
5484
  'contracts': contracts,
5458
5485
  'contractSize': contractSize,
5459
5486
  'markPrice': this.parseNumber(markPriceString),
5460
- 'lastPrice': undefined,
5487
+ 'lastPrice': this.safeNumber(position, 'closeAvgPx'),
5461
5488
  'side': side,
5462
5489
  'hedged': hedged,
5463
5490
  'timestamp': timestamp,
5464
5491
  'datetime': this.iso8601(timestamp),
5465
- 'lastUpdateTimestamp': undefined,
5492
+ 'lastUpdateTimestamp': this.safeInteger(position, 'uTime'),
5466
5493
  'maintenanceMargin': maintenanceMargin,
5467
5494
  'maintenanceMarginPercentage': maintenanceMarginPercentage,
5468
5495
  'collateral': this.parseNumber(collateralString),