ccxt 4.5.38 → 4.5.40

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 (117) hide show
  1. package/README.md +5 -7
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -6
  4. package/dist/cjs/src/base/Exchange.js +62 -5
  5. package/dist/cjs/src/binance.js +151 -2
  6. package/dist/cjs/src/bingx.js +137 -120
  7. package/dist/cjs/src/bitget.js +47 -1
  8. package/dist/cjs/src/bitmart.js +23 -8
  9. package/dist/cjs/src/bitmex.js +416 -0
  10. package/dist/cjs/src/bitstamp.js +264 -43
  11. package/dist/cjs/src/bitvavo.js +10 -0
  12. package/dist/cjs/src/blofin.js +85 -0
  13. package/dist/cjs/src/btcmarkets.js +1 -1
  14. package/dist/cjs/src/bybit.js +135 -0
  15. package/dist/cjs/src/coinspot.js +77 -7
  16. package/dist/cjs/src/delta.js +367 -0
  17. package/dist/cjs/src/htx.js +265 -2
  18. package/dist/cjs/src/hyperliquid.js +37 -8
  19. package/dist/cjs/src/krakenfutures.js +4 -0
  20. package/dist/cjs/src/kucoinfutures.js +121 -0
  21. package/dist/cjs/src/mexc.js +9 -1
  22. package/dist/cjs/src/phemex.js +359 -0
  23. package/dist/cjs/src/poloniex.js +5 -0
  24. package/dist/cjs/src/pro/binance.js +111 -26
  25. package/dist/cjs/src/pro/bingx.js +33 -33
  26. package/dist/cjs/src/pro/bitget.js +48 -90
  27. package/dist/cjs/src/pro/bitmart.js +68 -0
  28. package/dist/cjs/src/pro/blofin.js +52 -1
  29. package/dist/cjs/src/pro/bybit.js +2 -2
  30. package/dist/cjs/src/pro/coinbaseinternational.js +5 -2
  31. package/dist/cjs/src/pro/mexc.js +72 -0
  32. package/dist/cjs/src/pro/okx.js +8 -5
  33. package/dist/cjs/src/pro/paradex.js +137 -0
  34. package/dist/cjs/src/pro/woo.js +43 -0
  35. package/dist/cjs/src/tokocrypto.js +23 -0
  36. package/dist/cjs/src/toobit.js +20 -0
  37. package/dist/cjs/src/whitebit.js +11 -10
  38. package/dist/cjs/src/woo.js +103 -3
  39. package/js/ccxt.d.ts +3 -9
  40. package/js/ccxt.js +2 -6
  41. package/js/src/abstract/binance.d.ts +5 -0
  42. package/js/src/abstract/binancecoinm.d.ts +5 -0
  43. package/js/src/abstract/binanceus.d.ts +5 -0
  44. package/js/src/abstract/binanceusdm.d.ts +5 -0
  45. package/js/src/abstract/bitget.d.ts +47 -1
  46. package/js/src/abstract/bitstamp.d.ts +1 -1
  47. package/js/src/abstract/bitvavo.d.ts +10 -0
  48. package/js/src/abstract/coinspot.d.ts +45 -0
  49. package/js/src/base/Exchange.d.ts +11 -8
  50. package/js/src/base/Exchange.js +65 -5
  51. package/js/src/base/types.d.ts +9 -0
  52. package/js/src/binance.d.ts +26 -1
  53. package/js/src/binance.js +151 -2
  54. package/js/src/bingx.d.ts +113 -108
  55. package/js/src/bingx.js +137 -120
  56. package/js/src/bitget.js +47 -1
  57. package/js/src/bitmart.js +23 -8
  58. package/js/src/bitmex.d.ts +50 -1
  59. package/js/src/bitmex.js +416 -0
  60. package/js/src/bitstamp.d.ts +52 -1
  61. package/js/src/bitstamp.js +264 -43
  62. package/js/src/bitvavo.js +10 -0
  63. package/js/src/blofin.d.ts +12 -1
  64. package/js/src/blofin.js +85 -0
  65. package/js/src/btcmarkets.js +1 -1
  66. package/js/src/bybit.d.ts +12 -1
  67. package/js/src/bybit.js +135 -0
  68. package/js/src/coinspot.js +77 -7
  69. package/js/src/delta.d.ts +12 -1
  70. package/js/src/delta.js +367 -0
  71. package/js/src/htx.d.ts +15 -1
  72. package/js/src/htx.js +265 -2
  73. package/js/src/hyperliquid.js +37 -8
  74. package/js/src/krakenfutures.js +4 -0
  75. package/js/src/kucoinfutures.d.ts +12 -1
  76. package/js/src/kucoinfutures.js +121 -0
  77. package/js/src/mexc.js +9 -1
  78. package/js/src/phemex.d.ts +16 -1
  79. package/js/src/phemex.js +359 -0
  80. package/js/src/poloniex.js +5 -0
  81. package/js/src/pro/binance.d.ts +13 -0
  82. package/js/src/pro/binance.js +111 -26
  83. package/js/src/pro/bingx.d.ts +33 -33
  84. package/js/src/pro/bingx.js +33 -33
  85. package/js/src/pro/bitget.d.ts +6 -6
  86. package/js/src/pro/bitget.js +48 -90
  87. package/js/src/pro/bitmart.d.ts +22 -1
  88. package/js/src/pro/bitmart.js +69 -1
  89. package/js/src/pro/blofin.d.ts +12 -1
  90. package/js/src/pro/blofin.js +52 -1
  91. package/js/src/pro/bybit.d.ts +1 -1
  92. package/js/src/pro/bybit.js +2 -2
  93. package/js/src/pro/coinbaseinternational.d.ts +2 -2
  94. package/js/src/pro/coinbaseinternational.js +6 -3
  95. package/js/src/pro/mexc.d.ts +22 -1
  96. package/js/src/pro/mexc.js +72 -0
  97. package/js/src/pro/okx.d.ts +4 -4
  98. package/js/src/pro/okx.js +8 -5
  99. package/js/src/pro/paradex.d.ts +23 -1
  100. package/js/src/pro/paradex.js +137 -0
  101. package/js/src/pro/woo.d.ts +12 -1
  102. package/js/src/pro/woo.js +43 -0
  103. package/js/src/tokocrypto.js +23 -0
  104. package/js/src/toobit.js +20 -0
  105. package/js/src/whitebit.js +8 -8
  106. package/js/src/woo.d.ts +12 -1
  107. package/js/src/woo.js +103 -3
  108. package/package.json +1 -1
  109. package/dist/cjs/src/abstract/probit.js +0 -11
  110. package/dist/cjs/src/pro/probit.js +0 -594
  111. package/dist/cjs/src/probit.js +0 -1936
  112. package/js/src/abstract/probit.d.ts +0 -26
  113. package/js/src/abstract/probit.js +0 -11
  114. package/js/src/pro/probit.d.ts +0 -91
  115. package/js/src/pro/probit.js +0 -593
  116. package/js/src/probit.d.ts +0 -283
  117. package/js/src/probit.js +0 -1935
