ccxt 4.0.108 → 4.0.110

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.
@@ -1105,9 +1105,10 @@ class phemex extends phemex$1 {
1105
1105
  * @see https://github.com/phemex/phemex-api-docs/blob/master/Public-Contract-API-en.md#query-kline
1106
1106
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
1107
1107
  * @param {string} timeframe the length of time each candle represents
1108
- * @param {int} [since] *emulated not supported by the exchange* timestamp in ms of the earliest candle to fetch
1108
+ * @param {int} [since] *only used for USDT settled contracts, otherwise is emulated and not supported by the exchange* timestamp in ms of the earliest candle to fetch
1109
1109
  * @param {int} [limit] the maximum amount of candles to fetch
1110
1110
  * @param {object} [params] extra parameters specific to the phemex api endpoint
1111
+ * @param {int} [params.until] *USDT settled/ linear swaps only* end time in ms
1111
1112
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
1112
1113
  */
1113
1114
  await this.loadMarkets();
@@ -1117,34 +1118,55 @@ class phemex extends phemex$1 {
1117
1118
  'symbol': market['id'],
1118
1119
  'resolution': this.safeString(this.timeframes, timeframe, timeframe),
1119
1120
  };
1120
- const possibleLimitValues = [5, 10, 50, 100, 500, 1000];
1121
- const maxLimit = 1000;
1122
- if (limit === undefined && since === undefined) {
1123
- limit = possibleLimitValues[5];
1124
- }
1125
- if (since !== undefined) {
1126
- // phemex also provides kline query with from/to, however, this interface is NOT recommended and does not work properly.
1127
- // we do not send since param to the exchange, instead we calculate appropriate limit param
1128
- const duration = this.parseTimeframe(timeframe) * 1000;
1129
- const timeDelta = this.milliseconds() - since;
1130
- limit = this.parseToInt(timeDelta / duration); // setting limit to the number of candles after since
1131
- }
1132
- if (limit > maxLimit) {
1121
+ const until = this.safeInteger2(params, 'until', 'to');
1122
+ params = this.omit(params, ['until']);
1123
+ const usesSpecialFromToEndpoint = ((market['linear'] || market['settle'] === 'USDT')) && ((since !== undefined) || (until !== undefined));
1124
+ let maxLimit = 1000;
1125
+ if (usesSpecialFromToEndpoint) {
1126
+ maxLimit = 2000;
1127
+ }
1128
+ if (limit === undefined) {
1133
1129
  limit = maxLimit;
1134
1130
  }
1135
- else {
1136
- for (let i = 0; i < possibleLimitValues.length; i++) {
1137
- if (limit <= possibleLimitValues[i]) {
1138
- limit = possibleLimitValues[i];
1139
- }
1140
- }
1141
- }
1142
- request['limit'] = limit;
1131
+ request['limit'] = Math.min(limit, maxLimit);
1143
1132
  let response = undefined;
1144
1133
  if (market['linear'] || market['settle'] === 'USDT') {
1145
- response = await this.publicGetMdV2KlineLast(this.extend(request, params));
1134
+ if ((until !== undefined) || (since !== undefined)) {
1135
+ const candleDuration = this.parseTimeframe(timeframe);
1136
+ if (since !== undefined) {
1137
+ since = Math.round(since / 1000);
1138
+ request['from'] = since;
1139
+ }
1140
+ else {
1141
+ // when 'to' is defined since is mandatory
1142
+ since = (until / 100) - (maxLimit * candleDuration);
1143
+ }
1144
+ if (until !== undefined) {
1145
+ request['to'] = Math.round(until / 1000);
1146
+ }
1147
+ else {
1148
+ // when since is defined 'to' is mandatory
1149
+ let to = since + (maxLimit * candleDuration);
1150
+ const now = this.seconds();
1151
+ if (to > now) {
1152
+ to = now;
1153
+ }
1154
+ request['to'] = to;
1155
+ }
1156
+ response = await this.publicGetMdV2KlineList(this.extend(request, params));
1157
+ }
1158
+ else {
1159
+ response = await this.publicGetMdV2KlineLast(this.extend(request, params));
1160
+ }
1146
1161
  }
1147
1162
  else {
1163
+ if (since !== undefined) {
1164
+ // phemex also provides kline query with from/to, however, this interface is NOT recommended and does not work properly.
1165
+ // we do not send since param to the exchange, instead we calculate appropriate limit param
1166
+ const duration = this.parseTimeframe(timeframe) * 1000;
1167
+ const timeDelta = this.milliseconds() - since;
1168
+ limit = this.parseToInt(timeDelta / duration); // setting limit to the number of candles after since
1169
+ }
1148
1170
  response = await this.publicGetMdV2Kline(this.extend(request, params));
1149
1171
  }
1150
1172
  //
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.0.107";
7
+ declare const version = "4.0.109";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.0.108';
41
+ const version = '4.0.110';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -2607,9 +2607,6 @@ export default class bitfinex2 extends Exchange {
2607
2607
  else if (type.indexOf('fee') >= 0 || type.indexOf('charged') >= 0) {
2608
2608
  return 'fee';
2609
2609
  }
2610
- else if (type.indexOf('exchange') >= 0 || type.indexOf('position') >= 0) {
2611
- return 'trade';
2612
- }
2613
2610
  else if (type.indexOf('rebate') >= 0) {
2614
2611
  return 'rebate';
2615
2612
  }
@@ -2622,6 +2619,9 @@ export default class bitfinex2 extends Exchange {
2622
2619
  else if (type.indexOf('payment') >= 0) {
2623
2620
  return 'payout';
2624
2621
  }
2622
+ else if (type.indexOf('exchange') >= 0 || type.indexOf('position') >= 0) {
2623
+ return 'trade';
2624
+ }
2625
2625
  else {
2626
2626
  return type;
2627
2627
  }
@@ -150,6 +150,7 @@ export default class bitflyer extends Exchange {
150
150
  * @method
151
151
  * @name bitflyer#fetchMarkets
152
152
  * @description retrieves data on all markets for bitflyer
153
+ * @see https://lightning.bitflyer.com/docs?lang=en#market-list
153
154
  * @param {object} [params] extra parameters specific to the exchange api endpoint
154
155
  * @returns {object[]} an array of objects representing market data
155
156
  */
@@ -317,6 +318,7 @@ export default class bitflyer extends Exchange {
317
318
  * @method
318
319
  * @name bitflyer#fetchBalance
319
320
  * @description query for balance and get the amount of funds available for trading or funds locked in orders
321
+ * @see https://lightning.bitflyer.com/docs?lang=en#get-account-asset-balance
320
322
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
321
323
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
322
324
  */
@@ -348,6 +350,7 @@ export default class bitflyer extends Exchange {
348
350
  * @method
349
351
  * @name bitflyer#fetchOrderBook
350
352
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
353
+ * @see https://lightning.bitflyer.com/docs?lang=en#order-book
351
354
  * @param {string} symbol unified symbol of the market to fetch the order book for
352
355
  * @param {int} [limit] the maximum amount of order book entries to return
353
356
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
@@ -393,6 +396,7 @@ export default class bitflyer extends Exchange {
393
396
  * @method
394
397
  * @name bitflyer#fetchTicker
395
398
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
399
+ * @see https://lightning.bitflyer.com/docs?lang=en#ticker
396
400
  * @param {string} symbol unified symbol of the market to fetch the ticker for
397
401
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
398
402
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -474,6 +478,7 @@ export default class bitflyer extends Exchange {
474
478
  * @method
475
479
  * @name bitflyer#fetchTrades
476
480
  * @description get the list of most recent trades for a particular symbol
481
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-executions
477
482
  * @param {string} symbol unified symbol of the market to fetch trades for
478
483
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
479
484
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -509,6 +514,7 @@ export default class bitflyer extends Exchange {
509
514
  * @method
510
515
  * @name bitflyer#fetchTradingFee
511
516
  * @description fetch the trading fees for a market
517
+ * @see https://lightning.bitflyer.com/docs?lang=en#get-trading-commission
512
518
  * @param {string} symbol unified market symbol
513
519
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
514
520
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -537,6 +543,7 @@ export default class bitflyer extends Exchange {
537
543
  * @method
538
544
  * @name bitflyer#createOrder
539
545
  * @description create a trade order
546
+ * @see https://lightning.bitflyer.com/docs?lang=en#send-a-new-order
540
547
  * @param {string} symbol unified symbol of the market to create an order in
541
548
  * @param {string} type 'market' or 'limit'
542
549
  * @param {string} side 'buy' or 'sell'
@@ -566,6 +573,7 @@ export default class bitflyer extends Exchange {
566
573
  * @method
567
574
  * @name bitflyer#cancelOrder
568
575
  * @description cancels an open order
576
+ * @see https://lightning.bitflyer.com/docs?lang=en#cancel-order
569
577
  * @param {string} id order id
570
578
  * @param {string} symbol unified symbol of the market the order was made in
571
579
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
@@ -642,6 +650,7 @@ export default class bitflyer extends Exchange {
642
650
  * @method
643
651
  * @name bitflyer#fetchOrders
644
652
  * @description fetches information on multiple orders made by the user
653
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
645
654
  * @param {string} symbol unified market symbol of the market orders were made in
646
655
  * @param {int} [since] the earliest time in ms to fetch orders for
647
656
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -669,6 +678,7 @@ export default class bitflyer extends Exchange {
669
678
  * @method
670
679
  * @name bitflyer#fetchOpenOrders
671
680
  * @description fetch all unfilled currently open orders
681
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
672
682
  * @param {string} symbol unified market symbol
673
683
  * @param {int} [since] the earliest time in ms to fetch open orders for
674
684
  * @param {int} [limit] the maximum number of open orders structures to retrieve
@@ -685,6 +695,7 @@ export default class bitflyer extends Exchange {
685
695
  * @method
686
696
  * @name bitflyer#fetchClosedOrders
687
697
  * @description fetches information on multiple closed orders made by the user
698
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
688
699
  * @param {string} symbol unified market symbol of the market orders were made in
689
700
  * @param {int} [since] the earliest time in ms to fetch orders for
690
701
  * @param {int} [limit] the maximum number of orde structures to retrieve
@@ -701,6 +712,7 @@ export default class bitflyer extends Exchange {
701
712
  * @method
702
713
  * @name bitflyer#fetchOrder
703
714
  * @description fetches information on an order made by the user
715
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-orders
704
716
  * @param {string} symbol unified symbol of the market the order was made in
705
717
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
706
718
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -720,6 +732,7 @@ export default class bitflyer extends Exchange {
720
732
  * @method
721
733
  * @name bitflyer#fetchMyTrades
722
734
  * @description fetch all trades made by the user
735
+ * @see https://lightning.bitflyer.com/docs?lang=en#list-executions
723
736
  * @param {string} symbol unified market symbol
724
737
  * @param {int} [since] the earliest time in ms to fetch trades for
725
738
  * @param {int} [limit] the maximum number of trades structures to retrieve
@@ -759,6 +772,7 @@ export default class bitflyer extends Exchange {
759
772
  * @method
760
773
  * @name bitflyer#fetchPositions
761
774
  * @description fetch all open positions
775
+ * @see https://lightning.bitflyer.com/docs?lang=en#get-open-interest-summary
762
776
  * @param {string[]} symbols list of unified market symbols
763
777
  * @param {object} [params] extra parameters specific to the bitflyer api endpoint
764
778
  * @returns {object[]} a list of [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
@@ -796,6 +810,7 @@ export default class bitflyer extends Exchange {
796
810
  * @method
797
811
  * @name bitflyer#withdraw
798
812
  * @description make a withdrawal
813
+ * @see https://lightning.bitflyer.com/docs?lang=en#withdrawing-funds
799
814
  * @param {string} code unified currency code
800
815
  * @param {float} amount the amount to withdraw
801
816
  * @param {string} address the address to withdraw to
@@ -827,6 +842,7 @@ export default class bitflyer extends Exchange {
827
842
  * @method
828
843
  * @name bitflyer#fetchDeposits
829
844
  * @description fetch all deposits made to an account
845
+ * @see https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-deposit-history
830
846
  * @param {string} code unified currency code
831
847
  * @param {int} [since] the earliest time in ms to fetch deposits for
832
848
  * @param {int} [limit] the maximum number of deposits structures to retrieve
@@ -864,6 +880,7 @@ export default class bitflyer extends Exchange {
864
880
  * @method
865
881
  * @name bitflyer#fetchWithdrawals
866
882
  * @description fetch all withdrawals made from an account
883
+ * @see https://lightning.bitflyer.com/docs?lang=en#get-crypto-assets-transaction-history
867
884
  * @param {string} code unified currency code
868
885
  * @param {int} [since] the earliest time in ms to fetch withdrawals for
869
886
  * @param {int} [limit] the maximum number of withdrawals structures to retrieve
package/js/src/bitget.js CHANGED
@@ -891,6 +891,7 @@ export default class bitget extends Exchange {
891
891
  '40712': InsufficientFunds,
892
892
  '40713': ExchangeError,
893
893
  '40714': ExchangeError,
894
+ '40768': OrderNotFound,
894
895
  '41114': OnMaintenance,
895
896
  '43011': InvalidOrder,
896
897
  '43025': InvalidOrder,
@@ -1066,6 +1067,7 @@ export default class bitget extends Exchange {
1066
1067
  * @method
1067
1068
  * @name bitget#fetchTime
1068
1069
  * @description fetches the current integer timestamp in milliseconds from the exchange server
1070
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-server-time
1069
1071
  * @param {object} [params] extra parameters specific to the bitget api endpoint
1070
1072
  * @returns {int} the current integer timestamp in milliseconds from the exchange server
1071
1073
  */
@@ -1085,6 +1087,8 @@ export default class bitget extends Exchange {
1085
1087
  * @method
1086
1088
  * @name bitget#fetchMarkets
1087
1089
  * @description retrieves data on all markets for bitget
1090
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-symbols
1091
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-all-symbols
1088
1092
  * @param {object} [params] extra parameters specific to the exchange api endpoint
1089
1093
  * @returns {object[]} an array of objects representing market data
1090
1094
  */
@@ -1358,6 +1362,7 @@ export default class bitget extends Exchange {
1358
1362
  * @method
1359
1363
  * @name bitget#fetchCurrencies
1360
1364
  * @description fetches all available currencies on an exchange
1365
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-coin-list
1361
1366
  * @param {object} [params] extra parameters specific to the bitget api endpoint
1362
1367
  * @returns {object} an associative dictionary of currencies
1363
1368
  */
@@ -1798,6 +1803,7 @@ export default class bitget extends Exchange {
1798
1803
  * @method
1799
1804
  * @name bitget#fetchDepositAddress
1800
1805
  * @description fetch the deposit address for a currency associated with this account
1806
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-coin-address
1801
1807
  * @param {string} code unified currency code
1802
1808
  * @param {object} [params] extra parameters specific to the bitget api endpoint
1803
1809
  * @returns {object} an [address structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#address-structure}
@@ -1855,6 +1861,8 @@ export default class bitget extends Exchange {
1855
1861
  * @method
1856
1862
  * @name bitget#fetchOrderBook
1857
1863
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
1864
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-depth
1865
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-depth
1858
1866
  * @param {string} symbol unified symbol of the market to fetch the order book for
1859
1867
  * @param {int} [limit] the maximum amount of order book entries to return
1860
1868
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -2013,6 +2021,8 @@ export default class bitget extends Exchange {
2013
2021
  * @method
2014
2022
  * @name bitget#fetchTicker
2015
2023
  * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
2024
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-single-ticker
2025
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-single-symbol-ticker
2016
2026
  * @param {string} symbol unified symbol of the market to fetch the ticker for
2017
2027
  * @param {object} [params] extra parameters specific to the bitget api endpoint
2018
2028
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
@@ -2344,6 +2354,7 @@ export default class bitget extends Exchange {
2344
2354
  * @method
2345
2355
  * @name bitget#fetchTradingFee
2346
2356
  * @description fetch the trading fees for a market
2357
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-single-symbol
2347
2358
  * @param {string} symbol unified market symbol
2348
2359
  * @param {object} [params] extra parameters specific to the bitget api endpoint
2349
2360
  * @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
@@ -2382,6 +2393,7 @@ export default class bitget extends Exchange {
2382
2393
  * @method
2383
2394
  * @name bitget#fetchTradingFees
2384
2395
  * @description fetch the trading fees for multiple markets
2396
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-symbols
2385
2397
  * @param {object} [params] extra parameters specific to the bitget api endpoint
2386
2398
  * @returns {object} a dictionary of [fee structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure} indexed by market symbols
2387
2399
  */
@@ -2580,9 +2592,9 @@ export default class bitget extends Exchange {
2580
2592
  /**
2581
2593
  * @method
2582
2594
  * @name bitget#fetchBalance
2595
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
2583
2596
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-account-assets
2584
2597
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-account-list
2585
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
2586
2598
  * @param {object} [params] extra parameters specific to the bitget api endpoint
2587
2599
  * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
2588
2600
  */
@@ -2840,13 +2852,13 @@ export default class bitget extends Exchange {
2840
2852
  /**
2841
2853
  * @method
2842
2854
  * @name bitget#createOrder
2855
+ * @description create a trade order
2843
2856
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#place-order
2844
2857
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#place-plan-order
2845
2858
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#place-order
2846
2859
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#place-stop-order
2847
2860
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#place-position-tpsl
2848
2861
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#place-plan-order
2849
- * @description create a trade order
2850
2862
  * @param {string} symbol unified symbol of the market to create an order in
2851
2863
  * @param {string} type 'market' or 'limit'
2852
2864
  * @param {string} side 'buy' or 'sell' or 'open_long' or 'open_short' or 'close_long' or 'close_short'
@@ -3039,6 +3051,10 @@ export default class bitget extends Exchange {
3039
3051
  * @method
3040
3052
  * @name bitget#editOrder
3041
3053
  * @description edit a trade order
3054
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#modify-plan-order
3055
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#modify-plan-order
3056
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#modify-plan-order-tpsl
3057
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#modify-stop-order
3042
3058
  * @param {string} id cancel order id
3043
3059
  * @param {string} symbol unified symbol of the market to create an order in
3044
3060
  * @param {string} type 'market' or 'limit'
@@ -3142,6 +3158,10 @@ export default class bitget extends Exchange {
3142
3158
  * @method
3143
3159
  * @name bitget#cancelOrder
3144
3160
  * @description cancels an open order
3161
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#cancel-order
3162
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#cancel-plan-order
3163
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-order
3164
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-plan-order-tpsl
3145
3165
  * @param {string} id order id
3146
3166
  * @param {string} symbol unified symbol of the market the order was made in
3147
3167
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -3186,6 +3206,8 @@ export default class bitget extends Exchange {
3186
3206
  * @method
3187
3207
  * @name bitget#cancelOrders
3188
3208
  * @description cancel multiple orders
3209
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#cancel-order-in-batch-v2-single-instruments
3210
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-cancel-order
3189
3211
  * @param {string[]} ids order ids
3190
3212
  * @param {string} symbol unified market symbol, default is undefined
3191
3213
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -3324,6 +3346,8 @@ export default class bitget extends Exchange {
3324
3346
  * @method
3325
3347
  * @name bitget#fetchOrder
3326
3348
  * @description fetches information on an order made by the user
3349
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-details
3350
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-order-details
3327
3351
  * @param {string} symbol unified symbol of the market the order was made in
3328
3352
  * @param {object} [params] extra parameters specific to the bitget api endpoint
3329
3353
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -3405,11 +3429,11 @@ export default class bitget extends Exchange {
3405
3429
  /**
3406
3430
  * @method
3407
3431
  * @name bitget#fetchOpenOrders
3432
+ * @description fetch all unfilled currently open orders
3408
3433
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-order-list
3409
3434
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-all-open-order
3410
3435
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-plan-order-tpsl-list
3411
3436
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-open-order
3412
- * @description fetch all unfilled currently open orders
3413
3437
  * @param {string} symbol unified market symbol
3414
3438
  * @param {int} [since] the earliest time in ms to fetch open orders for
3415
3439
  * @param {int} [limit] the maximum number of open order structures to retrieve
@@ -3791,6 +3815,7 @@ export default class bitget extends Exchange {
3791
3815
  * @method
3792
3816
  * @name bitget#fetchLedger
3793
3817
  * @description fetch the history of changes, actions done by the user or operations that altered balance of the user
3818
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-bills
3794
3819
  * @param {string} code unified currency code, default is undefined
3795
3820
  * @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
3796
3821
  * @param {int} [limit] max number of ledger entrys to return, default is undefined
@@ -3934,6 +3959,8 @@ export default class bitget extends Exchange {
3934
3959
  * @method
3935
3960
  * @name bitget#fetchOrderTrades
3936
3961
  * @description fetch all the trades made from a single order
3962
+ * @see https://bitgetlimited.github.io/apidoc/en/spot/#get-transaction-details
3963
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-order-fill-detail
3937
3964
  * @param {string} id order id
3938
3965
  * @param {string} symbol unified market symbol
3939
3966
  * @param {int} [since] the earliest time in ms to fetch trades for
@@ -3986,6 +4013,7 @@ export default class bitget extends Exchange {
3986
4013
  * @method
3987
4014
  * @name bitget#fetchPosition
3988
4015
  * @description fetch data on a single open contract trade position
4016
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-symbol-position-v2
3989
4017
  * @param {string} symbol unified market symbol of the market the position is held in, default is undefined
3990
4018
  * @param {object} [params] extra parameters specific to the bitget api endpoint
3991
4019
  * @returns {object} a [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
@@ -4035,6 +4063,8 @@ export default class bitget extends Exchange {
4035
4063
  * @method
4036
4064
  * @name bitget#fetchPositions
4037
4065
  * @description fetch all open positions
4066
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-all-position-v2
4067
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-position
4038
4068
  * @param {string[]|undefined} symbols list of unified market symbols
4039
4069
  * @param {object} [params] extra parameters specific to the bitget api endpoint
4040
4070
  * @returns {object[]} a list of [position structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#position-structure}
@@ -4294,6 +4324,7 @@ export default class bitget extends Exchange {
4294
4324
  * @method
4295
4325
  * @name bitget#fetchFundingRateHistory
4296
4326
  * @description fetches historical funding rate prices
4327
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-history-funding-rate
4297
4328
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
4298
4329
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
4299
4330
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
@@ -4350,6 +4381,7 @@ export default class bitget extends Exchange {
4350
4381
  * @method
4351
4382
  * @name bitget#fetchFundingRate
4352
4383
  * @description fetch the current funding rate
4384
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-current-funding-rate
4353
4385
  * @param {string} symbol unified market symbol
4354
4386
  * @param {object} [params] extra parameters specific to the bitget api endpoint
4355
4387
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
@@ -4553,6 +4585,7 @@ export default class bitget extends Exchange {
4553
4585
  * @method
4554
4586
  * @name bitget#reduceMargin
4555
4587
  * @description remove margin from a position
4588
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#change-margin
4556
4589
  * @param {string} symbol unified market symbol
4557
4590
  * @param {float} amount the amount of margin to remove
4558
4591
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -4572,6 +4605,7 @@ export default class bitget extends Exchange {
4572
4605
  * @method
4573
4606
  * @name bitget#addMargin
4574
4607
  * @description add margin
4608
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#change-margin
4575
4609
  * @param {string} symbol unified market symbol
4576
4610
  * @param {float} amount amount of margin to add
4577
4611
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -4588,6 +4622,7 @@ export default class bitget extends Exchange {
4588
4622
  * @method
4589
4623
  * @name bitget#fetchLeverage
4590
4624
  * @description fetch the set leverage for a market
4625
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#get-single-account
4591
4626
  * @param {string} symbol unified market symbol
4592
4627
  * @param {object} [params] extra parameters specific to the bitget api endpoint
4593
4628
  * @returns {object} a [leverage structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#leverage-structure}
@@ -4632,6 +4667,7 @@ export default class bitget extends Exchange {
4632
4667
  * @method
4633
4668
  * @name bitget#setLeverage
4634
4669
  * @description set the level of leverage for a market
4670
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#change-leverage
4635
4671
  * @param {float} leverage the rate of leverage
4636
4672
  * @param {string} symbol unified market symbol
4637
4673
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -4653,6 +4689,7 @@ export default class bitget extends Exchange {
4653
4689
  * @method
4654
4690
  * @name bitget#setMarginMode
4655
4691
  * @description set margin mode to 'cross' or 'isolated'
4692
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#change-margin-mode
4656
4693
  * @param {string} marginMode 'cross' or 'isolated'
4657
4694
  * @param {string} symbol unified market symbol
4658
4695
  * @param {object} [params] extra parameters specific to the bitget api endpoint
@@ -4683,6 +4720,7 @@ export default class bitget extends Exchange {
4683
4720
  * @method
4684
4721
  * @name bitget#setPositionMode
4685
4722
  * @description set hedged to true or false for a market
4723
+ * @see https://bitgetlimited.github.io/apidoc/en/mix/#change-hold-mode
4686
4724
  * @param {bool} hedged set to true to use dualSidePosition
4687
4725
  * @param {string} symbol not used by bitget setPositionMode ()
4688
4726
  * @param {object} [params] extra parameters specific to the bitget api endpoint
package/js/src/bitmart.js CHANGED
@@ -1951,7 +1951,7 @@ export default class bitmart extends Exchange {
1951
1951
  // "updateTime" : 1681701559408
1952
1952
  // }
1953
1953
  //
1954
- // swap: fetchOpenOrders
1954
+ // swap: fetchOrder, fetchOpenOrders
1955
1955
  //
1956
1956
  // {
1957
1957
  // "order_id": "230935812485489",
@@ -2494,29 +2494,95 @@ export default class bitmart extends Exchange {
2494
2494
  /**
2495
2495
  * @method
2496
2496
  * @name bitmart#fetchOrder
2497
+ * @description fetches information on an order made by the user
2497
2498
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-id-v4-signed
2498
2499
  * @see https://developer-pro.bitmart.com/en/spot/#query-order-by-clientorderid-v4-signed
2499
- * @description fetches information on an order made by the user
2500
+ * @see https://developer-pro.bitmart.com/en/futures/#get-order-detail-keyed
2501
+ * @param {string} id the id of the order
2500
2502
  * @param {string} symbol unified symbol of the market the order was made in
2501
2503
  * @param {object} [params] extra parameters specific to the bitmart api endpoint
2502
- * @param {string} [params.clientOrderId] fetch the order by client order id instead of order id
2504
+ * @param {string} [params.clientOrderId] *spot* fetch the order by client order id instead of order id
2503
2505
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
2504
2506
  */
2505
2507
  await this.loadMarkets();
2506
2508
  const request = {};
2507
- const clientOrderId = this.safeString(params, 'clientOrderId');
2508
- if (!clientOrderId) {
2509
- request['orderId'] = id;
2510
- }
2509
+ let type = undefined;
2510
+ let market = undefined;
2511
2511
  let response = undefined;
2512
- if (clientOrderId !== undefined) {
2513
- response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
2512
+ if (symbol !== undefined) {
2513
+ market = this.market(symbol);
2514
2514
  }
2515
- else {
2516
- response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
2515
+ [type, params] = this.handleMarketTypeAndParams('fetchOrder', market, params);
2516
+ if (type === 'spot') {
2517
+ const clientOrderId = this.safeString(params, 'clientOrderId');
2518
+ if (!clientOrderId) {
2519
+ request['orderId'] = id;
2520
+ }
2521
+ if (clientOrderId !== undefined) {
2522
+ response = await this.privatePostSpotV4QueryClientOrder(this.extend(request, params));
2523
+ }
2524
+ else {
2525
+ response = await this.privatePostSpotV4QueryOrder(this.extend(request, params));
2526
+ }
2517
2527
  }
2528
+ else if (type === 'swap') {
2529
+ this.checkRequiredSymbol('fetchOrder', symbol);
2530
+ request['symbol'] = market['id'];
2531
+ request['order_id'] = id;
2532
+ response = await this.privateGetContractPrivateOrder(this.extend(request, params));
2533
+ }
2534
+ //
2535
+ // spot
2536
+ //
2537
+ // {
2538
+ // "code": 1000,
2539
+ // "message": "success",
2540
+ // "data": {
2541
+ // "orderId": "183347420821295423",
2542
+ // "clientOrderId": "183347420821295423",
2543
+ // "symbol": "BTC_USDT",
2544
+ // "side": "buy",
2545
+ // "orderMode": "spot",
2546
+ // "type": "limit",
2547
+ // "state": "new",
2548
+ // "price": "24000.00",
2549
+ // "priceAvg": "0.00",
2550
+ // "size": "0.00022",
2551
+ // "filledSize": "0.00000",
2552
+ // "notional": "5.28000000",
2553
+ // "filledNotional": "0.00000000",
2554
+ // "createTime": 1695783014734,
2555
+ // "updateTime": 1695783014762
2556
+ // },
2557
+ // "trace": "ce3e6422c8b44d5fag855348a68693ed.63.14957831547451715"
2558
+ // }
2559
+ //
2560
+ // swap
2561
+ //
2562
+ // {
2563
+ // "code": 1000,
2564
+ // "message": "Ok",
2565
+ // "data": {
2566
+ // "order_id": "230927283405028",
2567
+ // "client_order_id": "",
2568
+ // "price": "23000",
2569
+ // "size": "1",
2570
+ // "symbol": "BTCUSDT",
2571
+ // "state": 2,
2572
+ // "side": 1,
2573
+ // "type": "limit",
2574
+ // "leverage": "10",
2575
+ // "open_type": "isolated",
2576
+ // "deal_avg_price": "0",
2577
+ // "deal_size": "0",
2578
+ // "create_time": 1695783433600,
2579
+ // "update_time": 1695783433613
2580
+ // },
2581
+ // "trace": "4cad855075664097af6ba5257c47605d.63.14957831547451715"
2582
+ // }
2583
+ //
2518
2584
  const data = this.safeValue(response, 'data', {});
2519
- return this.parseOrder(data, undefined);
2585
+ return this.parseOrder(data, market);
2520
2586
  }
2521
2587
  async fetchDepositAddress(code, params = {}) {
2522
2588
  /**