ccxt 4.4.95__py2.py3-none-any.whl → 4.4.97__py2.py3-none-any.whl

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 (110) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/binance.py +3 -0
  3. ccxt/abstract/binancecoinm.py +3 -0
  4. ccxt/abstract/binanceus.py +3 -0
  5. ccxt/abstract/binanceusdm.py +3 -0
  6. ccxt/abstract/foxbit.py +26 -0
  7. ccxt/abstract/hyperliquid.py +1 -1
  8. ccxt/abstract/phemex.py +1 -0
  9. ccxt/apex.py +3 -3
  10. ccxt/ascendex.py +2 -2
  11. ccxt/async_support/__init__.py +3 -1
  12. ccxt/async_support/apex.py +3 -3
  13. ccxt/async_support/ascendex.py +2 -2
  14. ccxt/async_support/base/exchange.py +10 -5
  15. ccxt/async_support/base/ws/future.py +5 -3
  16. ccxt/async_support/binance.py +90 -34
  17. ccxt/async_support/binancecoinm.py +5 -1
  18. ccxt/async_support/binanceus.py +3 -1
  19. ccxt/async_support/binanceusdm.py +3 -1
  20. ccxt/async_support/bingx.py +1 -1
  21. ccxt/async_support/bitget.py +30 -143
  22. ccxt/async_support/bitmart.py +2 -2
  23. ccxt/async_support/bitrue.py +13 -8
  24. ccxt/async_support/bybit.py +14 -5
  25. ccxt/async_support/coinbaseexchange.py +4 -2
  26. ccxt/async_support/coinbaseinternational.py +2 -2
  27. ccxt/async_support/coinspot.py +36 -1
  28. ccxt/async_support/cryptocom.py +78 -3
  29. ccxt/async_support/cryptomus.py +41 -1
  30. ccxt/async_support/defx.py +1 -1
  31. ccxt/async_support/derive.py +1 -1
  32. ccxt/async_support/ellipx.py +40 -0
  33. ccxt/async_support/exmo.py +1 -1
  34. ccxt/async_support/foxbit.py +1935 -0
  35. ccxt/async_support/gate.py +1 -2
  36. ccxt/async_support/hashkey.py +39 -0
  37. ccxt/async_support/hyperliquid.py +42 -27
  38. ccxt/async_support/independentreserve.py +35 -0
  39. ccxt/async_support/indodax.py +34 -0
  40. ccxt/async_support/kucoin.py +3 -2
  41. ccxt/async_support/kucoinfutures.py +3 -2
  42. ccxt/async_support/latoken.py +42 -0
  43. ccxt/async_support/luno.py +36 -0
  44. ccxt/async_support/mercado.py +34 -0
  45. ccxt/async_support/mexc.py +31 -32
  46. ccxt/async_support/modetrade.py +3 -3
  47. ccxt/async_support/okcoin.py +1 -1
  48. ccxt/async_support/okx.py +10 -3
  49. ccxt/async_support/onetrading.py +1 -1
  50. ccxt/async_support/oxfun.py +2 -1
  51. ccxt/async_support/paradex.py +2 -2
  52. ccxt/async_support/phemex.py +36 -31
  53. ccxt/async_support/vertex.py +3 -2
  54. ccxt/async_support/woo.py +6 -2
  55. ccxt/async_support/woofipro.py +2 -2
  56. ccxt/base/decimal_to_precision.py +16 -10
  57. ccxt/base/errors.py +6 -0
  58. ccxt/base/exchange.py +60 -17
  59. ccxt/binance.py +90 -34
  60. ccxt/binancecoinm.py +5 -1
  61. ccxt/binanceus.py +3 -1
  62. ccxt/binanceusdm.py +3 -1
  63. ccxt/bingx.py +1 -1
  64. ccxt/bitget.py +30 -143
  65. ccxt/bitmart.py +2 -2
  66. ccxt/bitrue.py +13 -8
  67. ccxt/bybit.py +14 -5
  68. ccxt/coinbaseexchange.py +4 -2
  69. ccxt/coinbaseinternational.py +2 -2
  70. ccxt/coinspot.py +36 -1
  71. ccxt/cryptocom.py +78 -3
  72. ccxt/cryptomus.py +41 -1
  73. ccxt/defx.py +1 -1
  74. ccxt/derive.py +1 -1
  75. ccxt/ellipx.py +40 -0
  76. ccxt/exmo.py +1 -1
  77. ccxt/foxbit.py +1935 -0
  78. ccxt/gate.py +1 -2
  79. ccxt/hashkey.py +39 -0
  80. ccxt/hyperliquid.py +42 -27
  81. ccxt/independentreserve.py +35 -0
  82. ccxt/indodax.py +34 -0
  83. ccxt/kucoin.py +3 -2
  84. ccxt/kucoinfutures.py +3 -2
  85. ccxt/latoken.py +42 -0
  86. ccxt/luno.py +36 -0
  87. ccxt/mercado.py +34 -0
  88. ccxt/mexc.py +31 -32
  89. ccxt/modetrade.py +3 -3
  90. ccxt/okcoin.py +1 -1
  91. ccxt/okx.py +10 -3
  92. ccxt/onetrading.py +1 -1
  93. ccxt/oxfun.py +2 -1
  94. ccxt/paradex.py +2 -2
  95. ccxt/phemex.py +36 -31
  96. ccxt/pro/__init__.py +1 -1
  97. ccxt/pro/binancecoinm.py +3 -1
  98. ccxt/pro/binanceus.py +3 -1
  99. ccxt/pro/binanceusdm.py +3 -1
  100. ccxt/pro/bybit.py +33 -1
  101. ccxt/test/tests_async.py +15 -0
  102. ccxt/test/tests_sync.py +15 -0
  103. ccxt/vertex.py +3 -2
  104. ccxt/woo.py +6 -2
  105. ccxt/woofipro.py +2 -2
  106. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/METADATA +19 -19
  107. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/RECORD +110 -107
  108. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/LICENSE.txt +0 -0
  109. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/WHEEL +0 -0
  110. {ccxt-4.4.95.dist-info → ccxt-4.4.97.dist-info}/top_level.txt +0 -0