package/js/src/bitmex.js CHANGED
@@ -77,16 +77,21 @@ export default class bitmex extends Exchange {
77
77
  'fetchMyLiquidations': false,
78
78
  'fetchMyTrades': true,
79
79
  'fetchOHLCV': true,
80
+ 'fetchOpenInterest': 'emulated',
81
+ 'fetchOpenInterests': true,
80
82
  'fetchOpenOrders': true,
81
83
  'fetchOrder': true,
82
84
  'fetchOrderBook': true,
83
85
  'fetchOrders': true,
84
86
  'fetchPosition': false,
87
+ 'fetchPositionADLRank': true,
85
88
  'fetchPositionHistory': false,
86
89
  'fetchPositions': true,
90
+ 'fetchPositionsADLRank': true,
87
91
  'fetchPositionsHistory': false,
88
92
  'fetchPositionsRisk': false,
89
93
  'fetchPremiumIndexOHLCV': false,
94
+ 'fetchSettlementHistory': true,
90
95
  'fetchTicker': true,
91
96
  'fetchTickers': true,
92
97
  'fetchTrades': true,
@@ -2962,6 +2967,70 @@ export default class bitmex extends Exchange {
2962
2967
  //
2963
2968
  return this.parseDepositWithdrawFees(assets, codes, 'asset');
2964
2969
  }
2970
+ /**
2971
+ * @method
2972
+ * @name bitmex#fetchOpenInterests
2973
+ * @description Retrieves the open interest for a list of symbols
2974
+ * @see https://docs.bitmex.com/api-explorer/get-stats
2975
+ * @param {string[]} [symbols] a list of unified CCXT market symbols
2976
+ * @param {object} [params] exchange specific parameters
2977
+ * @returns {object[]} a list of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
2978
+ */
2979
+ async fetchOpenInterests(symbols = undefined, params = {}) {
2980
+ await this.loadMarkets();
2981
+ const request = {};
2982
+ let response = undefined;
2983
+ response = await this.publicGetStats(this.extend(request, params));
2984
+ //
2985
+ // [
2986
+ // {
2987
+ // currency: 'XBt',
2988
+ // openInterest: '0',
2989
+ // openValue: '323890820079',
2990
+ // rootSymbol: 'Total',
2991
+ // turnover24h: '447088001322',
2992
+ // volume24h: '0'
2993
+ // }
2994
+ // ...
2995
+ // ]
2996
+ //
2997
+ symbols = this.marketSymbols(symbols);
2998
+ return this.parseOpenInterests(response, symbols);
2999
+ }
3000
+ parseOpenInterest(interest, market = undefined) {
3001
+ //
3002
+ // fetchOpenInterest
3003
+ //
3004
+ // {
3005
+ // currency: 'XBt',
3006
+ // openInterest: '0',
3007
+ // openValue: '323890820079',
3008
+ // rootSymbol: 'Total',
3009
+ // turnover24h: '447088001322',
3010
+ // volume24h: '0'
3011
+ // }
3012
+ //
3013
+ const quoteId = this.safeString(interest, 'currency');
3014
+ const baseId = this.safeString(interest, 'rootSymbol');
3015
+ const quoteSymbol = this.safeCurrencyCode(quoteId);
3016
+ const baseSymbol = this.safeCurrencyCode(baseId);
3017
+ let symbol = baseSymbol;
3018
+ if (quoteSymbol !== undefined) {
3019
+ symbol = baseSymbol + '/' + quoteSymbol + ':' + quoteSymbol;
3020
+ }
3021
+ const openInterest = this.safeNumber(interest, 'openInterest');
3022
+ const openValue = this.safeNumber(interest, 'openValue');
3023
+ return this.safeOpenInterest({
3024
+ 'info': interest,
3025
+ 'symbol': symbol,
3026
+ 'baseVolume': openInterest,
3027
+ 'quoteVolume': openValue,
3028
+ 'openInterestAmount': openInterest,
3029
+ 'openInterestValue': openValue,
3030
+ 'timestamp': undefined,
3031
+ 'datetime': undefined,
3032
+ }, market);
3033
+ }
2965
3034
  calculateRateLimiterCost(api, method, path, params, config = {}) {
2966
3035
  const isAuthenticated = this.checkRequiredCredentials(false);
2967
3036
  const cost = this.safeValue(config, 'cost', 1);
@@ -3044,6 +3113,353 @@ export default class bitmex extends Exchange {
3044
3113
  'datetime': undefined,
3045
3114
  });
3046
3115
  }
