ccxt 4.4.90__py2.py3-none-any.whl → 4.4.91__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 (57) hide show
  1. ccxt/__init__.py +1 -3
  2. ccxt/async_support/__init__.py +1 -3
  3. ccxt/async_support/base/exchange.py +6 -3
  4. ccxt/async_support/base/ws/client.py +173 -64
  5. ccxt/async_support/base/ws/future.py +23 -50
  6. ccxt/async_support/binance.py +1 -1
  7. ccxt/async_support/bitmex.py +2 -1
  8. ccxt/async_support/cex.py +61 -0
  9. ccxt/async_support/cryptocom.py +17 -2
  10. ccxt/async_support/cryptomus.py +1 -1
  11. ccxt/async_support/exmo.py +14 -7
  12. ccxt/async_support/gate.py +2 -2
  13. ccxt/async_support/hyperliquid.py +104 -53
  14. ccxt/async_support/kraken.py +26 -1
  15. ccxt/async_support/mexc.py +1 -0
  16. ccxt/async_support/modetrade.py +2 -2
  17. ccxt/async_support/paradex.py +1 -1
  18. ccxt/base/exchange.py +8 -5
  19. ccxt/binance.py +1 -1
  20. ccxt/bitmex.py +2 -1
  21. ccxt/cex.py +61 -0
  22. ccxt/cryptocom.py +17 -2
  23. ccxt/cryptomus.py +1 -1
  24. ccxt/exmo.py +13 -7
  25. ccxt/gate.py +2 -2
  26. ccxt/hyperliquid.py +104 -53
  27. ccxt/kraken.py +26 -1
  28. ccxt/mexc.py +1 -0
  29. ccxt/modetrade.py +2 -2
  30. ccxt/paradex.py +1 -1
  31. ccxt/pro/__init__.py +1 -1
  32. ccxt/pro/bitstamp.py +1 -1
  33. ccxt/pro/bybit.py +6 -136
  34. ccxt/pro/kraken.py +246 -258
  35. ccxt/pro/mexc.py +0 -1
  36. {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/METADATA +6 -7
  37. {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/RECORD +40 -57
  38. ccxt/abstract/coinlist.py +0 -57
  39. ccxt/async_support/base/ws/aiohttp_client.py +0 -147
  40. ccxt/async_support/bitcoincom.py +0 -18
  41. ccxt/async_support/bitfinex1.py +0 -1711
  42. ccxt/async_support/bitpanda.py +0 -17
  43. ccxt/async_support/coinlist.py +0 -2542
  44. ccxt/async_support/poloniexfutures.py +0 -1875
  45. ccxt/bitcoincom.py +0 -18
  46. ccxt/bitfinex1.py +0 -1710
  47. ccxt/bitpanda.py +0 -17
  48. ccxt/coinlist.py +0 -2542
  49. ccxt/poloniexfutures.py +0 -1875
  50. ccxt/pro/bitcoincom.py +0 -35
  51. ccxt/pro/bitfinex1.py +0 -635
  52. ccxt/pro/bitpanda.py +0 -16
  53. ccxt/pro/poloniexfutures.py +0 -1004
  54. ccxt/pro/wazirx.py +0 -766
  55. {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/LICENSE.txt +0 -0
  56. {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/WHEEL +0 -0
  57. {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/top_level.txt +0 -0
ccxt/gate.py CHANGED
@@ -1241,7 +1241,7 @@ class gate(Exchange, ImplicitAPI):
1241
1241
  self.fetch_option_markets(params),
1242
1242
  ]
1243
1243
  if not sandboxMode:
1244
- # gate does not have a sandbox for spot markets
1244
+ # gate doesn't have a sandbox for spot markets
1245
1245
  mainnetOnly = [self.fetch_spot_markets(params)]
1246
1246
  rawPromises = self.array_concat(rawPromises, mainnetOnly)
1247
1247
  promises = rawPromises
@@ -1652,7 +1652,7 @@ class gate(Exchange, ImplicitAPI):
1652
1652
  'contractSize': self.parse_number('1'),
1653
1653
  'expiry': expiry,
1654
1654
  'expiryDatetime': self.iso8601(expiry),
1655
- 'strike': strike,
1655
+ 'strike': self.parse_number(strike),
1656
1656
  'optionType': optionType,
1657
1657
  'precision': {
1658
1658
  'amount': self.parse_number('1'), # all options have self step size
ccxt/hyperliquid.py CHANGED
@@ -56,6 +56,7 @@ class hyperliquid(Exchange, ImplicitAPI):
56
56
  'createMarketSellOrderWithCost': False,
57
57
  'createOrder': True,
58
58
  'createOrders': True,
59
+ 'createOrderWithTakeProfitAndStopLoss': True,
59
60
  'createReduceOnlyOrder': True,
60
61
  'createStopOrder': True,
61
62
  'createTriggerOrder': True,
@@ -239,7 +240,16 @@ class hyperliquid(Exchange, ImplicitAPI):
239
240
  'triggerDirection': False,
240
241
  'stopLossPrice': False,
241
242
  'takeProfitPrice': False,
242
- 'attachedStopLossTakeProfit': None,
243
+ 'attachedStopLossTakeProfit': {
244
+ 'triggerPriceType': {
245
+ 'last': False,
246
+ 'mark': False,
247
+ 'index': False,
248
+ },
249
+ 'triggerPrice': True,
250
+ 'type': True,
251
+ 'price': True,
252
+ },
243
253
  'timeInForce': {
244
254
  'IOC': True,
245
255
  'FOK': False,
@@ -1403,6 +1413,65 @@ class hyperliquid(Exchange, ImplicitAPI):
1403
1413
  statuses = self.safe_list(data, 'statuses', [])
1404
1414
  return self.parse_orders(statuses, None)
1405
1415
 
1416
+ def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: str, price: Str = None, params={}):
1417
+ market = self.market(symbol)
1418
+ type = type.upper()
1419
+ side = side.upper()
1420
+ isMarket = (type == 'MARKET')
1421
+ isBuy = (side == 'BUY')
1422
+ clientOrderId = self.safe_string_2(params, 'clientOrderId', 'client_id')
1423
+ slippage = self.safe_string(params, 'slippage')
1424
+ defaultTimeInForce = 'ioc' if (isMarket) else 'gtc'
1425
+ postOnly = self.safe_bool(params, 'postOnly', False)
1426
+ if postOnly:
1427
+ defaultTimeInForce = 'alo'
1428
+ timeInForce = self.safe_string_lower(params, 'timeInForce', defaultTimeInForce)
1429
+ timeInForce = self.capitalize(timeInForce)
1430
+ triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1431
+ stopLossPrice = self.safe_string(params, 'stopLossPrice', triggerPrice)
1432
+ takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1433
+ isTrigger = (stopLossPrice or takeProfitPrice)
1434
+ px = None
1435
+ if isMarket:
1436
+ if price is None:
1437
+ raise ArgumentsRequired(self.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options(default is 5%).')
1438
+ px = Precise.string_mul(price, Precise.string_add('1', slippage)) if (isBuy) else Precise.string_mul(price, Precise.string_sub('1', slippage))
1439
+ px = self.price_to_precision(symbol, px) # round after adding slippage
1440
+ else:
1441
+ px = self.price_to_precision(symbol, price)
1442
+ sz = self.amount_to_precision(symbol, amount)
1443
+ reduceOnly = self.safe_bool(params, 'reduceOnly', False)
1444
+ orderType: dict = {}
1445
+ if isTrigger:
1446
+ isTp = False
1447
+ if takeProfitPrice is not None:
1448
+ triggerPrice = self.price_to_precision(symbol, takeProfitPrice)
1449
+ isTp = True
1450
+ else:
1451
+ triggerPrice = self.price_to_precision(symbol, stopLossPrice)
1452
+ orderType['trigger'] = {
1453
+ 'isMarket': isMarket,
1454
+ 'triggerPx': triggerPrice,
1455
+ 'tpsl': 'tp' if (isTp) else 'sl',
1456
+ }
1457
+ else:
1458
+ orderType['limit'] = {
1459
+ 'tif': timeInForce,
1460
+ }
1461
+ params = self.omit(params, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly'])
1462
+ orderObj: dict = {
1463
+ 'a': self.parse_to_int(market['baseId']),
1464
+ 'b': isBuy,
1465
+ 'p': px,
1466
+ 's': sz,
1467
+ 'r': reduceOnly,
1468
+ 't': orderType,
1469
+ # 'c': clientOrderId,
1470
+ }
1471
+ if clientOrderId is not None:
1472
+ orderObj['c'] = clientOrderId
1473
+ return orderObj
1474
+
1406
1475
  def create_orders_request(self, orders, params={}) -> dict:
1407
1476
  """
1408
1477
  create a list of trade orders
@@ -1430,77 +1499,59 @@ class hyperliquid(Exchange, ImplicitAPI):
1430
1499
  params = self.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce'])
1431
1500
  nonce = self.milliseconds()
1432
1501
  orderReq = []
1502
+ grouping = 'na'
1433
1503
  for i in range(0, len(orders)):
1434
1504
  rawOrder = orders[i]
1435
1505
  marketId = self.safe_string(rawOrder, 'symbol')
1436
1506
  market = self.market(marketId)
1437
1507
  symbol = market['symbol']
1438
1508
  type = self.safe_string_upper(rawOrder, 'type')
1439
- isMarket = (type == 'MARKET')
1440
1509
  side = self.safe_string_upper(rawOrder, 'side')
1441
- isBuy = (side == 'BUY')
1442
1510
  amount = self.safe_string(rawOrder, 'amount')
1443
1511
  price = self.safe_string(rawOrder, 'price')
1444
1512
  orderParams = self.safe_dict(rawOrder, 'params', {})
1445
- clientOrderId = self.safe_string_2(orderParams, 'clientOrderId', 'client_id')
1446
1513
  slippage = self.safe_string(orderParams, 'slippage', defaultSlippage)
1447
- defaultTimeInForce = 'ioc' if (isMarket) else 'gtc'
1448
- postOnly = self.safe_bool(orderParams, 'postOnly', False)
1449
- if postOnly:
1450
- defaultTimeInForce = 'alo'
1451
- timeInForce = self.safe_string_lower(orderParams, 'timeInForce', defaultTimeInForce)
1452
- timeInForce = self.capitalize(timeInForce)
1453
- triggerPrice = self.safe_string_2(orderParams, 'triggerPrice', 'stopPrice')
1454
- stopLossPrice = self.safe_string(orderParams, 'stopLossPrice', triggerPrice)
1455
- takeProfitPrice = self.safe_string(orderParams, 'takeProfitPrice')
1456
- isTrigger = (stopLossPrice or takeProfitPrice)
1457
- px = None
1458
- if isMarket:
1459
- if price is None:
1460
- raise ArgumentsRequired(self.id + ' market orders require price to calculate the max slippage price. Default slippage can be set in options(default is 5%).')
1461
- px = Precise.string_mul(price, Precise.string_add('1', slippage)) if (isBuy) else Precise.string_mul(price, Precise.string_sub('1', slippage))
1462
- px = self.price_to_precision(symbol, px) # round after adding slippage
1463
- else:
1464
- px = self.price_to_precision(symbol, price)
1465
- sz = self.amount_to_precision(symbol, amount)
1466
- reduceOnly = self.safe_bool(orderParams, 'reduceOnly', False)
1467
- orderType: dict = {}
1514
+ orderParams['slippage'] = slippage
1515
+ stopLoss = self.safe_value(orderParams, 'stopLoss')
1516
+ takeProfit = self.safe_value(orderParams, 'takeProfit')
1517
+ isTrigger = (stopLoss or takeProfit)
1518
+ orderParams = self.omit(orderParams, ['stopLoss', 'takeProfit'])
1519
+ mainOrderObj: dict = self.create_order_request(symbol, type, side, amount, price, orderParams)
1520
+ orderReq.append(mainOrderObj)
1468
1521
  if isTrigger:
1469
- isTp = False
1470
- if takeProfitPrice is not None:
1471
- triggerPrice = self.price_to_precision(symbol, takeProfitPrice)
1472
- isTp = True
1522
+ # grouping opposed orders for sl/tp
1523
+ stopLossOrderTriggerPrice = self.safe_string_n(stopLoss, ['triggerPrice', 'stopPrice'])
1524
+ stopLossOrderType = self.safe_string(stopLoss, 'type')
1525
+ stopLossOrderLimitPrice = self.safe_string_n(stopLoss, ['price', 'stopLossPrice'], stopLossOrderTriggerPrice)
1526
+ takeProfitOrderTriggerPrice = self.safe_string_n(takeProfit, ['triggerPrice', 'stopPrice'])
1527
+ takeProfitOrderType = self.safe_string(takeProfit, 'type')
1528
+ takeProfitOrderLimitPrice = self.safe_string_n(takeProfit, ['price', 'takeProfitPrice'], takeProfitOrderTriggerPrice)
1529
+ grouping = 'normalTpsl'
1530
+ orderParams = self.omit(orderParams, ['stopLoss', 'takeProfit'])
1531
+ triggerOrderSide = ''
1532
+ if side == 'BUY':
1533
+ triggerOrderSide = 'sell'
1473
1534
  else:
1474
- triggerPrice = self.price_to_precision(symbol, stopLossPrice)
1475
- orderType['trigger'] = {
1476
- 'isMarket': isMarket,
1477
- 'triggerPx': triggerPrice,
1478
- 'tpsl': 'tp' if (isTp) else 'sl',
1479
- }
1480
- else:
1481
- orderType['limit'] = {
1482
- 'tif': timeInForce,
1483
- }
1484
- orderParams = self.omit(orderParams, ['clientOrderId', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce', 'client_id', 'reduceOnly', 'postOnly'])
1485
- orderObj: dict = {
1486
- 'a': self.parse_to_int(market['baseId']),
1487
- 'b': isBuy,
1488
- 'p': px,
1489
- 's': sz,
1490
- 'r': reduceOnly,
1491
- 't': orderType,
1492
- # 'c': clientOrderId,
1493
- }
1494
- if clientOrderId is not None:
1495
- orderObj['c'] = clientOrderId
1496
- orderReq.append(orderObj)
1535
+ triggerOrderSide = 'buy'
1536
+ if takeProfit is not None:
1537
+ orderObj: dict = self.create_order_request(symbol, takeProfitOrderType, triggerOrderSide, amount, takeProfitOrderLimitPrice, self.extend(orderParams, {
1538
+ 'takeProfitPrice': takeProfitOrderTriggerPrice,
1539
+ 'reduceOnly': True,
1540
+ }))
1541
+ orderReq.append(orderObj)
1542
+ if stopLoss is not None:
1543
+ orderObj: dict = self.create_order_request(symbol, stopLossOrderType, triggerOrderSide, amount, stopLossOrderLimitPrice, self.extend(orderParams, {
1544
+ 'stopLossPrice': stopLossOrderTriggerPrice,
1545
+ 'reduceOnly': True,
1546
+ }))
1547
+ orderReq.append(orderObj)
1497
1548
  vaultAddress = None
1498
1549
  vaultAddress, params = self.handle_option_and_params(params, 'createOrder', 'vaultAddress')
1499
1550
  vaultAddress = self.format_vault_address(vaultAddress)
1500
1551
  orderAction: dict = {
1501
1552
  'type': 'order',
1502
1553
  'orders': orderReq,
1503
- 'grouping': 'na',
1554
+ 'grouping': grouping,
1504
1555
  # 'brokerCode': 1, # cant
1505
1556
  }
1506
1557
  if vaultAddress is None:
ccxt/kraken.py CHANGED
@@ -1365,7 +1365,20 @@ class kraken(Exchange, ImplicitAPI):
1365
1365
  # "maker": False
1366
1366
  # }
1367
1367
  #
1368
+ # watchTrades
1369
+ #
1370
+ # {
1371
+ # "symbol": "BTC/USD",
1372
+ # "side": "buy",
1373
+ # "price": 109601.2,
1374
+ # "qty": 0.04561994,
1375
+ # "ord_type": "market",
1376
+ # "trade_id": 83449369,
1377
+ # "timestamp": "2025-05-27T11:24:03.847761Z"
1378
+ # }
1379
+ #
1368
1380
  timestamp = None
1381
+ datetime = None
1369
1382
  side = None
1370
1383
  type = None
1371
1384
  price = None
@@ -1408,6 +1421,14 @@ class kraken(Exchange, ImplicitAPI):
1408
1421
  'cost': self.safe_string(trade, 'fee'),
1409
1422
  'currency': currency,
1410
1423
  }
1424
+ else:
1425
+ symbol = self.safe_string(trade, 'symbol')
1426
+ datetime = self.safe_string(trade, 'timestamp')
1427
+ id = self.safe_string(trade, 'trade_id')
1428
+ side = self.safe_string(trade, 'side')
1429
+ type = self.safe_string(trade, 'ord_type')
1430
+ price = self.safe_string(trade, 'price')
1431
+ amount = self.safe_string(trade, 'qty')
1411
1432
  if market is not None:
1412
1433
  symbol = market['symbol']
1413
1434
  cost = self.safe_string(trade, 'cost')
@@ -1415,12 +1436,16 @@ class kraken(Exchange, ImplicitAPI):
1415
1436
  takerOrMaker = None
1416
1437
  if maker is not None:
1417
1438
  takerOrMaker = 'maker' if maker else 'taker'
1439
+ if datetime is None:
1440
+ datetime = self.iso8601(timestamp)
1441
+ else:
1442
+ timestamp = self.parse8601(datetime)
1418
1443
  return self.safe_trade({
1419
1444
  'id': id,
1420
1445
  'order': orderId,
1421
1446
  'info': trade,
1422
1447
  'timestamp': timestamp,
1423
- 'datetime': self.iso8601(timestamp),
1448
+ 'datetime': datetime,
1424
1449
  'symbol': symbol,
1425
1450
  'type': type,
1426
1451
  'side': side,
ccxt/mexc.py CHANGED
@@ -854,6 +854,7 @@ class mexc(Exchange, ImplicitAPI):
854
854
  'PROS': 'PROSFINANCE', # conflict with Prosper
855
855
  'SIN': 'SINCITYTOKEN',
856
856
  'SOUL': 'SOULSWAP',
857
+ 'XBT': 'XBT', # restore original mapping
857
858
  },
858
859
  'exceptions': {
859
860
  'exact': {
ccxt/modetrade.py CHANGED
@@ -1651,7 +1651,7 @@ class modetrade(Exchange, ImplicitAPI):
1651
1651
  #
1652
1652
  # {
1653
1653
  # "success": True,
1654
- # "timestamp": 1702989203989,
1654
+ # "timestamp": 1702989203988,
1655
1655
  # "data": {
1656
1656
  # "status": "CANCEL_SENT"
1657
1657
  # }
@@ -1659,7 +1659,7 @@ class modetrade(Exchange, ImplicitAPI):
1659
1659
  #
1660
1660
  # {
1661
1661
  # "success": True,
1662
- # "timestamp": 1702989203989,
1662
+ # "timestamp": 1702989203988,
1663
1663
  # "status": "CANCEL_SENT"
1664
1664
  # }
1665
1665
  #
ccxt/paradex.py CHANGED
@@ -785,7 +785,7 @@ class paradex(Exchange, ImplicitAPI):
785
785
  # "ask": "69578.2",
786
786
  # "volume_24h": "5815541.397939004",
787
787
  # "total_volume": "584031465.525259686",
788
- # "created_at": 1718170156580,
788
+ # "created_at": 1718170156581,
789
789
  # "underlying_price": "67367.37268422",
790
790
  # "open_interest": "162.272",
791
791
  # "funding_rate": "0.01629574927887",
ccxt/pro/__init__.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # ----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.4.90'
7
+ __version__ = '4.4.91'
8
8
 
9
9
  # ----------------------------------------------------------------------------
10
10
 
ccxt/pro/bitstamp.py CHANGED
@@ -502,7 +502,7 @@ class bitstamp(ccxt.async_support.bitstamp):
502
502
  #
503
503
  sessionToken = self.safe_string(response, 'token')
504
504
  if sessionToken is not None:
505
- userId = self.safe_number(response, 'user_id')
505
+ userId = self.safe_string(response, 'user_id')
506
506
  validity = self.safe_integer_product(response, 'valid_sec', 1000)
507
507
  self.options['expiresIn'] = self.sum(time, validity)
508
508
  self.options['userId'] = userId
ccxt/pro/bybit.py CHANGED
@@ -1786,11 +1786,12 @@ class bybit(ccxt.async_support.bybit):
1786
1786
  rawOrders = self.safe_value(rawOrders, 'result', rawOrders)
1787
1787
  symbols: dict = {}
1788
1788
  for i in range(0, len(rawOrders)):
1789
- parsed = None
1790
- if isSpot:
1791
- parsed = self.parse_ws_spot_order(rawOrders[i])
1792
- else:
1793
- parsed = self.parse_order(rawOrders[i])
1789
+ parsed = self.parse_order(rawOrders[i])
1790
+ # if isSpot:
1791
+ # parsed = self.parseWsSpotOrder(rawOrders[i])
1792
+ # else:
1793
+ # parsed = self.parse_order(rawOrders[i])
1794
+ # }
1794
1795
  symbol = parsed['symbol']
1795
1796
  symbols[symbol] = True
1796
1797
  orders.append(parsed)
@@ -1801,137 +1802,6 @@ class bybit(ccxt.async_support.bybit):
1801
1802
  messageHash = 'orders'
1802
1803
  client.resolve(orders, messageHash)
1803
1804
 
1804
- def parse_ws_spot_order(self, order, market=None):
1805
- #
1806
- # {
1807
- # "e": "executionReport",
1808
- # "E": "1653297251061", # timestamp
1809
- # "s": "LTCUSDT", # symbol
1810
- # "c": "1653297250740", # user id
1811
- # "S": "SELL", # side
1812
- # "o": "MARKET_OF_BASE", # order type
1813
- # "f": "GTC", # time in force
1814
- # "q": "0.16233", # quantity
1815
- # "p": "0", # price
1816
- # "X": "NEW", # status
1817
- # "i": "1162336018974750208", # order id
1818
- # "M": "0",
1819
- # "l": "0", # last filled
1820
- # "z": "0", # total filled
1821
- # "L": "0", # last traded price
1822
- # "n": "0", # trading fee
1823
- # "N": '', # fee asset
1824
- # "u": True,
1825
- # "w": True,
1826
- # "m": False, # is limit_maker
1827
- # "O": "1653297251042", # order creation
1828
- # "Z": "0", # total filled
1829
- # "A": "0", # account id
1830
- # "C": False, # is close
1831
- # "v": "0", # leverage
1832
- # "d": "NO_LIQ"
1833
- # }
1834
- # v5
1835
- # {
1836
- # "category":"spot",
1837
- # "symbol":"LTCUSDT",
1838
- # "orderId":"1474764674982492160",
1839
- # "orderLinkId":"1690541649154749",
1840
- # "blockTradeId":"",
1841
- # "side":"Buy",
1842
- # "positionIdx":0,
1843
- # "orderStatus":"Cancelled",
1844
- # "cancelType":"UNKNOWN",
1845
- # "rejectReason":"EC_NoError",
1846
- # "timeInForce":"GTC",
1847
- # "isLeverage":"0",
1848
- # "price":"0",
1849
- # "qty":"5.00000",
1850
- # "avgPrice":"0",
1851
- # "leavesQty":"0.00000",
1852
- # "leavesValue":"5.0000000",
1853
- # "cumExecQty":"0.00000",
1854
- # "cumExecValue":"0.0000000",
1855
- # "cumExecFee":"",
1856
- # "orderType":"Market",
1857
- # "stopOrderType":"",
1858
- # "orderIv":"",
1859
- # "triggerPrice":"0.000",
1860
- # "takeProfit":"",
1861
- # "stopLoss":"",
1862
- # "triggerBy":"",
1863
- # "tpTriggerBy":"",
1864
- # "slTriggerBy":"",
1865
- # "triggerDirection":0,
1866
- # "placeType":"",
1867
- # "lastPriceOnCreated":"0.000",
1868
- # "closeOnTrigger":false,
1869
- # "reduceOnly":false,
1870
- # "smpGroup":0,
1871
- # "smpType":"None",
1872
- # "smpOrderId":"",
1873
- # "createdTime":"1690541649160",
1874
- # "updatedTime":"1690541649168"
1875
- # }
1876
- #
1877
- id = self.safe_string_2(order, 'i', 'orderId')
1878
- marketId = self.safe_string_2(order, 's', 'symbol')
1879
- symbol = self.safe_symbol(marketId, market, None, 'spot')
1880
- timestamp = self.safe_integer_2(order, 'O', 'createdTime')
1881
- price = self.safe_string_2(order, 'p', 'price')
1882
- if price == '0':
1883
- price = None # market orders
1884
- filled = self.safe_string_2(order, 'z', 'cumExecQty')
1885
- status = self.parse_order_status(self.safe_string_2(order, 'X', 'orderStatus'))
1886
- side = self.safe_string_lower_2(order, 'S', 'side')
1887
- lastTradeTimestamp = self.safe_string_2(order, 'E', 'updatedTime')
1888
- timeInForce = self.safe_string_2(order, 'f', 'timeInForce')
1889
- amount = None
1890
- cost = self.safe_string_2(order, 'Z', 'cumExecValue')
1891
- type = self.safe_string_lower_2(order, 'o', 'orderType')
1892
- if (type is not None) and (type.find('market') >= 0):
1893
- type = 'market'
1894
- if type == 'market' and side == 'buy':
1895
- amount = filled
1896
- else:
1897
- amount = self.safe_string_2(order, 'orderQty', 'qty')
1898
- fee = None
1899
- feeCost = self.safe_string_2(order, 'n', 'cumExecFee')
1900
- if feeCost is not None and feeCost != '0':
1901
- feeCurrencyId = self.safe_string(order, 'N')
1902
- feeCurrencyCode = self.safe_currency_code(feeCurrencyId)
1903
- fee = {
1904
- 'cost': feeCost,
1905
- 'currency': feeCurrencyCode,
1906
- }
1907
- triggerPrice = self.omit_zero(self.safe_string(order, 'triggerPrice'))
1908
- return self.safe_order({
1909
- 'info': order,
1910
- 'id': id,
1911
- 'clientOrderId': self.safe_string_2(order, 'c', 'orderLinkId'),
1912
- 'timestamp': timestamp,
1913
- 'datetime': self.iso8601(timestamp),
1914
- 'lastTradeTimestamp': lastTradeTimestamp,
1915
- 'symbol': symbol,
1916
- 'type': type,
1917
- 'timeInForce': timeInForce,
1918
- 'postOnly': None,
1919
- 'side': side,
1920
- 'price': price,
1921
- 'stopPrice': triggerPrice,
1922
- 'triggerPrice': triggerPrice,
1923
- 'takeProfitPrice': self.safe_string(order, 'takeProfit'),
1924
- 'stopLossPrice': self.safe_string(order, 'stopLoss'),
1925
- 'reduceOnly': self.safe_value(order, 'reduceOnly'),
1926
- 'amount': amount,
1927
- 'cost': cost,
1928
- 'average': self.safe_string(order, 'avgPrice'),
1929
- 'filled': filled,
1930
- 'remaining': None,
1931
- 'status': status,
1932
- 'fee': fee,
1933
- }, market)
1934
-
1935
1805
  async def watch_balance(self, params={}) -> Balances:
1936
1806
  """
1937
1807
  watch balance and get the amount of funds available for trading or funds locked in orders