ccxt/bitget.py CHANGED
@@ -4111,82 +4111,35 @@ class bitget(Exchange, ImplicitAPI):
4111
4111
  # "result": "success"
4112
4112
  # }
4113
4113
  #
4114
- # spot: fetchOrder
4115
- #
4116
- # {
4117
- # "userId": "7264631750",
4118
- # "symbol": "BTCUSDT",
4119
- # "orderId": "1111461743123927040",
4120
- # "clientOid": "63f95110-93b5-4309-8f77-46339f1bcf3c",
4121
- # "price": "25000.0000000000000000",
4122
- # "size": "0.0002000000000000",
4123
- # "orderType": "limit",
4124
- # "side": "buy",
4125
- # "status": "live",
4126
- # "priceAvg": "0",
4127
- # "baseVolume": "0.0000000000000000",
4128
- # "quoteVolume": "0.0000000000000000",
4129
- # "enterPointSource": "API",
4130
- # "feeDetail": "",
4131
- # "orderSource": "normal",
4132
- # "cTime": "1700719050198",
4133
- # "uTime": "1700719050198"
4134
- # }
4135
- #
4136
- # swap and future: fetchOrder
4137
- #
4138
- # {
4139
- # "symbol": "BTCUSDT",
4140
- # "size": "0.001",
4141
- # "orderId": "1111465253393825792",
4142
- # "clientOid": "1111465253431574529",
4143
- # "baseVolume": "0",
4144
- # "fee": "0",
4145
- # "price": "27000",
4146
- # "priceAvg": "",
4147
- # "state": "live",
4148
- # "side": "buy",
4149
- # "force": "gtc",
4150
- # "totalProfits": "0",
4151
- # "posSide": "long",
4152
- # "marginCoin": "USDT",
4153
- # "presetStopSurplusPrice": "",
4154
- # "presetStopLossPrice": "",
4155
- # "quoteVolume": "0",
4156
- # "orderType": "limit",
4157
- # "leverage": "20",
4158
- # "marginMode": "crossed",
4159
- # "reduceOnly": "NO",
4160
- # "enterPointSource": "API",
4161
- # "tradeSide": "open",
4162
- # "posMode": "hedge_mode",
4163
- # "orderSource": "normal",
4164
- # "cTime": "1700719887120",
4165
- # "uTime": "1700719887120"
4166
- # }
4167
- #
4168
- # spot: fetchOpenOrders
4114
+ # spot: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
4169
4115
  #
4170
4116
  # {
4171
4117
  # "userId": "7264631750",