3116
+ /**
3117
+ * @method
3118
+ * @name bitmex#fetchPositionsADLRank
3119
+ * @description fetches the auto deleveraging rank and risk percentage for a list of symbols
3120
+ * @see https://www.bitmex.com/api/explorer/#!/Position/Position_get
3121
+ * @param {string[]} [symbols] list of unified market symbols
3122
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
3123
+ * @returns {object[]} an [auto de leverage structure]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
3124
+ */
3125
+ async fetchPositionsADLRank(symbols = undefined, params = {}) {
3126
+ await this.loadMarkets();
3127
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
3128
+ const response = await this.privateGetPosition(params);
3129
+ //
3130
+ // [
3131
+ // {
3132
+ // "account": 395724,
3133
+ // "symbol": "XBTUSDT",
3134
+ // "strategy": "OneWay",
3135
+ // "currency": "USDt",
3136
+ // "underlying": "XBT",
3137
+ // "quoteCurrency": "USDT",
3138
+ // "commission": 0.0005,
3139
+ // "initMarginReq": 0.01,
3140
+ // "maintMarginReq": 0.005,
3141
+ // "riskLimit": 1000000000000,
3142
+ // "leverage": 100,
3143
+ // "crossMargin": true,
3144
+ // "deleveragePercentile": 1,
3145
+ // "rebalancedPnl": -4319,
3146
+ // "prevRealisedPnl": 0,
3147
+ // "prevUnrealisedPnl": null,
3148
+ // "openingQty": null,
3149
+ // "openOrderBuyQty": 0,
3150
+ // "openOrderBuyCost": 0,
3151
+ // "openOrderBuyPremium": 0,
3152
+ // "openOrderSellQty": 0,
3153
+ // "openOrderSellCost": 0,
3154
+ // "openOrderSellPremium": 0,
3155
+ // "currentQty": 100,
3156
+ // "currentCost": 8639330,
3157
+ // "currentComm": 0,
3158
+ // "realisedCost": 0,
3159
+ // "unrealisedCost": 8639330,
3160
+ // "grossOpenPremium": 0,
3161
+ // "isOpen": true,
3162
+ // "markPrice": 88636.92,
3163
+ // "markValue": 8863692,
3164
+ // "riskValue": 8863692,
3165
+ // "homeNotional": 0.0001,
3166
+ // "foreignNotional": -8.863692,
3167
+ // "posCost": 8639330,
3168
+ // "posCross": 0,
3169
+ // "posComm": 0,
3170
+ // "posLoss": 0,
3171
+ // "posMargin": 44061,
3172
+ // "posMaint": 44061,
3173
+ // "posInit": 0,
3174
+ // "initMargin": 0,
3175
+ // "maintMargin": 44061,
3176
+ // "realisedPnl": 0,
3177
+ // "unrealisedPnl": 224362,
3178
+ // "unrealisedPnlPcnt": 0.026,
3179
+ // "unrealisedRoePcnt": 2.597,
3180
+ // "avgCostPrice": 86393.3,
3181
+ // "avgEntryPrice": 86393.3,
3182
+ // "breakEvenPrice": 86436.5,
3183
+ // "marginCallPrice": null,
3184
+ // "liquidationPrice": 0,
3185
+ // "bankruptPrice": 0,
3186
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3187
+ // "positionReport": {
3188
+ // "account": 395724,
3189
+ // "avgCostPrice": 86393.3,
3190
+ // "avgEntryPrice": 86393.3,
3191
+ // "bankruptPrice": 0,
3192
+ // "breakEvenPrice": 86436.5,
3193
+ // "commission": 0.0005,
3194
+ // "crossMargin": true,
3195
+ // "currency": "USDt",
3196
+ // "currentComm": 0,
3197
+ // "currentCost": 8639330,
3198
+ // "currentQty": 100,
3199
+ // "deleveragePercentile": 1,
3200
+ // "foreignNotional": -8.863692,
3201
+ // "grossOpenPremium": 0,
3202
+ // "homeNotional": 0.0001,
3203
+ // "initMargin": 0,
3204
+ // "initMarginReq": 0.01,
3205
+ // "isOpen": true,
3206
+ // "leverage": 100,
3207
+ // "liquidationPrice": 0,
3208
+ // "maintMargin": 44061,
3209
+ // "maintMarginReq": 0.005,
3210
+ // "markPrice": 88636.92,
3211
+ // "markValue": 8863692,
3212
+ // "openOrderBuyCost": 0,
3213
+ // "openOrderBuyPremium": 0,
3214
+ // "openOrderBuyQty": 0,
3215
+ // "openOrderRealisedPnl": 0,
3216
+ // "openOrderSellCost": 0,
3217
+ // "openOrderSellPremium": 0,
3218
+ // "openOrderSellQty": 0,
3219
+ // "posComm": 0,
3220
+ // "posCost": 8639330,
3221
+ // "posCross": 0,
3222
+ // "posInit": 0,
3223
+ // "posLoss": 0,
3224
+ // "posMaint": 44061,
3225
+ // "posMargin": 44061,
3226
+ // "prevRealisedPnl": 0,
3227
+ // "quoteCurrency": "USDT",
3228
+ // "realisedCost": 0,
3229
+ // "realisedPnl": 0,
3230
+ // "rebalancedPnl": -4319,
3231
+ // "riskLimit": 1000000000000,
3232
+ // "riskValue": 8863692,
3233
+ // "strategy": "OneWay",
3234
+ // "symbol": "XBTUSDT",
3235
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3236
+ // "underlying": "XBT",
3237
+ // "unrealisedCost": 8639330,
3238
+ // "unrealisedPnl": 224362,
3239
+ // "unrealisedPnlPcnt": 0.026,
3240
+ // "unrealisedRoePcnt": 2.597
3241
+ // }
3242
+ // }
3243
+ // ]
3244
+ //
3245
+ return this.parseADLRanks(response, symbols);
3246
+ }
3247
+ parseADLRank(info, market = undefined) {
3248
+ //
3249
+ // fetchPositionsADLRank
3250
+ //
3251
+ // {
3252
+ // "account": 395724,
3253
+ // "symbol": "XBTUSDT",
3254
+ // "strategy": "OneWay",
3255
+ // "currency": "USDt",
3256
+ // "underlying": "XBT",
3257
+ // "quoteCurrency": "USDT",
3258
+ // "commission": 0.0005,
3259
+ // "initMarginReq": 0.01,
3260
+ // "maintMarginReq": 0.005,
3261
+ // "riskLimit": 1000000000000,
3262
+ // "leverage": 100,
3263
+ // "crossMargin": true,
3264
+ // "deleveragePercentile": 1,
3265
+ // "rebalancedPnl": -4319,
3266
+ // "prevRealisedPnl": 0,
3267
+ // "prevUnrealisedPnl": null,
3268
+ // "openingQty": null,
3269
+ // "openOrderBuyQty": 0,
3270
+ // "openOrderBuyCost": 0,
3271
+ // "openOrderBuyPremium": 0,
3272
+ // "openOrderSellQty": 0,
3273
+ // "openOrderSellCost": 0,
3274
+ // "openOrderSellPremium": 0,
3275
+ // "currentQty": 100,
3276
+ // "currentCost": 8639330,
3277
+ // "currentComm": 0,
3278
+ // "realisedCost": 0,
3279
+ // "unrealisedCost": 8639330,
3280
+ // "grossOpenPremium": 0,
3281
+ // "isOpen": true,
3282
+ // "markPrice": 88636.92,
3283
+ // "markValue": 8863692,
3284
+ // "riskValue": 8863692,
3285
+ // "homeNotional": 0.0001,
3286
+ // "foreignNotional": -8.863692,
3287
+ // "posCost": 8639330,
3288
+ // "posCross": 0,
3289
+ // "posComm": 0,
3290
+ // "posLoss": 0,
3291
+ // "posMargin": 44061,
3292
+ // "posMaint": 44061,
3293
+ // "posInit": 0,
3294
+ // "initMargin": 0,
3295
+ // "maintMargin": 44061,
3296
+ // "realisedPnl": 0,
3297
+ // "unrealisedPnl": 224362,
3298
+ // "unrealisedPnlPcnt": 0.026,
3299
+ // "unrealisedRoePcnt": 2.597,
3300
+ // "avgCostPrice": 86393.3,
3301
+ // "avgEntryPrice": 86393.3,
3302
+ // "breakEvenPrice": 86436.5,
3303
+ // "marginCallPrice": null,
3304
+ // "liquidationPrice": 0,
3305
+ // "bankruptPrice": 0,
3306
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3307
+ // "positionReport": {
3308
+ // "account": 395724,
3309
+ // "avgCostPrice": 86393.3,
3310
+ // "avgEntryPrice": 86393.3,
3311
+ // "bankruptPrice": 0,
3312
+ // "breakEvenPrice": 86436.5,
3313
+ // "commission": 0.0005,
3314
+ // "crossMargin": true,
3315
+ // "currency": "USDt",
3316
+ // "currentComm": 0,
3317
+ // "currentCost": 8639330,
3318
+ // "currentQty": 100,
3319
+ // "deleveragePercentile": 1,
3320
+ // "foreignNotional": -8.863692,
3321
+ // "grossOpenPremium": 0,
3322
+ // "homeNotional": 0.0001,
3323
+ // "initMargin": 0,
3324
+ // "initMarginReq": 0.01,
3325
+ // "isOpen": true,
3326
+ // "leverage": 100,
3327
+ // "liquidationPrice": 0,
3328
+ // "maintMargin": 44061,
3329
+ // "maintMarginReq": 0.005,
3330
+ // "markPrice": 88636.92,
3331
+ // "markValue": 8863692,
3332
+ // "openOrderBuyCost": 0,
3333
+ // "openOrderBuyPremium": 0,
3334
+ // "openOrderBuyQty": 0,
3335
+ // "openOrderRealisedPnl": 0,
3336
+ // "openOrderSellCost": 0,
3337
+ // "openOrderSellPremium": 0,
3338
+ // "openOrderSellQty": 0,
3339
+ // "posComm": 0,
3340
+ // "posCost": 8639330,
3341
+ // "posCross": 0,
3342
+ // "posInit": 0,
3343
+ // "posLoss": 0,
3344
+ // "posMaint": 44061,
3345
+ // "posMargin": 44061,
3346
+ // "prevRealisedPnl": 0,
3347
+ // "quoteCurrency": "USDT",
3348
+ // "realisedCost": 0,
3349
+ // "realisedPnl": 0,
3350
+ // "rebalancedPnl": -4319,
3351
+ // "riskLimit": 1000000000000,
3352
+ // "riskValue": 8863692,
3353
+ // "strategy": "OneWay",
3354
+ // "symbol": "XBTUSDT",
3355
+ // "timestamp": "2025-12-31T07:55:50.505Z",
3356
+ // "underlying": "XBT",
3357
+ // "unrealisedCost": 8639330,
3358
+ // "unrealisedPnl": 224362,
3359
+ // "unrealisedPnlPcnt": 0.026,
3360
+ // "unrealisedRoePcnt": 2.597
3361
+ // }
3362
+ // }
3363
+ //
3364
+ const marketId = this.safeString(info, 'symbol');
3365
+ const datetime = this.safeString(info, 'timestamp');
3366
+ return {
3367
+ 'info': info,
3368
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3369
+ 'rank': this.safeInteger(info, 'deleveragePercentile'),
3370
+ 'rating': undefined,
3371
+ 'percentage': undefined,
3372
+ 'timestamp': this.parse8601(datetime),
3373
+ 'datetime': datetime,
3374
+ };
3375
+ }
3376
+ /**
3377
+ * @method
3378
+ * @name bitmex#fetchSettlementHistory
3379
+ * @description fetches historical settlement records
3380
+ * @see https://docs.bitmex.com/api-explorer/get-settlements
3381
+ * @param {string} symbol unified market symbol of the settlement history
3382
+ * @param {int} [since] timestamp in ms
3383
+ * @param {int} [limit] number of records
3384
+ * @param {object} [params] exchange specific params
3385
+ * @param {int} [params.until] timestamp in ms
3386
+ *
3387
+ * EXCHANGE SPECIFIC PARAMETERS
3388
+ * @param {string} [params.filter] generic table filter, send json key/value pairs, such as {"key": "value"}, you can key on individual fields, and do more advanced querying on timestamps, see the timestamp docs for more details, default value = {}
3389
+ * @param {string} [params.columns] array of column names to fetch, if omitted, will return all columns, note that this method will always return item keys, even when not specified, so you may receive more columns that you expect
3390
+ * @param {int} [params.start] possible values are >= 0 starting point for results, default value = 0
3391
+ * @param {boolean} [params.reverse] if true, will sort results newest first, default value = false
3392
+ * @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/?id=settlement-history-structure}
3393
+ */
3394
+ async fetchSettlementHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
3395
+ await this.loadMarkets();
3396
+ const request = {
3397
+ // symbol string Instrument symbol. Send a bare series (e.g. XBT) to get data for the nearest expiring contract in that series. You can also send a timeframe, e.g. XBT:quarterly. Timeframes are nearest, daily, weekly, monthly, quarterly, biquarterly, and perpetual. Symbols are case-insensitive.
3398
+ // filter string Generic table filter. Send JSON key/value pairs, such as {"key": "value"}. You can key on individual fields, and do more advanced querying on timestamps. See the Timestamp Docs for more details. Default value: {}
3399
+ // columns string Array of column names to fetch. If omitted, will return all columns. Note that this method will always return item keys, even when not specified, so you may receive more columns that you expect.
3400
+ // count int32 Possible values: >= 1 and <= 500 Number of results to fetch. Must be a positive integer. Default value: 100
3401
+ // start int32 Possible values: >= 0 Starting point for results. Default value: 0
3402
+ // reverse boolean If true, will sort results newest first. Default value: false
3403
+ // startTime string Starting time filter for results.
3404
+ // endTime string Ending time filter for results.
3405
+ };
3406
+ let market = undefined;
3407
+ if (symbol !== undefined) {
3408
+ market = this.market(symbol);
3409
+ request['symbol'] = market['id'];
3410
+ }
3411
+ if (since !== undefined) {
3412
+ request['startTime'] = this.iso8601(since);
3413
+ }
3414
+ if (limit !== undefined) {
3415
+ request['count'] = limit;
3416
+ }
3417
+ const until = this.safeString(params, 'until');
3418
+ if (until !== undefined) {
3419
+ request['endTime'] = this.iso8601(since);
3420
+ params = this.omit(params, 'until');
3421
+ }
3422
+ const response = await this.publicGetSettlement(this.extend(request, params));
3423
+ //
3424
+ // [
3425
+ // {
3426
+ // timestamp: '2025-03-28T12:00:00.000Z',
3427
+ // symbol: 'ETHUSDH25',
3428
+ // settlementType: 'Settlement',
3429
+ // settledPrice: '1897.53'
3430
+ // }
3431
+ // ]
3432
+ //
3433
+ return this.parseSettlements(response, market, since, limit);
3434
+ }
3435
+ parseSettlements(settlements, market = undefined, since = undefined, limit = undefined) {
3436
+ const result = [];
3437
+ for (let i = 0; i < settlements.length; i++) {
3438
+ result.push(this.parseSettlement(settlements[i], market));
3439
+ }
3440
+ const sorted = this.sortBy(result, 'timestamp');
3441
+ const symbol = this.safeString(market, 'symbol');
3442
+ return this.filterBySymbolSinceLimit(sorted, symbol, since, limit);
3443
+ }
3444
+ parseSettlement(settlement, market = undefined) {
3445
+ //
3446
+ // {
3447
+ // timestamp: '2025-03-28T12:00:00.000Z',
3448
+ // symbol: 'ETHUSDH25',
3449
+ // settlementType: 'Settlement',
3450
+ // settledPrice: '1897.53'
3451
+ // }
3452
+ //
3453
+ const datetime = this.safeString(settlement, 'timestamp');
3454
+ const marketId = this.safeString(settlement, 'symbol');
3455
+ return {
3456
+ 'info': settlement,
3457
+ 'symbol': this.safeSymbol(marketId, market),
3458
+ 'price': this.safeNumber(settlement, 'settledPrice'),
3459
+ 'timestamp': this.parse8601(datetime),
3460
+ 'datetime': datetime,
3461
+ };
3462
+ }
3047
3463
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
3048
3464
  if (response === undefined) {
3049
3465
  return undefined;
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitstamp.js';
2
- import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, int, LedgerEntry, DepositAddress } from './base/types.js';
2
+ import type { Balances, Currencies, Currency, Dict, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry, int, LedgerEntry, DepositAddress, FundingRateHistory, FundingRate } from './base/types.js';
3
3
  /**
4
4
  * @class bitstamp
5
5
  * @augments Exchange
@@ -190,6 +190,24 @@ export default class bitstamp extends Exchange {
190
190
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
191
191
  */
