ccxt 4.4.44__py2.py3-none-any.whl → 4.4.46__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 (74) hide show
  1. ccxt/__init__.py +1 -1
  2. ccxt/abstract/blofin.py +22 -0
  3. ccxt/ascendex.py +15 -1
  4. ccxt/async_support/__init__.py +1 -1
  5. ccxt/async_support/ascendex.py +15 -1
  6. ccxt/async_support/base/exchange.py +1 -1
  7. ccxt/async_support/binance.py +178 -62
  8. ccxt/async_support/bingx.py +15 -9
  9. ccxt/async_support/bitfinex.py +1 -1
  10. ccxt/async_support/bitget.py +105 -41
  11. ccxt/async_support/bitmart.py +3 -3
  12. ccxt/async_support/bitmex.py +1 -1
  13. ccxt/async_support/blofin.py +22 -0
  14. ccxt/async_support/bybit.py +84 -40
  15. ccxt/async_support/coinbase.py +1 -1
  16. ccxt/async_support/coinex.py +1 -1
  17. ccxt/async_support/cryptocom.py +1 -1
  18. ccxt/async_support/delta.py +9 -4
  19. ccxt/async_support/exmo.py +16 -8
  20. ccxt/async_support/gate.py +1 -2
  21. ccxt/async_support/hashkey.py +6 -1
  22. ccxt/async_support/htx.py +2 -2
  23. ccxt/async_support/hyperliquid.py +3 -4
  24. ccxt/async_support/kraken.py +1 -1
  25. ccxt/async_support/krakenfutures.py +1 -1
  26. ccxt/async_support/kucoin.py +1 -1
  27. ccxt/async_support/kucoinfutures.py +2 -3
  28. ccxt/async_support/lykke.py +1 -1
  29. ccxt/async_support/mexc.py +3 -2
  30. ccxt/async_support/myokx.py +8 -0
  31. ccxt/async_support/okx.py +4 -4
  32. ccxt/async_support/onetrading.py +20 -4
  33. ccxt/async_support/whitebit.py +31 -8
  34. ccxt/async_support/woo.py +1 -1
  35. ccxt/async_support/woofipro.py +2 -2
  36. ccxt/base/exchange.py +1 -1
  37. ccxt/binance.py +178 -62
  38. ccxt/bingx.py +15 -9
  39. ccxt/bitfinex.py +1 -1
  40. ccxt/bitget.py +105 -41
  41. ccxt/bitmart.py +3 -3
  42. ccxt/bitmex.py +1 -1
  43. ccxt/blofin.py +22 -0
  44. ccxt/bybit.py +84 -40
  45. ccxt/coinbase.py +1 -1
  46. ccxt/coinex.py +1 -1
  47. ccxt/cryptocom.py +1 -1
  48. ccxt/delta.py +9 -4
  49. ccxt/exmo.py +16 -8
  50. ccxt/gate.py +1 -2
  51. ccxt/hashkey.py +6 -1
  52. ccxt/htx.py +2 -2
  53. ccxt/hyperliquid.py +3 -4
  54. ccxt/kraken.py +1 -1
  55. ccxt/krakenfutures.py +1 -1
  56. ccxt/kucoin.py +1 -1
  57. ccxt/kucoinfutures.py +2 -3
  58. ccxt/lykke.py +1 -1
  59. ccxt/mexc.py +3 -2
  60. ccxt/myokx.py +8 -0
  61. ccxt/okx.py +4 -4
  62. ccxt/onetrading.py +20 -4
  63. ccxt/pro/__init__.py +1 -1
  64. ccxt/pro/binance.py +2 -1
  65. ccxt/pro/coinex.py +1 -1
  66. ccxt/pro/myokx.py +5 -0
  67. ccxt/whitebit.py +31 -8
  68. ccxt/woo.py +1 -1
  69. ccxt/woofipro.py +2 -2
  70. {ccxt-4.4.44.dist-info → ccxt-4.4.46.dist-info}/METADATA +4 -4
  71. {ccxt-4.4.44.dist-info → ccxt-4.4.46.dist-info}/RECORD +74 -74
  72. {ccxt-4.4.44.dist-info → ccxt-4.4.46.dist-info}/LICENSE.txt +0 -0
  73. {ccxt-4.4.44.dist-info → ccxt-4.4.46.dist-info}/WHEEL +0 -0
  74. {ccxt-4.4.44.dist-info → ccxt-4.4.46.dist-info}/top_level.txt +0 -0