4172
4118
  # "symbol": "BTCUSDT",
4173
4119
  # "orderId": "1111499608327360513",
4174
4120
  # "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6",
4175
- # "priceAvg": "25000.0000000000000000",
4176
- # "size": "0.0002000000000000",
4121
+ # "size": "0.0002000000000000", # COST for 'buy market' order! AMOUNT in all other cases
4122
+ # "price": "0", # in fetchOrder: 0 for market order, otherwise limit price(field not present in fetchOpenOrders
4177
4123
  # "orderType": "limit",
4178
4124
  # "side": "buy",
4179
4125
  # "status": "live",
4180
4126
  # "basePrice": "0",
4181
- # "baseVolume": "0.0000000000000000",
4182
- # "quoteVolume": "0.0000000000000000",
4127
+ # "priceAvg": "25000.0000000000000000", # 0 if nothing filled
4128
+ # "baseVolume": "0.0000000000000000", # 0 if nothing filled
4129
+ # "quoteVolume": "0.0000000000000000", # 0 if nothing filled
4183
4130
  # "enterPointSource": "WEB",
4184
4131
  # "orderSource": "normal",
4185
4132
  # "cTime": "1700728077966",
4186
4133
  # "uTime": "1700728077966"
4134
+ # "feeDetail": "{\\"newFees\\":{\\"c\\":0,\\"d\\":0,\\"deduction\\":false,\\"r\\":-0.0064699886,\\"t\\":-0.0064699886,\\"totalDeductionFee\\":0},\\"USDT\\":{\\"deduction\\":false,\\"feeCoinCode\\":\\"USDT\\",\\"totalDeductionFee\\":0,\\"totalFee\\":-0.0064699886000000}}", # might not be present in fetchOpenOrders
4135
+ # "triggerPrice": null,
4136
+ # "tpslType": "normal",
4137
+ # "quoteCoin": "USDT", # not present in fetchOpenOrders
4138
+ # "baseCoin": "DOT", # not present in fetchOpenOrders
4139
+ # "cancelReason": "", # not present in fetchOpenOrders
4187
4140
  # }
4188
4141
  #
4189
- # spot stop: fetchOpenOrders, fetchCanceledAndClosedOrders
4142
+ # spot trigger: fetchOpenOrders, fetchCanceledAndClosedOrders
4190
4143
  #
4191
4144
  # {
4192
4145
  # "orderId": "1111503385931620352",
@@ -4227,18 +4180,19 @@ class bitget(Exchange, ImplicitAPI):
4227
4180
  # "uTime": "1700729691866"
4228
4181
  # }
4229
4182
  #
4230
- # swap: fetchOpenOrders, fetchCanceledAndClosedOrders
4183
+ # swap and future: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
4231
4184
  #
4232
4185
  # {
4233
4186
  # "symbol": "BTCUSDT",
4234
- # "size": "0.002",
4235
- # "orderId": "1111488897767604224",
4236
- # "clientOid": "1111488897805352960",
4187
+ # "size": "0.001",
4188
+ # "orderId": "1111465253393825792",
4189
+ # "clientOid": "1111465253431574529",
4237
4190
  # "baseVolume": "0",
4238
4191
  # "fee": "0",
4239
- # "price": "25000",
4192
+ # "price": "27000",
4240
4193
  # "priceAvg": "",
4241
- # "status": "live",
4194
+ # "state": "live",
4195
+ # # "status": "live", # key for fetchOpenOrders, fetchClosedOrders
4242
4196
  # "side": "buy",
4243
4197
  # "force": "gtc",
4244
4198
  # "totalProfits": "0",
@@ -4247,7 +4201,7 @@ class bitget(Exchange, ImplicitAPI):
4247
4201
  # "quoteVolume": "0",
4248
4202
  # "leverage": "20",
4249
4203
  # "marginMode": "crossed",
4250
- # "enterPointSource": "web",
4204
+ # "enterPointSource": "API",
4251
4205
  # "tradeSide": "open",
4252
4206
  # "posMode": "hedge_mode",
4253
4207
  # "orderType": "limit",
@@ -4255,94 +4209,22 @@ class bitget(Exchange, ImplicitAPI):
4255
4209
  # "presetStopSurplusPrice": "",
4256
4210
  # "presetStopLossPrice": "",
4257
4211
  # "reduceOnly": "NO",