192
192
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
193
+ /**
194
+ * @method
195
+ * @name bitstamp#editOrder
196
+ * @description edit a trade order
197
+ * @see https://www.bitstamp.net/api/#tag/Orders/operation/ReplaceOrder
198
+ * @param {string} id order id
199
+ * @param {string} [symbol] unified symbol of the market to create an order in
200
+ * @param {string} [type] 'market', 'limit' or 'stop_limit'
201
+ * @param {string} [side] 'buy' or 'sell'
202
+ * @param {float} [amount] how much of the currency you want to trade in units of the base currency
203
+ * @param {float} [price] the price for the order, in units of the quote currency, ignored in market orders
204
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
205
+ * @param {string} [params.triggerPrice] the price to trigger a stop order
206
+ * @param {string} [params.timeInForce] for crypto trading either 'gtc' or 'ioc' can be used
207
+ * @param {string} [params.clientOrderId] a unique identifier for the order, automatically generated if not sent
208
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
209
+ */
210
+ editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
193
211
  /**
194
212
  * @method
195
213
  * @name bitstamp#cancelOrder
@@ -238,6 +256,28 @@ export default class bitstamp extends Exchange {
238
256
  * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
239
257
  */
240
258
  fetchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
259
+ /**
260
+ * @method
261
+ * @name bitstamp#fetchFundingRateHistory
262
+ * @description fetches historical funding rate prices
263
+ * @see https://www.bitstamp.net/api/#tag/Market-info/operation/GetFundingRateHistory
264
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
265
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
266
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
267
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
268
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
269
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
270
+ * @param {string} [params.subType] "linear" or "inverse"
271
+ * @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
272
+ */
273
+ fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
274
+ parseFundingRateHistory(contract: any, market?: Market): {
275
+ info: any;
276
+ symbol: any;
277
+ fundingRate: number;
278
+ timestamp: number;
279
+ datetime: string;
280
+ };
241
281
  /**
242
282
  * @method
243
283
  * @name bitstamp#fetchDepositsWithdrawals
@@ -279,6 +319,17 @@ export default class bitstamp extends Exchange {
279
319
  * @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
280
320
  */
281
321
  fetchLedger(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<LedgerEntry[]>;
322
+ /**
323
+ * @method
324
+ * @name bitstamp#fetchFundingRate
325
+ * @description fetch the current funding rate
326
+ * @see https://www.bitstamp.net/api/#tag/Market-info/operation/GetFundingRate
327
+ * @param {string} symbol unified market symbol
328
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
329
+ * @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
330
+ */
331
+ fetchFundingRate(symbol: string, params?: {}): Promise<FundingRate>;
332
+ parseFundingRate(fundingRate: any, market?: Market): FundingRate;
282
333
  /**
283
334
  * @method
284
335
  * @name bitstamp#fetchOpenOrders