ccxt 4.4.68 → 4.4.70

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.
Files changed (51) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +0 -1
  5. package/dist/cjs/src/binance.js +20 -3
  6. package/dist/cjs/src/bitget.js +49 -335
  7. package/dist/cjs/src/bitstamp.js +2 -3
  8. package/dist/cjs/src/bybit.js +7 -0
  9. package/dist/cjs/src/coinbase.js +25 -9
  10. package/dist/cjs/src/cryptomus.js +214 -116
  11. package/dist/cjs/src/hyperliquid.js +19 -8
  12. package/dist/cjs/src/okx.js +4 -0
  13. package/dist/cjs/src/paradex.js +172 -4
  14. package/dist/cjs/src/phemex.js +2 -2
  15. package/dist/cjs/src/pro/bitget.js +40 -7
  16. package/dist/cjs/src/pro/bybit.js +86 -38
  17. package/dist/cjs/src/tradeogre.js +34 -11
  18. package/dist/cjs/src/whitebit.js +211 -1
  19. package/js/ccxt.d.ts +1 -1
  20. package/js/ccxt.js +1 -1
  21. package/js/src/abstract/bybit.d.ts +4 -0
  22. package/js/src/abstract/myokx.d.ts +3 -0
  23. package/js/src/abstract/okx.d.ts +3 -0
  24. package/js/src/abstract/paradex.d.ts +23 -0
  25. package/js/src/abstract/tradeogre.d.ts +2 -1
  26. package/js/src/base/Exchange.js +0 -1
  27. package/js/src/base/types.d.ts +2 -2
  28. package/js/src/binance.js +20 -3
  29. package/js/src/bitget.d.ts +0 -1
  30. package/js/src/bitget.js +49 -335
  31. package/js/src/bitstamp.js +2 -3
  32. package/js/src/bybit.js +7 -0
  33. package/js/src/coinbase.d.ts +0 -5
  34. package/js/src/coinbase.js +25 -9
  35. package/js/src/cryptomus.d.ts +127 -1
  36. package/js/src/cryptomus.js +214 -116
  37. package/js/src/hyperliquid.js +19 -8
  38. package/js/src/okx.d.ts +1 -0
  39. package/js/src/okx.js +4 -0
  40. package/js/src/paradex.d.ts +48 -1
  41. package/js/src/paradex.js +172 -4
  42. package/js/src/phemex.d.ts +1 -1
  43. package/js/src/phemex.js +2 -2
  44. package/js/src/pro/bitget.js +40 -7
  45. package/js/src/pro/bybit.d.ts +1 -0
  46. package/js/src/pro/bybit.js +86 -38
  47. package/js/src/tradeogre.d.ts +1 -0
  48. package/js/src/tradeogre.js +34 -11
  49. package/js/src/whitebit.d.ts +35 -1
  50. package/js/src/whitebit.js +211 -1
  51. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/whitebit.js';
2
- import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, Currencies, TradingFees, Dict, int, FundingRate, FundingRates, DepositAddress, Conversion, BorrowInterest, FundingHistory } from './base/types.js';
2
+ import type { TransferEntry, Balances, Currency, Int, Market, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, Num, Currencies, TradingFees, Dict, int, FundingRate, FundingRates, DepositAddress, Conversion, BorrowInterest, FundingHistory, Position } from './base/types.js';
3
3
  /**
4
4
  * @class whitebit
5
5
  * @augments Exchange
@@ -490,6 +490,40 @@ export default class whitebit extends Exchange {
490
490
  */
491
491
  fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