4258
- # "cTime": "1700725524378",
4259
- # "uTime": "1700725524378"
4260
- # }
4212
+ # "cTime": "1700719887120",
4213
+ # "uTime": "1700719887120"
4261
4214
  #
4262
- # swap stop: fetchOpenOrders
4215
+ # for swap trigger order, the additional below fields are present:
4263
4216
  #
4264
- # {
4265
4217
  # "planType": "normal_plan",
4266
- # "symbol": "BTCUSDT",
4267
- # "size": "0.001",
4268
- # "orderId": "1111491399869075457",
4269
- # "clientOid": "1111491399869075456",
4270
- # "price": "27000",
4271
4218
  # "callbackRatio": "",
4272
4219
  # "triggerPrice": "24000",
4273
4220
  # "triggerType": "mark_price",
4274
4221
  # "planStatus": "live",
4275
- # "side": "buy",
4276
- # "posSide": "long",
4277
- # "marginCoin": "USDT",
4278
- # "marginMode": "crossed",
4279
- # "enterPointSource": "API",
4280
- # "tradeSide": "open",
4281
- # "posMode": "hedge_mode",
4282
- # "orderType": "limit",
4283
- # "stopSurplusTriggerPrice": "",
4284
- # "stopSurplusExecutePrice": "",
4285
- # "stopSurplusTriggerType": "fill_price",
4286
- # "stopLossTriggerPrice": "",
4287
- # "stopLossExecutePrice": "",
4288
- # "stopLossTriggerType": "fill_price",
4289
- # "cTime": "1700726120917",
4290
- # "uTime": "1700726120917"
4291
- # }
4292
- #
4293
- # spot: fetchCanceledAndClosedOrders
4294
- #
4295
- # {
4296
- # "userId": "7264631750",
4297
- # "symbol": "BTCUSDT",
4298
- # "orderId": "1111499608327360513",
4299
- # "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6",
4300
- # "price": "25000.0000000000000000",
4301
- # "size": "0.0002000000000000",
4302
- # "orderType": "limit",
4303
- # "side": "buy",
4304
- # "status": "cancelled",
4305
- # "priceAvg": "0",
4306
- # "baseVolume": "0.0000000000000000",
4307
- # "quoteVolume": "0.0000000000000000",
4308
- # "enterPointSource": "WEB",
4309
- # "feeDetail": "",
4310
- # "orderSource": "normal",
4311
- # "cTime": "1700728077966",
4312
- # "uTime": "1700728911471"
4313
- # }
4314
- #
4315
- # swap stop: fetchCanceledAndClosedOrders
4316
- #
4317
- # {
4318
- # "planType": "normal_plan",
4319
- # "symbol": "BTCUSDT",
4320
- # "size": "0.001",
4321
- # "orderId": "1111491399869075457",
4322
- # "clientOid": "1111491399869075456",
4323
- # "planStatus": "cancelled",
4324
- # "price": "27000",
4325
- # "feeDetail": null,
4326
- # "baseVolume": "0",
4327
- # "callbackRatio": "",
4328
- # "triggerPrice": "24000",
4329
- # "triggerType": "mark_price",
4330
- # "side": "buy",
4331
- # "posSide": "long",
4332
- # "marginCoin": "USDT",
4333
- # "marginMode": "crossed",
4334
- # "enterPointSource": "API",
4335
- # "tradeSide": "open",
4336
- # "posMode": "hedge_mode",
4337
- # "orderType": "limit",
4338
4222
  # "stopSurplusTriggerPrice": "",
4339
4223
  # "stopSurplusExecutePrice": "",
4340
4224
  # "stopSurplusTriggerType": "fill_price",
4341
4225
  # "stopLossTriggerPrice": "",
4342
4226
  # "stopLossExecutePrice": "",
4343
4227
  # "stopLossTriggerType": "fill_price",
4344
- # "cTime": "1700726120917",
4345
- # "uTime": "1700727879652"
4346
4228
  # }
4347
4229
  #
4348
4230
  errorMessage = self.safe_string(order, 'errorMsg')
@@ -4420,6 +4302,11 @@ class bitget(Exchange, ImplicitAPI):
4420
4302
  side = 'sell' if (side == 'buy') else 'buy'
4421
4303
  # on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
4422
4304
  # so the side of the reduceOnly order is inversed