ccxt/binance.py CHANGED
@@ -1642,7 +1642,7 @@ class binance(Exchange, ImplicitAPI):
1642
1642
  'fetchClosedOrders': {
1643
1643
  'marginMode': True,
1644
1644
  'limit': 1000,
1645
- 'daysBackClosed': None,
1645
+ 'daysBack': None,
1646
1646
  'daysBackCanceled': None,
1647
1647
  'untilDays': 10000,
1648
1648
  'trigger': False,
@@ -1712,7 +1712,7 @@ class binance(Exchange, ImplicitAPI):
1712
1712
  'fetchClosedOrders': {
1713
1713
  'marginMode': True,
1714
1714
  'limit': 1000,
1715
- 'daysBackClosed': 90,
1715
+ 'daysBack': 90,
1716
1716
  'daysBackCanceled': 3,
1717
1717
  'untilDays': 7,
1718
1718
  'trigger': False,
@@ -2435,92 +2435,189 @@ class binance(Exchange, ImplicitAPI):
2435
2435
  'portfolioMargin': {
2436
2436
  'exact': {
2437
2437
  #
2438
- # 1xxx
2438
+ # 10xx General Server or Network Issues
2439
2439
  #
2440
- '-1005': PermissionDenied, # {"code":-1005,"msg":"No such IP has been white listed"}
2441
- '-1011': PermissionDenied, # {"code":-1011,"msg":"This IP cannot access self route."}
2442
- '-1023': BadRequest, # START_TIME_GREATER_THAN_END_TIME
2443
- '-1109': BadRequest, # BAD_ACCOUNT
2444
- '-1110': BadSymbol, # BAD_INSTRUMENT_TYPE
2445
- '-1113': BadRequest, # {"code":-1113,"msg":"Withdrawal amount must be negative."}
2446
- '-1128': BadRequest, # {"code":-1128,"msg":"Combination of optional parameters invalid."}
2447
- '-1136': BadRequest, # INVALID_NEW_ORDER_RESP_TYPE
2440
+ '-1000': OperationFailed, # An unknown error occured while processing the request.
2441
+ '-1001': ExchangeError, # Internal error; unable to process your request. Please try again.
2442
+ '-1002': PermissionDenied, # You are not authorized to execute self request.
2443
+ '-1003': RateLimitExceeded, # Too many requests use the websocket for live updates to avoid polling the API.
2444
+ '-1004': BadRequest, # This IP is already on the white list.
2445
+ '-1005': PermissionDenied, # No such IP has been white listed.
2446
+ '-1006': BadResponse, # An unexpected response was received from the message bus. Execution status unknown.
2447
+ '-1007': BadResponse, # Timeout waiting for response from backend server. Send status unknown, execution status unknown.
2448
+ '-1008': OperationFailed, # WS Spot server is currently overloaded with other requests. Please try again in a few minutes.
2449
+ '-1010': ExchangeError, # ERROR_MSG_RECEIVED
2450
+ '-1011': PermissionDenied, # This IP cannot access self route.
2451
+ '-1013': ExchangeError, # INVALID_MESSAGE.
2452
+ '-1014': InvalidOrder, # Unsupported order combination.
2453
+ '-1015': InvalidOrder, # Too many new orders.
2454
+ '-1016': NotSupported, # This service is no longer available.
2455
+ '-1020': NotSupported, # This operation is not supported.
2456
+ '-1021': BadRequest, # Timestamp for self request is outside of the recvWindow 1000ms ahead of the servers time.
2457
+ '-1022': BadRequest, # Signature for self request is not valid.
2458
+ '-1023': BadRequest, # Start time is greater than end time
2459
+ '-1099': OperationFailed, # WS not found authenticated or authorized
2448
2460
  #
2449
- # 2xxx
2461
+ # 11xx Request Issues
2450
2462
  #
2451
- '-2016': OperationRejected, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
2452
- '-2018': InsufficientFunds, # {"code":-2018,"msg":"Balance is insufficient"}
2453
- '-2019': InsufficientFunds, # Margin is insufficient
2454
- '-2020': OrderNotFillable, # UNABLE_TO_FILL
2463
+ '-1100': BadRequest, # Illegal characters found in a parameter.
2464
+ '-1101': BadRequest, # Too many parameters sent for self endpoint.
2465
+ '-1102': BadRequest, # A mandatory parameter was not sent, was empty/null, or malformed.
2466
+ '-1103': BadRequest, # An unknown parameter was sent.
2467
+ '-1104': BadRequest, # Not all sent parameters were read.
2468
+ '-1105': BadRequest, # A parameter was empty.
2469
+ '-1106': BadRequest, # A parameter was sent when not required.
2470
+ '-1108': BadRequest, # Invalid asset.
2471
+ '-1109': BadRequest, # Invalid account.
2472
+ '-1110': BadSymbol, # Invalid symbolType.
2473
+ '-1111': BadRequest, # Precision is over the maximum defined for self asset.
2474
+ '-1112': BadRequest, # No orders on book for symbol.
2475
+ '-1113': BadRequest, # Withdrawal amount must be negative.
2476
+ '-1114': BadRequest, # TimeInForce parameter sent when not required.
2477
+ '-1115': BadRequest, # Invalid timeInForce.
2478
+ '-1116': BadRequest, # Invalid orderType.
2479
+ '-1117': BadRequest, # Invalid side.
2480
+ '-1118': BadRequest, # New client order ID was empty.
2481
+ '-1119': BadRequest, # Original client order ID was empty.
2482
+ '-1120': BadRequest, # Invalid interval.
2483
+ '-1121': BadSymbol, # Invalid symbol.
2484
+ '-1125': BadRequest, # This listenKey does not exist.
2485
+ '-1127': BadRequest, # Lookup interval is too big.
2486
+ '-1128': BadRequest, # Combination of optional parameters invalid.
2487
+ '-1130': BadRequest, # Invalid data sent for a parameter.
2488
+ '-1131': BadRequest, # WS recvWindow must be less than 60000
2489
+ '-1134': BadRequest, # WS strategyType was less than 1000000.
2490
+ '-1136': BadRequest, # Invalid newOrderRespType.
2491
+ '-1145': BadRequest, # WS cancelRestrictions has to be either ONLY_NEW or ONLY_PARTIALLY_FILLED.
2492
+ '-1151': BadRequest, # WS Symbol is present multiple times in the list.
2493
+ #
2494
+ # 20xx Processing Issues
2495
+ #
2496
+ '-2010': InvalidOrder, # NEW_ORDER_REJECTED
2497
+ '-2011': OperationRejected, # CANCEL_REJECTED
2498
+ '-2013': OrderNotFound, # Order does not exist.
2499
+ '-2014': OperationRejected, # API-key format invalid.
2500
+ '-2015': OperationRejected, # Invalid API-key, IP, or permissions for action.
2501
+ '-2016': OperationFailed, # No trading window could be found for the symbol. Try ticker/24hrs instead.
2502
+ '-2018': OperationFailed, # Balance is insufficient.
2503
+ '-2019': OperationFailed, # Margin is insufficient.
2504
+ '-2020': OrderNotFillable, # Unable to fill.
2455
2505
  '-2021': OrderImmediatelyFillable, # Order would immediately trigger.
2456
- '-2022': InvalidOrder, # ReduceOnly Order is rejected
2457
- '-2023': OperationFailed, # User in liquidation mode now
2458
- '-2024': OperationRejected, # Position is not sufficient
2506
+ '-2022': InvalidOrder, # ReduceOnly Order is rejected.
2507
+ '-2023': OperationFailed, # User in liquidation mode now.
2508
+ '-2024': OperationRejected, # Position is not sufficient.
2459
2509
  '-2025': OperationRejected, # Reach max open order limit.
2460
2510
  '-2026': InvalidOrder, # This OrderType is not supported when reduceOnly.
2461
2511
  '-2027': OperationRejected, # Exceeded the maximum allowable position at current leverage.
2462
2512
  '-2028': OperationRejected, # Leverage is smaller than permitted: insufficient margin balance.
2463
2513
  #
2464
- # 4xxx
2514
+ # 4xxx Filters and other issues
2465
2515
  #
2466
- '-4063': BadRequest, # INVALID_OPTIONS_REQUEST_TYPE
2467
- '-4064': BadRequest, # INVALID_OPTIONS_TIME_FRAME
2468
- '-4065': BadRequest, # INVALID_OPTIONS_AMOUNT
2469
- '-4066': BadRequest, # INVALID_OPTIONS_EVENT_TYPE
2470
- '-4069': BadRequest, # Position INVALID_OPTIONS_PREMIUM_FEE
2516
+ '-4000': BadRequest, # Invalid order status.
2517
+ '-4001': BadRequest, # Price less than 0.
2518
+ '-4002': BadRequest, # Price greater than max price.
2519
+ '-4003': BadRequest, # Quantity less than zero.
2520
+ '-4004': BadRequest, # Quantity less than min quantity.
2521
+ '-4005': BadRequest, # Quantity greater than max quantity.
2522
+ '-4006': BadRequest, # Stop price less than zero.
2523
+ '-4007': BadRequest, # Stop price greater than max price.
2524
+ '-4008': BadRequest, # Tick size less than zero.
2525
+ '-4009': BadRequest, # Max price less than min price.
2526
+ '-4010': BadRequest, # Max qty less than min qty.
2527
+ '-4011': BadRequest, # Step size less than zero.
2528
+ '-4012': BadRequest, # Max mum orders less than zero.
2529
+ '-4013': BadRequest, # Price less than min price.
2530
+ '-4014': BadRequest, # Price not increased by tick size.
2531
+ '-4015': BadRequest, # Client order id is not valid.
2532
+ '-4016': BadRequest, # Price is higher than mark price multiplier cap.
2533
+ '-4017': BadRequest, # Multiplier up less than zero.
2534
+ '-4018': BadRequest, # Multiplier down less than zero.
2535
+ '-4019': BadRequest, # Composite scale too large.
2536
+ '-4020': BadRequest, # Target strategy invalid for orderType '%s',reduceOnly '%b'.
2537
+ '-4021': BadRequest, # Invalid depth limit.
2538
+ '-4022': BadRequest, # market status sent is not valid.
2539
+ '-4023': BadRequest, # Qty not increased by step size.
2540
+ '-4024': BadRequest, # Price is lower than mark price multiplier floor.
2541
+ '-4025': BadRequest, # Multiplier decimal less than zero.
2542
+ '-4026': BadRequest, # Commission invalid.
2543
+ '-4027': BadRequest, # Invalid account type.
2544
+ '-4028': BadRequest, # Invalid leverage
2545
+ '-4029': BadRequest, # Tick size precision is invalid.
2546
+ '-4030': BadRequest, # Step size precision is invalid.
2547
+ '-4031': BadRequest, # Invalid parameter working type
2548
+ '-4032': BadRequest, # Exceed maximum cancel order size.
2549
+ '-4033': BadRequest, # Insurance account not found.
2550
+ '-4044': BadRequest, # Balance Type is invalid.
2551
+ '-4045': BadRequest, # Reach max stop order limit.
2552
+ '-4046': BadRequest, # No need to change margin type.
2553
+ '-4047': BadRequest, # Margin type cannot be changed if there exists open orders.
2554
+ '-4048': BadRequest, # Margin type cannot be changed if there exists position.
2555
+ '-4049': BadRequest, # Add margin only support for isolated position.
2556
+ '-4050': BadRequest, # Cross balance insufficient.
2557
+ '-4051': BadRequest, # Isolated balance insufficient.
2558
+ '-4052': BadRequest, # No need to change auto add margin.
2559
+ '-4053': BadRequest, # Auto add margin only support for isolated position.
2560
+ '-4054': BadRequest, # Cannot add position margin: position is 0.
2561
+ '-4055': BadRequest, # Amount must be positive.
2562
+ '-4056': PermissionDenied, # Invalid api key type.
2563
+ '-4057': PermissionDenied, # Invalid api public key
2564
+ '-4058': BadRequest, # maxPrice and priceDecimal too large,please check.
2565
+ '-4059': BadRequest, # No need to change position side.
2566
+ '-4060': BadRequest, # Invalid position side.
2567
+ '-4061': InvalidOrder, # Order's position side does not match user's setting.
2568
+ '-4062': BadRequest, # Invalid or improper reduceOnly value.
2569
+ '-4063': BadRequest, # Invalid options request type
2570
+ '-4064': BadRequest, # Invalid options time frame
2571
+ '-4065': BadRequest, # Invalid options amount
2572
+ '-4066': BadRequest, # Invalid options event type
2573
+ '-4067': BadRequest, # Position side cannot be changed if there exists open orders.
2574
+ '-4068': BadRequest, # Position side cannot be changed if there exists position.
2575
+ '-4069': BadRequest, # Invalid options premium fee
2471
2576
  '-4070': BadRequest, # Client options id is not valid.
2472
2577
  '-4071': BadRequest, # Invalid options direction
2473
2578
  '-4072': OperationRejected, # premium fee is not updated, reject order
2474
- '-4073': BadRequest, # OPTIONS_PREMIUM_INPUT_LESS_THAN_ZERO
2579
+ '-4073': BadRequest, # input premium fee is less than 0, reject order
2475
2580
  '-4074': BadRequest, # Order amount is bigger than upper boundary or less than 0, reject order
2476
2581
  '-4075': BadRequest, # output premium fee is less than 0, reject order
2477
2582
  '-4076': OperationRejected, # original fee is too much higher than last fee
2478
2583
  '-4077': OperationRejected, # place order amount has reached to limit, reject order
2479
2584
  '-4078': OperationFailed, # options internal error
2480
2585
  '-4079': BadRequest, # invalid options id
2481
- '-4080': PermissionDenied, # user not found with id: %s
2482
- '-4081': BadRequest, # OPTIONS_NOT_FOUND
2586
+ '-4080': PermissionDenied, # user not found
2587
+ '-4081': BadRequest, # options not found
2588
+ '-4082': BadRequest, # Invalid number of batch place orders.
2589
+ '-4083': BadRequest, # Fail to place batch orders.
2590
+ '-4084': NotSupported, # Method is not allowed currently. Upcoming soon.
2483
2591
  '-4085': BadRequest, # Invalid notional limit coefficient
2484
2592
  '-4086': BadRequest, # Invalid price spread threshold
2485
2593
  '-4087': PermissionDenied, # User can only place reduce only order
2486
2594
  '-4088': PermissionDenied, # User can not place order currently
2487
- '-4114': BadRequest, # INVALID_CLIENT_TRAN_ID_LEN
2488
- '-4115': BadRequest, # DUPLICATED_CLIENT_TRAN_ID
2489
- '-4118': OperationRejected, # REDUCE_ONLY_MARGIN_CHECK_FAILED
2595
+ '-4104': BadRequest, # Invalid contract type
2596
+ '-4114': BadRequest, # clientTranId is not valid
2597
+ '-4115': BadRequest, # clientTranId is duplicated
2598
+ '-4118': OperationRejected, # ReduceOnly Order Failed. Please check your existing position and open orders
2490
2599
  '-4131': OperationRejected, # The counterparty's best price does not meet the PERCENT_PRICE filter limit
2491
- '-4140': BadRequest, # Invalid symbol status for opening position
2600
+ '-4135': BadRequest, # Invalid activation price
2601
+ '-4137': BadRequest, # Quantity must be zero with closePosition equals True
2602
+ '-4138': BadRequest, # Reduce only must be True with closePosition equals True
2603
+ '-4139': BadRequest, # Order type can not be market if it's unable to cancel
2604
+ '-4140': OrderImmediatelyFillable, # Invalid symbol status for opening position
2492
2605
  '-4141': BadRequest, # Symbol is closed
2606
+ '-4142': OrderImmediatelyFillable, # REJECT: take profit or stop order will be triggered immediately
2493
2607
  '-4144': BadSymbol, # Invalid pair
2494
2608
  '-4161': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions
2495
- '-4164': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions
2609
+ '-4164': InvalidOrder, # Order's notional must be no smaller than 5.0(unless you choose reduce only)
2496
2610
  '-4165': BadRequest, # Invalid time interval
2497
- '-4183': BadRequest, # Price is higher than stop price multiplier cap.
2498
- '-4184': BadRequest, # Price is lower than stop price multiplier floor.
2611
+ '-4183': InvalidOrder, # Price is higher than stop price multiplier cap.
2612
+ '-4184': InvalidOrder, # Price is lower than stop price multiplier floor.
2613
+ '-4408': InvalidOrder, # This symbol is in reduce only mode due to regulation requirements. Please upgrade to Binance Credits Trading Mode.
2499
2614
  #
2500
- # 5xxx
2615
+ # 5xxx Order Execution Issues
2501
2616
  #
2502
2617
  '-5021': OrderNotFillable, # Due to the order could not be filled immediately, the FOK order has been rejected.
2503
2618
  '-5022': OrderNotFillable, # Due to the order could not be executed, the Post Only order will be rejected.
2504
- #
2505
- # 2xxxx
2506
- #
2507
- '-20121': ExchangeError, # override commons
2508
- '-20124': ExchangeError, # override commons
2509
- '-20130': ExchangeError, # override commons
2510
- '-20132': ExchangeError, # override commons
2511
- '-20194': ExchangeError, # override commons
2512
- '-20195': ExchangeError, # override commons
2513
- '-20196': ExchangeError, # override commons
2514
- '-20198': ExchangeError, # override commons
2515
- '-20204': ExchangeError, # override commons
2516
- # 21xxx - PORTFOLIO MARGIN(documented in spot docs)
2517
- '-21001': BadRequest, # Request ID is not a Portfolio Margin Account.
2518
- '-21002': BadRequest, # Portfolio Margin Account doesn't support transfer from margin to futures.
2519
- '-21003': BadResponse, # Fail to retrieve margin assets.
2520
- '-21004': OperationRejected, # User doesn’t have portfolio margin bankruptcy loan
2521
- '-21005': InsufficientFunds, # User’s spot wallet doesn’t have enough BUSD to repay portfolio margin bankruptcy loan
2522
- '-21006': OperationFailed, # User had portfolio margin bankruptcy loan repayment in process
2523
- '-21007': OperationFailed, # User failed to repay portfolio margin bankruptcy loan since liquidation was in process
2619
+ '-5028': OperationFailed, # The requested timestamp is outside the recvWindow of the matching engine
2620
+ '-5041': RateLimitExceeded, # Time out for too many requests from self account queueing at the same time.
2524
2621
  },
2525
2622
  },
2526
2623
  'exact': {
@@ -3548,7 +3645,11 @@ class binance(Exchange, ImplicitAPI):
3548
3645
  account['used'] = self.safe_string(entry, 'crossMarginLocked')
3549
3646
  account['total'] = self.safe_string(entry, 'crossMarginAsset')
3550
3647
  else:
3551
- account['total'] = self.safe_string(entry, 'totalWalletBalance')
3648
+ usedLinear = self.safe_string(entry, 'umUnrealizedPNL')
3649
+ usedInverse = self.safe_string(entry, 'cmUnrealizedPNL')
3650
+ totalUsed = Precise.string_add(usedLinear, usedInverse)
3651
+ totalWalletBalance = self.safe_string(entry, 'totalWalletBalance')
3652
+ account['total'] = Precise.string_add(totalUsed, totalWalletBalance)
3552
3653
  result[code] = account
3553
3654
  elif not isolated and ((type == 'spot') or cross):
3554
3655
  timestamp = self.safe_integer(response, 'updateTime')
@@ -5158,10 +5259,10 @@ class binance(Exchange, ImplicitAPI):
5158
5259
  request: dict = {
5159
5260
  'symbol': market['id'],
5160
5261
  'side': side.upper(),
5262
+ 'orderId': id,
5263
+ 'quantity': self.amount_to_precision(symbol, amount),
5161
5264
  }
5162
5265
  clientOrderId = self.safe_string_n(params, ['newClientOrderId', 'clientOrderId', 'origClientOrderId'])
5163
- request['orderId'] = id
5164
- request['quantity'] = self.amount_to_precision(symbol, amount)
5165
5266
  if price is not None:
5166
5267
  request['price'] = self.price_to_precision(symbol, price)
5167
5268
  if clientOrderId is not None:
@@ -5175,6 +5276,8 @@ class binance(Exchange, ImplicitAPI):
5175
5276
 
5176
5277
  https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Modify-Order
5177
5278
  https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Modify-Order
5279
+ https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-UM-Order
5280
+ https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Modify-CM-Order
5178
5281
 
5179
5282
  :param str id: cancel order id
5180
5283
  :param str symbol: unified symbol of the market to create an order in
@@ -5183,16 +5286,28 @@ class binance(Exchange, ImplicitAPI):
5183
5286
  :param float amount: how much of currency you want to trade in units of base currency
5184
5287
  :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5185
5288
  :param dict [params]: extra parameters specific to the exchange API endpoint
5289
+ :param boolean [params.portfolioMargin]: set to True if you would like to edit an order in a portfolio margin account
5186
5290
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5187
5291
  """
5188
5292
  self.load_markets()
5189
5293
  market = self.market(symbol)
5294
+ isPortfolioMargin = None
5295
+ isPortfolioMargin, params = self.handle_option_and_params_2(params, 'editContractOrder', 'papi', 'portfolioMargin', False)
5296
+ if market['linear'] or isPortfolioMargin:
5297
+ if price is None:
5298
+ raise ArgumentsRequired(self.id + ' editOrder() requires a price argument for portfolio margin and linear orders')
5190
5299
  request = self.edit_contract_order_request(id, symbol, type, side, amount, price, params)
5191
5300
  response = None
5192
5301
  if market['linear']:
5193
- response = self.fapiPrivatePutOrder(self.extend(request, params))
5302
+ if isPortfolioMargin:
5303
+ response = self.papiPutUmOrder(self.extend(request, params))
5304
+ else:
5305
+ response = self.fapiPrivatePutOrder(self.extend(request, params))
5194
5306
  elif market['inverse']:
5195
- response = self.dapiPrivatePutOrder(self.extend(request, params))
5307
+ if isPortfolioMargin:
5308
+ response = self.papiPutCmOrder(self.extend(request, params))
5309
+ else:
5310
+ response = self.dapiPrivatePutOrder(self.extend(request, params))
5196
5311
  #
5197
5312
  # swap and future
5198
5313
  #
@@ -5237,6 +5352,7 @@ class binance(Exchange, ImplicitAPI):
5237
5352
  :param float amount: how much of currency you want to trade in units of base currency
5238
5353
  :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
5239
5354
  :param dict [params]: extra parameters specific to the exchange API endpoint
5355
+ :param boolean [params.portfolioMargin]: set to True if you would like to edit an order in a portfolio margin account
5240
5356
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
5241
5357
  """
5242
5358
  self.load_markets()
@@ -11151,7 +11267,7 @@ class binance(Exchange, ImplicitAPI):
11151
11267
  elif url.startswith('https://eapi.' + hostname + '/'):
11152
11268
  marketType = 'option'
11153
11269
  elif url.startswith('https://papi.' + hostname + '/'):
11154
- marketType = 'portfoliomargin'
11270
+ marketType = 'portfolioMargin'
11155
11271
  if marketType is not None:
11156
11272
  exceptionsForMarketType = self.safe_dict(self.exceptions, marketType, {})
11157
11273
  return self.safe_dict(exceptionsForMarketType, exactOrBroad, {})
ccxt/bingx.py CHANGED
@@ -565,7 +565,7 @@ class bingx(Exchange, ImplicitAPI):
565
565
  'mark': True,
566
566
  'index': True,
567
567
  },
568
- 'limitPrice': True,
568
+ 'price': True,
569
569
  },
570
570
  'timeInForce': {
571
571
  'IOC': True,
@@ -612,7 +612,7 @@ class bingx(Exchange, ImplicitAPI):
612
612
  'fetchClosedOrders': {
613
613
  'marginMode': False,
614
614
  'limit': 1000,
615
- 'daysBackClosed': None,
615
+ 'daysBack': None,
616
616
  'daysBackCanceled': None,
617
617
  'untilDays': 7,
618
618
  'trigger': False,
@@ -636,7 +636,7 @@ class bingx(Exchange, ImplicitAPI):
636
636
  'fetchClosedOrders': {
637
637
  'marginMode': False,
638
638
  'limit': 1000,
639
- 'daysBackClosed': None,
639
+ 'daysBack': None,
640
640
  'daysBackCanceled': None,
641
641
  'untilDays': 7,
642
642
  'trigger': False,
@@ -2651,8 +2651,10 @@ class bingx(Exchange, ImplicitAPI):
2651
2651
  :param dict [params]: extra parameters specific to the exchange API endpoint
2652
2652
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2653
2653
  """
2654
- params['quoteOrderQty'] = cost
2655
- return self.create_order(symbol, 'market', side, cost, None, params)
2654
+ req = {
2655
+ 'quoteOrderQty': cost,
2656
+ }
2657
+ return self.create_order(symbol, 'market', side, cost, None, self.extend(req, params))
2656
2658
 
2657
2659
  def create_market_buy_order_with_cost(self, symbol: str, cost: float, params={}):
2658
2660
  """
@@ -2662,8 +2664,10 @@ class bingx(Exchange, ImplicitAPI):
2662
2664
  :param dict [params]: extra parameters specific to the exchange API endpoint
2663
2665
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2664
2666
  """
2665
- params['quoteOrderQty'] = cost
2666
- return self.create_order(symbol, 'market', 'buy', cost, None, params)
2667
+ req = {
2668
+ 'quoteOrderQty': cost,
2669
+ }
2670
+ return self.create_order(symbol, 'market', 'buy', cost, None, self.extend(req, params))
2667
2671
 
2668
2672
  def create_market_sell_order_with_cost(self, symbol: str, cost: float, params={}):
2669
2673
  """
@@ -2673,8 +2677,10 @@ class bingx(Exchange, ImplicitAPI):
2673
2677
  :param dict [params]: extra parameters specific to the exchange API endpoint
2674
2678
  :returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
2675
2679
  """
2676
- params['quoteOrderQty'] = cost
2677
- return self.create_order(symbol, 'market', 'sell', cost, None, params)
2680
+ req = {
2681
+ 'quoteOrderQty': cost,
2682
+ }
2683
+ return self.create_order(symbol, 'market', 'sell', cost, None, self.extend(req, params))
2678
2684
 
2679
2685
  def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
2680
2686
  """
ccxt/bitfinex.py CHANGED
@@ -469,7 +469,7 @@ class bitfinex(Exchange, ImplicitAPI):
469
469
  'fetchClosedOrders': {
470
470
  'marginMode': False,
471
471
  'limit': None,
472
- 'daysBackClosed': None,
472
+ 'daysBack': None,
473
473
  'daysBackCanceled': None,
474
474
  'untilDays': 100000,
475
475
  'trigger': False,
ccxt/bitget.py CHANGED
@@ -1444,16 +1444,102 @@ class bitget(Exchange, ImplicitAPI):
1444
1444
  },
1445
1445
  'sandboxMode': False,
1446
1446
  'networks': {
1447
+ # 'TRX': 'TRX', # different code for mainnet
1447
1448
  'TRC20': 'TRC20',
1449
+ # 'ETH': 'ETH', # different code for mainnet
1448
1450
  'ERC20': 'ERC20',
1449
1451
  'BEP20': 'BSC',
1450
- 'ARB': 'ArbitrumOne',
1451
- 'ZKSYNC': 'zkSyncEra',
1452
- 'STARKNET': 'Starknet',
1452
+ # 'BEP20': 'BEP20', # different for BEP20
1453
+ 'BSC': 'BEP20',
1454
+ 'ATOM': 'ATOM',
1455
+ 'ACA': 'AcalaToken',
1453
1456
  'APT': 'Aptos',
1457
+ 'ARBONE': 'ArbitrumOne',
1458
+ 'ARBNOVA': 'ArbitrumNova',
1459
+ 'AVAXC': 'C-Chain',
1460
+ 'AVAXX': 'X-Chain',
1461
+ 'AR': 'Arweave',
1462
+ 'BCH': 'BCH',
1463
+ 'BCHA': 'BCHA',
1464
+ 'BITCI': 'BITCI',
1465
+ 'BTC': 'BTC',
1466
+ 'CELO': 'CELO',
1467
+ 'CSPR': 'CSPR',
1468
+ 'ADA': 'Cardano',
1469
+ 'CHZ': 'ChilizChain',
1470
+ 'CRC20': 'CronosChain',
1471
+ 'DOGE': 'DOGE',
1472
+ 'DOT': 'DOT',
1473
+ 'EOS': 'EOS',
1474
+ 'ETHF': 'ETHFAIR',
1475
+ 'ETHW': 'ETHW',
1476
+ 'ETC': 'ETC',
1477
+ 'EGLD': 'Elrond',
1478
+ 'FIL': 'FIL',
1479
+ 'FIO': 'FIO',
1480
+ 'FTM': 'Fantom',
1481
+ 'HRC20': 'HECO',
1482
+ 'ONE': 'Harmony',
1483
+ 'HNT': 'Helium',
1484
+ 'ICP': 'ICP',
1485
+ 'IOTX': 'IoTeX',
1486
+ 'KARDIA': 'KAI',
1487
+ 'KAVA': 'KAVA',
1488
+ 'KDA': 'KDA',
1489
+ 'KLAY': 'Klaytn',
1490
+ 'KSM': 'Kusama',
1491
+ 'LAT': 'LAT',
1492
+ 'LTC': 'LTC',
1493
+ 'MINA': 'MINA',
1494
+ 'MOVR': 'MOVR',
1495
+ 'METIS': 'MetisToken',
1496
+ 'GLMR': 'Moonbeam',
1497
+ 'NEAR': 'NEARProtocol',
1498
+ 'NULS': 'NULS',
1499
+ 'OASYS': 'OASYS',
1500
+ 'OASIS': 'ROSE',
1501
+ 'OMNI': 'OMNI',
1502
+ 'ONT': 'Ontology',
1503
+ 'OPTIMISM': 'Optimism',
1504
+ 'OSMO': 'Osmosis',
1505
+ 'POKT': 'PocketNetwork',
1454
1506
  'MATIC': 'Polygon',
1507
+ 'QTUM': 'QTUM',
1508
+ 'REEF': 'REEF',
1509
+ 'SOL': 'SOL',
1510
+ 'SYS': 'SYS', # SyscoinNEVM is different
1511
+ 'SXP': 'Solar',
1512
+ 'XYM': 'Symbol',
1513
+ 'TON': 'TON',
1514
+ 'TT': 'TT',
1515
+ 'TLOS': 'Telos',
1516
+ 'THETA': 'ThetaToken',
1517
+ 'VITE': 'VITE',
1518
+ 'WAVES': 'WAVES',
1519
+ 'WAX': 'WAXP',
1520
+ 'WEMIX': 'WEMIXMainnet',
1521
+ 'XDC': 'XDCNetworkXDC',
1522
+ 'XRP': 'XRP',
1523
+ 'FET': 'FETCH',
1524
+ 'NEM': 'NEM',
1525
+ 'REI': 'REINetwork',
1526
+ 'ZIL': 'ZIL',
1527
+ 'ABBC': 'ABBCCoin',
1528
+ 'RSK': 'RSK',
1529
+ 'AZERO': 'AZERO',
1530
+ 'TRC10': 'TRC10',
1531
+ 'JUNO': 'JUNO',
1532
+ # undetected: USDSP, more info at https://www.bitget.com/v1/spot/public/coinChainList
1533
+ # todo: uncomment below after unification
1534
+ # 'TERRACLASSIC': 'Terra', # tbd, that network id is also assigned to TERRANEW network
1535
+ # 'CUBENETWORK': 'CUBE',
1536
+ # 'CADUCEUS': 'CMP',
1537
+ # 'CONFLUX': 'CFX', # CFXeSpace is different
1538
+ # 'CERE': 'CERE',
1539
+ # 'CANTO': 'CANTO',
1540
+ 'ZKSYNC': 'zkSyncEra',
1541
+ 'STARKNET': 'Starknet',
1455
1542
  'VIC': 'VICTION',
1456
- 'AVAXC': 'C-Chain',
1457
1543
  },
1458
1544
  'networksById': {
1459
1545
  },
@@ -1482,7 +1568,7 @@ class bitget(Exchange, ImplicitAPI):
1482
1568
  'mark': False,
1483
1569
  'index': False,
1484
1570
  },
1485
- 'limitPrice': True,
1571
+ 'price': True,
1486
1572
  },
1487
1573
  'timeInForce': {
1488
1574
  'IOC': True,
@@ -1524,7 +1610,7 @@ class bitget(Exchange, ImplicitAPI):
1524
1610
  'fetchClosedOrders': {
1525
1611
  'marginMode': True,
1526
1612
  'limit': 100,
1527
- 'daysBackClosed': None,
1613
+ 'daysBack': None,
1528
1614
  'daysBackCanceled': None,
1529
1615
  'untilDays': 90,
1530
1616
  'trigger': True,
@@ -1552,7 +1638,7 @@ class bitget(Exchange, ImplicitAPI):
1552
1638
  'mark': True,
1553
1639
  'index': True,
1554
1640
  },
1555
- 'limitPrice': False,
1641
+ 'price': False,
1556
1642
  },
1557
1643
  'timeInForce': {
1558
1644
  'IOC': True,
@@ -2303,13 +2389,13 @@ class bitget(Exchange, ImplicitAPI):
2303
2389
  :returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
2304
2390
  """
2305
2391
  self.check_address(address)
2306
- chain = self.safe_string_2(params, 'chain', 'network')
2307
- params = self.omit(params, 'network')
2308
- if chain is None:
2309
- raise ArgumentsRequired(self.id + ' withdraw() requires a chain parameter or a network parameter')
2392
+ networkCode = None
2393
+ networkCode, params = self.handle_network_code_and_params(params)
2394
+ if networkCode is None:
2395
+ raise ArgumentsRequired(self.id + ' withdraw() requires a "network" parameter')
2310
2396
  self.load_markets()
2311
2397
  currency = self.currency(code)
2312
- networkId = self.network_code_to_id(chain)
2398
+ networkId = self.network_code_to_id(networkCode)
2313
2399
  request: dict = {
2314
2400
  'coin': currency['id'],
2315
2401
  'address': address,
@@ -2332,27 +2418,8 @@ class bitget(Exchange, ImplicitAPI):
2332
2418
  # }
2333
2419
  #
2334
2420
  data = self.safe_value(response, 'data', {})
2335
- result: dict = {
2336
- 'id': self.safe_string(data, 'orderId'),
2337
- 'info': response,
2338
- 'txid': None,
2339
- 'timestamp': None,
2340
- 'datetime': None,
2341
- 'network': None,
2342
- 'addressFrom': None,
2343
- 'address': None,
2344
- 'addressTo': None,
2345
- 'amount': None,
2346
- 'type': 'withdrawal',
2347
- 'currency': None,
2348
- 'status': None,
2349
- 'updated': None,
2350
- 'tagFrom': None,
2351
- 'tag': None,
2352
- 'tagTo': None,
2353
- 'comment': None,
2354
- 'fee': None,
2355
- }
2421
+ result = self.parse_transaction(data, currency)
2422
+ result['type'] = 'withdrawal'
2356
2423
  withdrawOptions = self.safe_value(self.options, 'withdraw', {})
2357
2424
  fillResponseFromRequest = self.safe_bool(withdrawOptions, 'fillResponseFromRequest', True)
2358
2425
  if fillResponseFromRequest:
@@ -2363,7 +2430,7 @@ class bitget(Exchange, ImplicitAPI):
2363
2430
  result['tag'] = tag
2364
2431
  result['address'] = address
2365
2432
  result['addressTo'] = address
2366
- result['network'] = chain
2433
+ result['network'] = networkCode
2367
2434
  return result
2368
2435
 
2369
2436
  def fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
@@ -2525,17 +2592,14 @@ class bitget(Exchange, ImplicitAPI):
2525
2592
  :returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
2526
2593
  """
2527
2594
  self.load_markets()
2528
- networkCode = self.safe_string_2(params, 'chain', 'network')
2529
- params = self.omit(params, 'network')
2530
- networkId = None
2531
- if networkCode is not None:
2532
- networkId = self.network_code_to_id(networkCode, code)
2595
+ networkCode = None
2596
+ networkCode, params = self.handle_network_code_and_params(params)
2533
2597
  currency = self.currency(code)
2534
2598
  request: dict = {
2535
2599
  'coin': currency['id'],
2536
2600
  }
2537
- if networkId is not None:
2538
- request['chain'] = networkId
2601
+ if networkCode is not None:
2602
+ request['chain'] = self.network_code_to_id(networkCode, code)
2539
2603
  response = self.privateSpotGetV2SpotWalletDepositAddress(self.extend(request, params))
2540
2604
  #
2541
2605
  # {