492
492
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
493
+ /**
494
+ * @method
495
+ * @name whitebit#fetchPositionHistory
496
+ * @description fetches historical positions
497
+ * @see https://docs.whitebit.com/private/http-trade-v4/#positions-history
498
+ * @param {string} symbol unified contract symbol
499
+ * @param {int} [since] the earliest time in ms to fetch positions for
500
+ * @param {int} [limit] the maximum amount of records to fetch
501
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
502
+ * @param {int} [params.positionId] the id of the requested position
503
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
504
+ */
505
+ fetchPositionHistory(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
506
+ /**
507
+ * @method
508
+ * @name whitebit#fetchPositions
509
+ * @description fetch all open positions
510
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
511
+ * @param {string[]} [symbols] list of unified market symbols
512
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
513
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
514
+ */
515
+ fetchPositions(symbols?: Strings, params?: {}): Promise<Position[]>;
516
+ /**
517
+ * @method
518
+ * @name whitebit#fetchPosition
519
+ * @description fetch data on a single open contract trade position
520
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
521
+ * @param {string} symbol unified market symbol of the market the position is held in
522
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
523
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
524
+ */
525
+ fetchPosition(symbol: string, params?: {}): Promise<Position>;
526
+ parsePosition(position: Dict, market?: Market): Position;
493
527
  isFiat(currency: string): boolean;
494
528
  nonce(): number;
495
529
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
@@ -22,7 +22,7 @@ export default class whitebit extends Exchange {
22
22
  'CORS': undefined,
23
23
  'spot': true,
24
24
  'margin': true,
25
- 'swap': false,
25
+ 'swap': true,
26
26
  'future': false,
27
27
  'option': false,
28
28
  'cancelAllOrders': true,
@@ -72,7 +72,10 @@ export default class whitebit extends Exchange {
72
72
  'fetchOpenOrders': true,
73
73
  'fetchOrderBook': true,
74
74
  'fetchOrderTrades': true,
75
+ 'fetchPosition': true,
76
+ 'fetchPositionHistory': true,
75
77
  'fetchPositionMode': false,
78
+ 'fetchPositions': true,
76
79
  'fetchPremiumIndexOHLCV': false,
77
80
  'fetchStatus': true,
78
81
  'fetchTicker': true,
@@ -2958,6 +2961,213 @@ export default class whitebit extends Exchange {
2958
2961
  'fee': undefined,
2959
2962
  };
2960
2963
  }
2964
+ /**
2965
+ * @method
2966
+ * @name whitebit#fetchPositionHistory
2967
+ * @description fetches historical positions
2968
+ * @see https://docs.whitebit.com/private/http-trade-v4/#positions-history
2969
+ * @param {string} symbol unified contract symbol
2970
+ * @param {int} [since] the earliest time in ms to fetch positions for
2971
+ * @param {int} [limit] the maximum amount of records to fetch
2972
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
2973
+ * @param {int} [params.positionId] the id of the requested position
2974
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2975
+ */
2976
+ async fetchPositionHistory(symbol, since = undefined, limit = undefined, params = {}) {
2977
+ await this.loadMarkets();
2978
+ const market = this.market(symbol);
2979
+ let request = {
2980
+ 'market': market['id'],
2981
+ };
2982
+ if (since !== undefined) {
2983
+ request['startDate'] = since;
2984
+ }
2985
+ if (limit !== undefined) {
2986
+ request['limit'] = since;
2987
+ }
2988
+ [request, params] = this.handleUntilOption('endDate', request, params);
2989
+ const response = await this.v4PrivatePostCollateralAccountPositionsHistory(this.extend(request, params));
2990
+ //
2991
+ // [
2992
+ // {
2993
+ // "positionId": 479975679,
2994
+ // "market": "BTC_PERP",
2995
+ // "openDate": 1741941025.309887,
2996
+ // "modifyDate": 1741941025.309887,
2997
+ // "amount": "0.001",
2998
+ // "basePrice": "82498.7",
2999
+ // "realizedFunding": "0",
3000
+ // "liquidationPrice": "0",
3001
+ // "liquidationState": null,
3002
+ // "orderDetail": {
3003
+ // "id": 1224727949521,
3004
+ // "tradeAmount": "0.001",
3005
+ // "price": "82498.7",
3006
+ // "tradeFee": "0.028874545",
3007
+ // "fundingFee": "0",
3008
+ // "realizedPnl": "-0.028874545"
3009
+ // }
3010
+ // }
3011
+ // ]
3012
+ //
3013
+ const positions = this.parsePositions(response);
3014
+ return this.filterBySymbolSinceLimit(positions, symbol, since, limit);
3015
+ }
3016
+ /**
3017
+ * @method
3018
+ * @name whitebit#fetchPositions
3019
+ * @description fetch all open positions
3020
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
3021
+ * @param {string[]} [symbols] list of unified market symbols
3022
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3023
+ * @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
3024
+ */
3025
+ async fetchPositions(symbols = undefined, params = {}) {
3026
+ await this.loadMarkets();
3027
+ symbols = this.marketSymbols(symbols);
3028
+ const response = await this.v4PrivatePostCollateralAccountPositionsOpen(params);
3029
+ //
3030
+ // [
3031
+ // {
3032
+ // "positionId": 479975679,
3033
+ // "market": "BTC_PERP",
3034
+ // "openDate": 1741941025.3098869,
3035
+ // "modifyDate": 1741941025.3098869,
3036
+ // "amount": "0.001",
3037
+ // "basePrice": "82498.7",
3038
+ // "liquidationPrice": "70177.2",
3039
+ // "pnl": "0",
3040
+ // "pnlPercent": "0.00",
3041
+ // "margin": "4.2",
3042
+ // "freeMargin": "9.9",
3043
+ // "funding": "0",
3044
+ // "unrealizedFunding": "0",
3045
+ // "liquidationState": null,
3046
+ // "tpsl": null
3047
+ // }
3048
+ // ]
3049
+ //
3050
+ return this.parsePositions(response, symbols);
3051
+ }
3052
+ /**
3053
+ * @method
3054
+ * @name whitebit#fetchPosition
3055
+ * @description fetch data on a single open contract trade position
3056
+ * @see https://docs.whitebit.com/private/http-trade-v4/#open-positions
3057
+ * @param {string} symbol unified market symbol of the market the position is held in
3058
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3059
+ * @returns {object} a [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
3060
+ */
3061
+ async fetchPosition(symbol, params = {}) {
3062
+ await this.loadMarkets();
3063
+ const market = this.market(symbol);
3064
+ const request = {
3065
+ 'symbol': market['id'],
3066
+ };
3067
+ const response = await this.v4PrivatePostCollateralAccountPositionsOpen(this.extend(request, params));
3068
+ //
3069
+ // [
3070
+ // {
3071
+ // "positionId": 479975679,
3072
+ // "market": "BTC_PERP",
3073
+ // "openDate": 1741941025.3098869,
3074
+ // "modifyDate": 1741941025.3098869,
3075
+ // "amount": "0.001",
3076
+ // "basePrice": "82498.7",
3077
+ // "liquidationPrice": "70177.2",
3078
+ // "pnl": "0",
3079
+ // "pnlPercent": "0.00",
3080
+ // "margin": "4.2",
3081
+ // "freeMargin": "9.9",
3082
+ // "funding": "0",
3083
+ // "unrealizedFunding": "0",
3084
+ // "liquidationState": null,
3085
+ // "tpsl": null
3086
+ // }
3087
+ // ]
3088
+ //
3089
+ const data = this.safeDict(response, 0, {});
3090
+ return this.parsePosition(data, market);
3091
+ }
3092
+ parsePosition(position, market = undefined) {
3093
+ //
3094
+ // fetchPosition, fetchPositions
3095
+ //
3096
+ // {
3097
+ // "positionId": 479975679,
3098
+ // "market": "BTC_PERP",
3099
+ // "openDate": 1741941025.3098869,
3100
+ // "modifyDate": 1741941025.3098869,
3101
+ // "amount": "0.001",
3102
+ // "basePrice": "82498.7",
3103
+ // "liquidationPrice": "70177.2",
3104
+ // "pnl": "0",
3105
+ // "pnlPercent": "0.00",
3106
+ // "margin": "4.2",
3107
+ // "freeMargin": "9.9",
3108
+ // "funding": "0",
3109
+ // "unrealizedFunding": "0",
3110
+ // "liquidationState": null,
3111
+ // "tpsl": null
3112
+ // }
3113
+ //
3114
+ // fetchPositionHistory
3115
+ //
3116
+ // {
3117
+ // "positionId": 479975679,
3118
+ // "market": "BTC_PERP",
3119
+ // "openDate": 1741941025.309887,
3120
+ // "modifyDate": 1741941025.309887,
3121
+ // "amount": "0.001",
3122
+ // "basePrice": "82498.7",
3123
+ // "realizedFunding": "0",
3124
+ // "liquidationPrice": "0",
3125
+ // "liquidationState": null,
3126
+ // "orderDetail": {
3127
+ // "id": 1224727949521,
3128
+ // "tradeAmount": "0.001",
3129
+ // "price": "82498.7",
3130
+ // "tradeFee": "0.028874545",
3131
+ // "fundingFee": "0",
3132
+ // "realizedPnl": "-0.028874545"
3133
+ // }
3134
+ // }
3135
+ //
3136
+ const marketId = this.safeString(position, 'market');
3137
+ const timestamp = this.safeTimestamp(position, 'openDate');
3138
+ const tpsl = this.safeDict(position, 'tpsl', {});
3139
+ const orderDetail = this.safeDict(position, 'orderDetail', {});
3140
+ return this.safePosition({
3141
+ 'info': position,
3142
+ 'id': this.safeString(position, 'positionId'),
3143
+ 'symbol': this.safeSymbol(marketId, market),
3144
+ 'notional': undefined,
3145
+ 'marginMode': undefined,
3146
+ 'liquidationPrice': this.safeNumber(position, 'liquidationPrice'),
3147
+ 'entryPrice': this.safeNumber(position, 'basePrice'),
3148
+ 'unrealizedPnl': this.safeNumber(position, 'pnl'),
3149
+ 'realizedPnl': this.safeNumber(orderDetail, 'realizedPnl'),
3150
+ 'percentage': this.safeNumber(position, 'pnlPercent'),
3151
+ 'contracts': undefined,
3152
+ 'contractSize': undefined,
3153
+ 'markPrice': undefined,
3154
+ 'lastPrice': undefined,
3155
+ 'side': undefined,
3156
+ 'hedged': undefined,
3157
+ 'timestamp': timestamp,
3158
+ 'datetime': this.iso8601(timestamp),
3159
+ 'lastUpdateTimestamp': this.safeTimestamp(position, 'modifyDate'),
3160
+ 'maintenanceMargin': undefined,
3161
+ 'maintenanceMarginPercentage': undefined,
3162
+ 'collateral': this.safeNumber(position, 'margin'),
3163
+ 'initialMargin': undefined,
3164
+ 'initialMarginPercentage': undefined,
3165
+ 'leverage': undefined,
3166
+ 'marginRatio': undefined,
3167
+ 'stopLossPrice': this.safeNumber(tpsl, 'stopLoss'),
3168
+ 'takeProfitPrice': this.safeNumber(tpsl, 'takeProfit'),
3169
+ });
3170
+ }
2961
3171
  isFiat(currency) {
2962
3172
  const fiatCurrencies = this.safeValue(this.options, 'fiatCurrencies', []);
2963
3173
  return this.inArray(currency, fiatCurrencies);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.4.68",
3
+ "version": "4.4.70",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",