4305
+ orderType = self.safe_string(order, 'orderType')
4306
+ isBuyMarket = (side == 'buy') and (orderType == 'market')
4307
+ if market['spot'] and isBuyMarket:
4308
+ # in top comment, for 'buy market' the 'size' field is COST, not AMOUNT
4309
+ size = self.safe_string(order, 'baseVolume')
4423
4310
  return self.safe_order({
4424
4311
  'info': order,
4425
4312
  'id': self.safe_string_2(order, 'orderId', 'data'),
@@ -4429,7 +4316,7 @@ class bitget(Exchange, ImplicitAPI):
4429
4316
  'lastTradeTimestamp': updateTimestamp,
4430
4317
  'lastUpdateTimestamp': updateTimestamp,
4431
4318
  'symbol': market['symbol'],
4432
- 'type': self.safe_string(order, 'orderType'),
4319
+ 'type': orderType,
4433
4320
  'side': side,
4434
4321
  'price': price,
4435
4322
  'amount': size,
ccxt/bitmart.py CHANGED
@@ -3083,7 +3083,7 @@ class bitmart(Exchange, ImplicitAPI):
3083
3083
  # }
3084
3084
  #
3085
3085
  if market['swap']:
3086
- return response
3086
+ return self.safe_order({'info': response})
3087
3087
  data = self.safe_value(response, 'data')
3088
3088
  if data is True:
3089
3089
  return self.safe_order({'id': id}, market)
@@ -3200,7 +3200,7 @@ class bitmart(Exchange, ImplicitAPI):
3200
3200
  # "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.70.16954131323145323"
3201
3201
  # }
3202
3202
  #
3203
- return response
3203
+ return [self.safe_order({'info': response})]
3204
3204
 
3205
3205
  def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
3206
3206
  if symbol is None:
ccxt/bitrue.py CHANGED
@@ -394,11 +394,9 @@ class bitrue(Exchange, ImplicitAPI):
394
394
  # exchange-specific options
395
395
  'options': {
396
396
  'createMarketBuyOrderRequiresPrice': True,
397
- 'fetchMarkets': [
398
- 'spot',
399
- 'linear',
400
- 'inverse',
401
- ],
397
+ 'fetchMarkets': {
398
+ 'types': ['spot', 'linear', 'inverse'],
399
+ },
402
400
  # 'fetchTradesMethod': 'publicGetAggTrades', # publicGetTrades, publicGetHistoricalTrades
403
401
  'fetchMyTradesMethod': 'v2PrivateGetMyTrades', # spotV1PrivateGetMyTrades
404
402
  'hasAlreadyAuthenticatedSuccessfully': False,
@@ -844,9 +842,16 @@ class bitrue(Exchange, ImplicitAPI):
844
842
  :returns dict[]: an array of objects representing market data
845
843
  """
846
844
  promisesRaw = []
847
- fetchMarkets = self.safe_value(self.options, 'fetchMarkets', ['spot', 'linear', 'inverse'])
848
- for i in range(0, len(fetchMarkets)):
849
- marketType = fetchMarkets[i]
845
+ types = None
846
+ defaultTypes = ['spot', 'linear', 'inverse']
847
+ fetchMarketsOptions = self.safe_dict(self.options, 'fetchMarkets')
848
+ if fetchMarketsOptions is not None:
849
+ types = self.safe_list(fetchMarketsOptions, 'types', defaultTypes)
850
+ else:
851
+ # for backward-compatibility
852
+ types = self.safe_list(self.options, 'fetchMarkets', defaultTypes)
853
+ for i in range(0, len(types)):
854
+ marketType = types[i]
850
855
  if marketType == 'spot':
851
856
  promisesRaw.append(self.spotV1PublicGetExchangeInfo(params))
852
857
  elif marketType == 'linear':
ccxt/bybit.py CHANGED
@@ -1040,7 +1040,9 @@ class bybit(Exchange, ImplicitAPI):
1040
1040
  'options': {
1041
1041
  'usePrivateInstrumentsInfo': False,
1042
1042
  'enableDemoTrading': False,
1043
- 'fetchMarkets': ['spot', 'linear', 'inverse', 'option'],
1043
+ 'fetchMarkets': {
1044
+ 'types': ['spot', 'linear', 'inverse', 'option'],
1045
+ },
1044
1046
  'enableUnifiedMargin': None,
1045
1047
  'enableUnifiedAccount': None,
1046
1048
  'unifiedMarginStatus': None,
@@ -1701,9 +1703,16 @@ class bybit(Exchange, ImplicitAPI):
1701
1703
  if self.options['adjustForTimeDifference']:
1702
1704
  self.load_time_difference()
1703
1705
  promisesUnresolved = []
1704
- fetchMarkets = self.safe_list(self.options, 'fetchMarkets', ['spot', 'linear', 'inverse'])
1705
- for i in range(0, len(fetchMarkets)):
1706
- marketType = fetchMarkets[i]
1706
+ types = None
1707
+ defaultTypes = ['spot', 'linear', 'inverse', 'option']
1708
+ fetchMarketsOptions = self.safe_dict(self.options, 'fetchMarkets')
1709
+ if fetchMarketsOptions is not None:
1710
+ types = self.safe_list(fetchMarketsOptions, 'types', defaultTypes)
1711
+ else:
1712
+ # for backward-compatibility
1713
+ types = self.safe_list(self.options, 'fetchMarkets', defaultTypes)
1714
+ for i in range(0, len(types)):
1715
+ marketType = types[i]
1707
1716
  if marketType == 'spot':
1708
1717
  promisesUnresolved.append(self.fetch_spot_markets(params))
1709
1718
  elif marketType == 'linear':
@@ -4576,7 +4585,7 @@ class bybit(Exchange, ImplicitAPI):
4576
4585
  result = self.safe_dict(response, 'result', {})
4577
4586
  orders = self.safe_list(result, 'list')
4578
4587
  if not isinstance(orders, list):
4579
- return response
4588
+ return [self.safe_order({'info': response})]
4580
4589
  return self.parse_orders(orders, market)
4581
4590
 
4582
4591
  def fetch_order_classic(self, id: str, symbol: Str = None, params={}) -> Order:
ccxt/coinbaseexchange.py CHANGED
@@ -1541,7 +1541,8 @@ class coinbaseexchange(Exchange, ImplicitAPI):
1541
1541
  if symbol is not None:
1542
1542
  market = self.market(symbol)
1543
1543
  request['product_id'] = market['symbol'] # the request will be more performant if you include it
1544
- return getattr(self, method)(self.extend(request, params))
1544
+ response = getattr(self, method)(self.extend(request, params))
1545
+ return self.safe_order({'info': response})
1545
1546
 
1546
1547
  def cancel_all_orders(self, symbol: Str = None, params={}):
1547
1548
  """
@@ -1559,7 +1560,8 @@ class coinbaseexchange(Exchange, ImplicitAPI):
1559
1560
  if symbol is not None:
1560
1561
  market = self.market(symbol)
1561
1562
  request['product_id'] = market['symbol'] # the request will be more performant if you include it
1562
- return self.privateDeleteOrders(self.extend(request, params))
1563
+ response = self.privateDeleteOrders(self.extend(request, params))
1564
+ return [self.safe_order({'info': response})]
1563
1565
 
1564
1566
  def fetch_payment_methods(self, params={}):
1565
1567
  return self.privateGetPaymentMethods(params)
@@ -6,7 +6,7 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.coinbaseinternational import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, Market, Order, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
9
+ from ccxt.base.types import Any, Balances, Currencies, Currency, DepositAddress, Int, MarginModification, Market, Order, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
10
10
  from typing import List
11
11
  from ccxt.base.errors import ExchangeError
12
12
  from ccxt.base.errors import AuthenticationError
@@ -875,7 +875,7 @@ class coinbaseinternational(Exchange, ImplicitAPI):
875
875
  },
876
876
  })
877
877
 
878
- def set_margin(self, symbol: str, amount: float, params={}) -> Any:
878
+ def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
879
879
  """
880
880
  Either adds or reduces margin in order to set the margin to a specific value
881
881
 
ccxt/coinspot.py CHANGED
@@ -31,33 +31,61 @@ class coinspot(Exchange, ImplicitAPI):
31
31
  'future': False,
32
32
  'option': False,
33
33
  'addMargin': False,
34
+ 'borrowCrossMargin': False,
35
+ 'borrowIsolatedMargin': False,
36
+ 'borrowMargin': False,
34
37
  'cancelOrder': True,
35
38
  'closeAllPositions': False,
36
39
  'closePosition': False,
37
40
  'createMarketOrder': False,
38
41
  'createOrder': True,
42
+ 'createOrderWithTakeProfitAndStopLoss': False,
43
+ 'createOrderWithTakeProfitAndStopLossWs': False,
44
+ 'createPostOnlyOrder': False,
39
45
  'createReduceOnlyOrder': False,
40
46
  'createStopLimitOrder': False,
41
47
  'createStopMarketOrder': False,
42
48
  'createStopOrder': False,
43
49
  'fetchBalance': True,
50
+ 'fetchBorrowInterest': False,
51
+ 'fetchBorrowRate': False,
44
52
  'fetchBorrowRateHistories': False,
45
53
  'fetchBorrowRateHistory': False,
54
+ 'fetchBorrowRates': False,
55
+ 'fetchBorrowRatesPerSymbol': False,
46
56
  'fetchCrossBorrowRate': False,
47
57
  'fetchCrossBorrowRates': False,
48
58
  'fetchFundingHistory': False,
59
+ 'fetchFundingInterval': False,
60
+ 'fetchFundingIntervals': False,
49
61
  'fetchFundingRate': False,
50
62
  'fetchFundingRateHistory': False,
51
63
  'fetchFundingRates': False,
64
+ 'fetchGreeks': False,
52
65
  'fetchIndexOHLCV': False,
53
66
  'fetchIsolatedBorrowRate': False,
54
67
  'fetchIsolatedBorrowRates': False,
68
+ 'fetchIsolatedPositions': False,
55
69
  'fetchLeverage': False,
70
+ 'fetchLeverages': False,
56
71
  'fetchLeverageTiers': False,
72
+ 'fetchLiquidations': False,
73
+ 'fetchLongShortRatio': False,
74
+ 'fetchLongShortRatioHistory': False,
75
+ 'fetchMarginAdjustmentHistory': False,
57
76
  'fetchMarginMode': False,
77
+ 'fetchMarginModes': False,
78
+ 'fetchMarketLeverageTiers': False,
58
79
  'fetchMarkOHLCV': False,
80
+ 'fetchMarkPrices': False,
81
+ 'fetchMyLiquidations': False,
82
+ 'fetchMySettlementHistory': False,
59
83
  'fetchMyTrades': True,
84
+ 'fetchOpenInterest': False,
60
85
  'fetchOpenInterestHistory': False,
86
+ 'fetchOpenInterests': False,
87
+ 'fetchOption': False,
88
+ 'fetchOptionChain': False,
61
89
  'fetchOrderBook': True,
62
90
  'fetchPosition': False,
63
91
  'fetchPositionHistory': False,
@@ -67,13 +95,19 @@ class coinspot(Exchange, ImplicitAPI):
67
95
  'fetchPositionsHistory': False,
68
96
  'fetchPositionsRisk': False,
69
97
  'fetchPremiumIndexOHLCV': False,
98
+ 'fetchSettlementHistory': False,
70
99
  'fetchTicker': True,
71
100
  'fetchTickers': True,
72
101
  'fetchTrades': True,
73
102
  'fetchTradingFee': False,
74
103
  'fetchTradingFees': False,
104
+ 'fetchVolatilityHistory': False,
75
105
  'reduceMargin': False,
106
+ 'repayCrossMargin': False,
107
+ 'repayIsolatedMargin': False,
108
+ 'repayMargin': False,
76
109
  'setLeverage': False,
110
+ 'setMargin': False,
77
111
  'setMarginMode': False,
78
112
  'setPositionMode': False,
79
113
  'ws': False,
@@ -551,7 +585,8 @@ class coinspot(Exchange, ImplicitAPI):
551
585
  'amount': amount,
552
586
  'rate': price,
553
587
  }
554
- return getattr(self, method)(self.extend(request, params))
588
+ response = getattr(self, method)(self.extend(request, params))
589
+ return self.parse_order(response)
555
590
 
556
591
  def cancel_order(self, id: str, symbol: Str = None, params={}):
557
592
  """
ccxt/cryptocom.py CHANGED
@@ -6,7 +6,8 @@
6
6
  from ccxt.base.exchange import Exchange
7
7
  from ccxt.abstract.cryptocom import ImplicitAPI
8
8
  import hashlib
9
- from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction
9
+ import math
10
+ from ccxt.base.types import Account, Any, Balances, Currencies, Currency, DepositAddress, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction
10
11
  from typing import List
11
12
  from ccxt.base.errors import ExchangeError
12
13
  from ccxt.base.errors import AuthenticationError
@@ -79,7 +80,7 @@ class cryptocom(Exchange, ImplicitAPI):
79
80
  'fetchDepositWithdrawFee': 'emulated',
80
81
  'fetchDepositWithdrawFees': True,
81
82
  'fetchFundingHistory': False,
82
- 'fetchFundingRate': False,
83
+ 'fetchFundingRate': True,
83
84
  'fetchFundingRateHistory': True,
84
85
  'fetchFundingRates': False,
85
86
  'fetchGreeks': False,
@@ -1631,7 +1632,8 @@ class cryptocom(Exchange, ImplicitAPI):
1631
1632
  if symbol is not None:
1632
1633
  market = self.market(symbol)
1633
1634
  request['instrument_name'] = market['id']
1634
- return self.v1PrivatePostPrivateCancelAllOrders(self.extend(request, params))
1635
+ response = self.v1PrivatePostPrivateCancelAllOrders(self.extend(request, params))
1636
+ return [self.safe_order({'info': response})]
1635
1637
 
1636
1638
  def cancel_order(self, id: str, symbol: Str = None, params={}):
1637
1639
  """
@@ -2848,6 +2850,79 @@ class cryptocom(Exchange, ImplicitAPI):
2848
2850
  result.append(self.parse_settlement(settlements[i], market))
2849
2851
  return result
2850
2852
 
2853
+ def fetch_funding_rate(self, symbol: str, params={}):
2854
+ """
2855
+ fetches historical funding rates
2856
+
2857
+ https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html#public-get-valuations
2858
+
2859
+ :param str symbol: unified symbol of the market to fetch the funding rate history for
2860
+ :param dict [params]: extra parameters specific to the exchange API endpoint
2861
+ :returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
2862
+ """
2863
+ self.load_markets()
2864
+ market = self.market(symbol)
2865
+ if not market['swap']:
2866
+ raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
2867
+ request: dict = {
2868
+ 'instrument_name': market['id'],
2869
+ 'valuation_type': 'estimated_funding_rate',
2870
+ 'count': 1,
2871
+ }
2872
+ response = self.v1PublicGetPublicGetValuations(self.extend(request, params))
2873
+ #
2874
+ # {
2875
+ # "id": -1,
2876
+ # "method": "public/get-valuations",
2877
+ # "code": 0,
2878
+ # "result": {
2879
+ # "data": [
2880
+ # {
2881
+ # "v": "-0.000001884",
2882
+ # "t": 1687892400000
2883
+ # },
2884
+ # ],
2885
+ # "instrument_name": "BTCUSD-PERP"
2886
+ # }
2887
+ # }
2888
+ #
2889
+ result = self.safe_dict(response, 'result', {})
2890
+ data = self.safe_list(result, 'data', [])
2891
+ entry = self.safe_dict(data, 0, {})
2892
+ return self.parse_funding_rate(entry, market)
2893
+
2894
+ def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
2895
+ #
2896
+ # {
2897
+ # "v": "-0.000001884",
2898
+ # "t": 1687892400000
2899
+ # },
2900
+ #
2901
+ timestamp = self.safe_integer(contract, 't')
2902
+ fundingTimestamp = None
2903
+ if timestamp is not None:
2904
+ fundingTimestamp = int(math.ceil(timestamp / 3600000)) * 3600000 # end of the next hour
2905
+ return {
2906
+ 'info': contract,
2907
+ 'symbol': self.safe_symbol(None, market),
2908
+ 'markPrice': None,
2909
+ 'indexPrice': None,
2910
+ 'interestRate': None,
2911
+ 'estimatedSettlePrice': None,
2912
+ 'timestamp': timestamp,
2913
+ 'datetime': self.iso8601(timestamp),
2914
+ 'fundingRate': self.safe_number(contract, 'v'),
2915
+ 'fundingTimestamp': fundingTimestamp,
2916
+ 'fundingDatetime': self.iso8601(fundingTimestamp),
2917
+ 'nextFundingRate': None,
2918
+ 'nextFundingTimestamp': None,
2919
+ 'nextFundingDatetime': None,
2920
+ 'previousFundingRate': None,
2921
+ 'previousFundingTimestamp': None,
2922
+ 'previousFundingDatetime': None,
2923
+ 'interval': '1h',
2924
+ }
2925
+
2851
2926
  def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
2852
2927
  """
2853
2928
  fetches historical funding rates