ccxt 4.2.29__py2.py3-none-any.whl → 4.2.31__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 (133) hide show
  1. ccxt/__init__.py +3 -3
  2. ccxt/abstract/bybit.py +2 -2
  3. ccxt/abstract/coinbase.py +10 -0
  4. ccxt/abstract/okx.py +12 -1
  5. ccxt/ascendex.py +5 -5
  6. ccxt/async_support/__init__.py +3 -3
  7. ccxt/async_support/ascendex.py +5 -5
  8. ccxt/async_support/base/exchange.py +3 -3
  9. ccxt/async_support/bigone.py +2 -2
  10. ccxt/async_support/binance.py +892 -218
  11. ccxt/async_support/bingx.py +1 -1
  12. ccxt/async_support/bitfinex.py +1 -1
  13. ccxt/async_support/bitfinex2.py +421 -86
  14. ccxt/async_support/bitforex.py +3 -0
  15. ccxt/async_support/bitget.py +8 -4
  16. ccxt/async_support/bitmart.py +3 -3
  17. ccxt/async_support/bitmex.py +4 -4
  18. ccxt/async_support/bitrue.py +1 -1
  19. ccxt/async_support/bitso.py +1 -1
  20. ccxt/async_support/bitteam.py +2 -2
  21. ccxt/async_support/btcalpha.py +1 -1
  22. ccxt/async_support/bybit.py +3 -3
  23. ccxt/async_support/coinbase.py +20 -5
  24. ccxt/async_support/coincheck.py +1 -1
  25. ccxt/async_support/coinex.py +2 -2
  26. ccxt/async_support/coinlist.py +1 -1
  27. ccxt/async_support/coinmate.py +1 -1
  28. ccxt/async_support/coinmetro.py +2 -2
  29. ccxt/async_support/coinsph.py +1 -1
  30. ccxt/async_support/cryptocom.py +3 -3
  31. ccxt/async_support/deribit.py +1 -0
  32. ccxt/async_support/digifinex.py +6 -4
  33. ccxt/async_support/exmo.py +2 -2
  34. ccxt/async_support/gate.py +5 -5
  35. ccxt/async_support/gemini.py +3 -3
  36. ccxt/async_support/hitbtc.py +13 -17
  37. ccxt/async_support/hollaex.py +2 -2
  38. ccxt/async_support/htx.py +6 -6
  39. ccxt/async_support/huobijp.py +1 -1
  40. ccxt/async_support/kraken.py +3 -1
  41. ccxt/async_support/krakenfutures.py +4 -1
  42. ccxt/async_support/kucoin.py +17 -17
  43. ccxt/async_support/kucoinfutures.py +3 -3
  44. ccxt/async_support/lbank.py +4 -3
  45. ccxt/async_support/mexc.py +7 -7
  46. ccxt/async_support/novadax.py +1 -1
  47. ccxt/async_support/okcoin.py +2 -2
  48. ccxt/async_support/okx.py +22 -8
  49. ccxt/async_support/p2b.py +1 -0
  50. ccxt/async_support/phemex.py +3 -3
  51. ccxt/async_support/poloniexfutures.py +6 -3
  52. ccxt/async_support/probit.py +1 -1
  53. ccxt/async_support/timex.py +2 -2
  54. ccxt/async_support/tokocrypto.py +3 -3
  55. ccxt/async_support/wavesexchange.py +2 -2
  56. ccxt/async_support/whitebit.py +3 -3
  57. ccxt/async_support/woo.py +3 -3
  58. ccxt/async_support/yobit.py +1 -1
  59. ccxt/async_support/zaif.py +1 -1
  60. ccxt/async_support/zonda.py +3 -3
  61. ccxt/base/errors.py +13 -12
  62. ccxt/base/exchange.py +36 -26
  63. ccxt/bigone.py +2 -2
  64. ccxt/binance.py +892 -218
  65. ccxt/bingx.py +1 -1
  66. ccxt/bitfinex.py +1 -1
  67. ccxt/bitfinex2.py +421 -86
  68. ccxt/bitforex.py +3 -0
  69. ccxt/bitget.py +8 -4
  70. ccxt/bitmart.py +3 -3
  71. ccxt/bitmex.py +4 -4
  72. ccxt/bitrue.py +1 -1
  73. ccxt/bitso.py +1 -1
  74. ccxt/bitteam.py +2 -2
  75. ccxt/btcalpha.py +1 -1
  76. ccxt/bybit.py +3 -3
  77. ccxt/coinbase.py +20 -5
  78. ccxt/coincheck.py +1 -1
  79. ccxt/coinex.py +2 -2
  80. ccxt/coinlist.py +1 -1
  81. ccxt/coinmate.py +1 -1
  82. ccxt/coinmetro.py +2 -2
  83. ccxt/coinsph.py +1 -1
  84. ccxt/cryptocom.py +3 -3
  85. ccxt/deribit.py +1 -0
  86. ccxt/digifinex.py +6 -4
  87. ccxt/exmo.py +2 -2
  88. ccxt/gate.py +5 -5
  89. ccxt/gemini.py +3 -3
  90. ccxt/hitbtc.py +13 -17
  91. ccxt/hollaex.py +2 -2
  92. ccxt/htx.py +6 -6
  93. ccxt/huobijp.py +1 -1
  94. ccxt/kraken.py +3 -1
  95. ccxt/krakenfutures.py +4 -1
  96. ccxt/kucoin.py +17 -17
  97. ccxt/kucoinfutures.py +3 -3
  98. ccxt/lbank.py +4 -3
  99. ccxt/mexc.py +7 -7
  100. ccxt/novadax.py +1 -1
  101. ccxt/okcoin.py +2 -2
  102. ccxt/okx.py +22 -8
  103. ccxt/p2b.py +1 -0
  104. ccxt/phemex.py +3 -3
  105. ccxt/poloniexfutures.py +6 -3
  106. ccxt/pro/__init__.py +3 -1
  107. ccxt/pro/alpaca.py +1 -1
  108. ccxt/pro/binance.py +4 -4
  109. ccxt/pro/bitget.py +1 -1
  110. ccxt/pro/bitmart.py +1 -1
  111. ccxt/pro/bitmex.py +43 -7
  112. ccxt/pro/bitvavo.py +1 -1
  113. ccxt/pro/bybit.py +2 -2
  114. ccxt/pro/cex.py +2 -2
  115. ccxt/pro/independentreserve.py +1 -1
  116. ccxt/pro/okx.py +1 -1
  117. ccxt/pro/onetrading.py +2 -2
  118. ccxt/pro/p2b.py +407 -0
  119. ccxt/pro/probit.py +5 -5
  120. ccxt/pro/whitebit.py +1 -1
  121. ccxt/probit.py +1 -1
  122. ccxt/timex.py +2 -2
  123. ccxt/tokocrypto.py +3 -3
  124. ccxt/wavesexchange.py +2 -2
  125. ccxt/whitebit.py +3 -3
  126. ccxt/woo.py +3 -3
  127. ccxt/yobit.py +1 -1
  128. ccxt/zaif.py +1 -1
  129. ccxt/zonda.py +3 -3
  130. {ccxt-4.2.29.dist-info → ccxt-4.2.31.dist-info}/METADATA +6 -7
  131. {ccxt-4.2.29.dist-info → ccxt-4.2.31.dist-info}/RECORD +133 -132
  132. {ccxt-4.2.29.dist-info → ccxt-4.2.31.dist-info}/WHEEL +0 -0
  133. {ccxt-4.2.29.dist-info → ccxt-4.2.31.dist-info}/top_level.txt +0 -0
ccxt/binance.py CHANGED
@@ -25,11 +25,12 @@ from ccxt.base.errors import OrderNotFillable
25
25
  from ccxt.base.errors import NotSupported
26
26
  from ccxt.base.errors import DDoSProtection
27
27
  from ccxt.base.errors import RateLimitExceeded
28
- from ccxt.base.errors import ExchangeNotAvailable
29
28
  from ccxt.base.errors import OnMaintenance
30
29
  from ccxt.base.errors import InvalidNonce
31
30
  from ccxt.base.errors import RequestTimeout
32
31
  from ccxt.base.errors import AuthenticationError
32
+ from ccxt.base.errors import OperationRejected
33
+ from ccxt.base.errors import OperationFailed
33
34
  from ccxt.base.decimal_to_precision import TRUNCATE
34
35
  from ccxt.base.decimal_to_precision import DECIMAL_PLACES
35
36
  from ccxt.base.precise import Precise
@@ -1453,234 +1454,885 @@ class binance(Exchange, ImplicitAPI):
1453
1454
  'BUSD': 'USD',
1454
1455
  },
1455
1456
  },
1456
- # https://binance-docs.github.io/apidocs/spot/en/#error-codes-2
1457
1457
  'exceptions': {
1458
+ 'spot': {
1459
+ # https://binance-docs.github.io/apidocs/spot/en/#error-codes
1460
+ 'exact': {
1461
+ '-1000': OperationFailed, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
1462
+ '-1001': OperationFailed, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
1463
+ '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
1464
+ '-1003': RateLimitExceeded, # {"code":-1003,"msg":"Too much request weight used, current limit is 1200 request weight per 1 MINUTE. Please use the websocket for live updates to avoid polling the API."}
1465
+ '-1004': OperationFailed, # {"code":-1004,"msg":"Server is busy, please wait and try again"}
1466
+ '-1006': OperationFailed, # {"code":-1006,"msg":"An unexpected response was received from the message bus. Execution status unknown."}
1467
+ '-1007': RequestTimeout, # {"code":-1007,"msg":"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}
1468
+ '-1008': OperationFailed, # undocumented, but mentioned: This is sent whenever the servers are overloaded with requests.
1469
+ '-1010': OperationFailed, # undocumented, but mentioned ERROR_MSG_RECEIVED
1470
+ '-1013': OperationFailed, # undocumented, but mentioned
1471
+ '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
1472
+ '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
1473
+ '-1016': BadRequest, # {"code":-1016,"msg":"'This service is no longer available.',"}
1474
+ '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
1475
+ '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
1476
+ '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
1477
+ '-1099': AuthenticationError, # {"code":-1099,"msg":"Not found, authenticated, or authorized"}
1478
+ '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
1479
+ '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
1480
+ '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
1481
+ '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
1482
+ '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
1483
+ '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
1484
+ '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
1485
+ '-1108': BadRequest, # undocumented, but mentioned: This error will occur if a value to a parameter being sent was too large, potentially causing overflow
1486
+ '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
1487
+ '-1112': OperationFailed, # {"code":-1112,"msg":"No orders on book for symbol."}
1488
+ '-1114': BadRequest, # {"code":-1114,"msg":"TimeInForce parameter sent when not required."}
1489
+ '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
1490
+ '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
1491
+ '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
1492
+ '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
1493
+ '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
1494
+ '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
1495
+ '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
1496
+ '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
1497
+ '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
1498
+ '-1128': BadRequest, # {"code":-1128,"msg":"Combination of optional parameters invalid."}
1499
+ '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
1500
+ '-1131': BadRequest, # {"code":-1131,"msg":"recvWindow must be less than 60000"}
1501
+ '-1134': BadRequest, # strategyType was less than 1000000.
1502
+ '-1135': BadRequest, # undocumented, but mentioned: This error code will occur if a parameter requiring a JSON object is invalid.
1503
+ '-1145': BadRequest, # cancelRestrictions has to be either ONLY_NEW or ONLY_PARTIALLY_FILLED.
1504
+ '-1151': BadSymbol, # Symbol is present multiple times in the list.
1505
+ '-2008': AuthenticationError, # undocumented, Invalid Api-Key ID
1506
+ '-2010': InvalidOrder, # NEW_ORDER_REJECTED
1507
+ '-2011': OrderNotFound, # {"code":-2011,"msg":"cancelOrder(1, 'BTC/USDT') -> 'UNKNOWN_ORDER'"}
1508
+ '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
1509
+ '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
1510
+ '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
1511
+ '-2016': OperationRejected, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
1512
+ '-2021': BadResponse, # This code is sent when either the cancellation of the order failed or the new order placement failed but not both.
1513
+ '-2022': BadResponse, # This code is sent when both the cancellation of the order failed and the new order placement failed.
1514
+ '-2026': InvalidOrder, # Order was canceled or expired with no executed qty over 90 days ago and has been archived.
1515
+ # 3xxx errors are available only for spot
1516
+ '-3000': OperationFailed, # {"code":-3000,"msg":"Internal server error."}
1517
+ '-3001': AuthenticationError, # {"code":-3001,"msg":"Please enable 2FA first."}
1518
+ '-3002': BadSymbol, # {"code":-3002,"msg":"We don't have self asset."}
1519
+ '-3003': BadRequest, # {"code":-3003,"msg":"Margin account does not exist."}
1520
+ '-3004': OperationRejected, # {"code":-3004,"msg":"Trade not allowed."}
1521
+ '-3005': BadRequest, # {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."}
1522
+ '-3006': BadRequest, # {"code":-3006,"msg":"Your borrow amount has exceed maximum borrow amount."}
1523
+ '-3007': OperationFailed, # {"code":-3007,"msg":"You have pending transaction, please try again later.."}
1524
+ '-3008': BadRequest, # {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."}
1525
+ '-3009': OperationRejected, # {"code":-3009,"msg":"This asset are not allowed to transfer into margin account currently."}
1526
+ '-3010': BadRequest, # {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."}
1527
+ '-3011': BadRequest, # {"code":-3011,"msg":"Your input date is invalid."}
1528
+ '-3012': OperationRejected, # {"code":-3012,"msg":"Borrow is banned for self asset."}
1529
+ '-3013': BadRequest, # {"code":-3013,"msg":"Borrow amount less than minimum borrow amount."}
1530
+ '-3014': AccountSuspended, # {"code":-3014,"msg":"Borrow is banned for self account."}
1531
+ '-3015': BadRequest, # {"code":-3015,"msg":"Repay amount exceeds borrow amount."}
1532
+ '-3016': BadRequest, # {"code":-3016,"msg":"Repay amount less than minimum repay amount."}
1533
+ '-3017': OperationRejected, # {"code":-3017,"msg":"This asset are not allowed to transfer into margin account currently."}
1534
+ '-3018': AccountSuspended, # {"code":-3018,"msg":"Transferring in has been banned for self account."}
1535
+ '-3019': AccountSuspended, # {"code":-3019,"msg":"Transferring out has been banned for self account."}
1536
+ '-3020': BadRequest, # {"code":-3020,"msg":"Transfer out amount exceeds max amount."}
1537
+ '-3021': BadRequest, # {"code":-3021,"msg":"Margin account are not allowed to trade self trading pair."}
1538
+ '-3022': AccountSuspended, # {"code":-3022,"msg":"You account's trading is banned."}
1539
+ '-3023': OperationRejected, # {"code":-3023,"msg":"You can't transfer out/place order under current margin level."}
1540
+ '-3024': OperationRejected, # {"code":-3024,"msg":"The unpaid debt is too small after self repayment."}
1541
+ '-3025': BadRequest, # {"code":-3025,"msg":"Your input date is invalid."}
1542
+ '-3026': BadRequest, # {"code":-3026,"msg":"Your input param is invalid."}
1543
+ '-3027': BadSymbol, # {"code":-3027,"msg":"Not a valid margin asset."}
1544
+ '-3028': BadSymbol, # {"code":-3028,"msg":"Not a valid margin pair."}
1545
+ '-3029': OperationFailed, # {"code":-3029,"msg":"Transfer failed."}
1546
+ '-3036': AccountSuspended, # {"code":-3036,"msg":"This account is not allowed to repay."}
1547
+ '-3037': OperationFailed, # {"code":-3037,"msg":"PNL is clearing. Wait a second."}
1548
+ '-3038': BadRequest, # {"code":-3038,"msg":"Listen key not found."}
1549
+ '-3041': InsufficientFunds, # {"code":-3041,"msg":"Balance is not enough"}
1550
+ '-3042': BadRequest, # {"code":-3042,"msg":"PriceIndex not available for self margin pair."}
1551
+ '-3043': PermissionDenied, # {"code":-3043,"msg":"Transferring in not allowed."}
1552
+ '-3044': OperationFailed, # {"code":-3044,"msg":"System busy."}
1553
+ '-3045': OperationFailed, # {"code":-3045,"msg":"The system doesn't have enough asset now."}
1554
+ '-3999': PermissionDenied, # {"code":-3999,"msg":"This function is only available for invited users."}
1555
+ '-4001': BadRequest, # {"code":-4001 ,"msg":"Invalid operation."}
1556
+ '-4002': BadRequest, # {"code":-4002 ,"msg":"Invalid get."}
1557
+ '-4003': BadRequest, # {"code":-4003 ,"msg":"Your input email is invalid."}
1558
+ '-4004': AuthenticationError, # {"code":-4004,"msg":"You don't login or auth."}
1559
+ '-4005': RateLimitExceeded, # {"code":-4005 ,"msg":"Too many new requests."}
1560
+ '-4006': BadRequest, # {"code":-4006 ,"msg":"Support main account only."}
1561
+ '-4007': PermissionDenied, # {"code":-4007 ,"msg":"Address validation is not passed."}
1562
+ '-4008': PermissionDenied, # {"code":-4008 ,"msg":"Address tag validation is not passed."}
1563
+ '-4009': ExchangeError, # undocumented
1564
+ '-4010': PermissionDenied, # {"code":-4010 ,"msg":"White list mail has been confirmed."} # [TODO] possible bug: it should probably be "has not been confirmed"
1565
+ '-4011': BadRequest, # {"code":-4011 ,"msg":"White list mail is invalid."}
1566
+ '-4012': PermissionDenied, # {"code":-4012 ,"msg":"White list is not opened."}
1567
+ '-4013': AuthenticationError, # {"code":-4013 ,"msg":"2FA is not opened."}
1568
+ '-4014': OperationFailed, # {"code":-4014 ,"msg":"Withdraw is not allowed within 2 min login."}
1569
+ '-4015': PermissionDenied, # {"code":-4015 ,"msg":"Withdraw is limited."}
1570
+ '-4016': PermissionDenied, # {"code":-4016 ,"msg":"Within 24 hours after password modification, withdrawal is prohibited."}
1571
+ '-4017': PermissionDenied, # {"code":-4017 ,"msg":"Within 24 hours after the release of 2FA, withdrawal is prohibited."}
1572
+ '-4018': BadSymbol, # {"code":-4018,"msg":"We don't have self asset."}
1573
+ '-4019': BadRequest, # {"code":-4019,"msg":"Current asset is not open for withdrawal."}
1574
+ '-4021': BadRequest, # {"code":-4021,"msg":"Asset withdrawal must be an %s multiple of %s."}
1575
+ '-4022': BadRequest, # {"code":-4022,"msg":"Not less than the minimum pick-up quantity %s."}
1576
+ '-4023': OperationFailed, # {"code":-4023,"msg":"Within 24 hours, the withdrawal exceeds the maximum amount."}
1577
+ '-4024': InsufficientFunds, # {"code":-4024,"msg":"You don't have self asset."}
1578
+ '-4025': InsufficientFunds, # {"code":-4025,"msg":"The number of hold asset is less than zero."}
1579
+ '-4026': InsufficientFunds, # {"code":-4026,"msg":"You have insufficient balance."}
1580
+ '-4027': OperationFailed, # {"code":-4027,"msg":"Failed to obtain tranId."}
1581
+ '-4028': BadRequest, # {"code":-4028,"msg":"The amount of withdrawal must be greater than the Commission."}
1582
+ '-4029': BadRequest, # {"code":-4029,"msg":"The withdrawal record does not exist."}
1583
+ '-4030': BadResponse, # {"code":-4030,"msg":"Confirmation of successful asset withdrawal. [TODO] possible bug in docs"}
1584
+ '-4031': OperationFailed, # {"code":-4031,"msg":"Cancellation failed."}
1585
+ '-4032': OperationFailed, # {"code":-4032,"msg":"Withdraw verification exception."}
1586
+ '-4033': BadRequest, # {"code":-4033,"msg":"Illegal address."}
1587
+ '-4034': OperationRejected, # {"code":-4034,"msg":"The address is suspected of fake."}
1588
+ '-4035': PermissionDenied, # {"code":-4035,"msg":"This address is not on the whitelist. Please join and try again."}
1589
+ '-4036': PermissionDenied, # {"code":-4036,"msg":"The new address needs to be withdrawn in {0} hours."}
1590
+ '-4037': OperationFailed, # {"code":-4037,"msg":"Re-sending Mail failed."}
1591
+ '-4038': OperationFailed, # {"code":-4038,"msg":"Please try again in 5 minutes."}
1592
+ '-4039': PermissionDenied, # {"code":-4039,"msg":"The user does not exist."}
1593
+ '-4040': OperationRejected, # {"code":-4040,"msg":"This address not charged."}
1594
+ '-4041': OperationFailed, # {"code":-4041,"msg":"Please try again in one minute."}
1595
+ '-4042': OperationRejected, # {"code":-4042,"msg":"This asset cannot get deposit address again."}
1596
+ '-4043': OperationRejected, # {"code":-4043,"msg":"More than 100 recharge addresses were used in 24 hours."}
1597
+ '-4044': PermissionDenied, # {"code":-4044,"msg":"This is a blacklist country."}
1598
+ '-4045': OperationFailed, # {"code":-4045,"msg":"Failure to acquire assets."}
1599
+ '-4046': AuthenticationError, # {"code":-4046,"msg":"Agreement not confirmed."}
1600
+ '-4047': BadRequest, # {"code":-4047,"msg":"Time interval must be within 0-90 days"}
1601
+ '-4060': OperationFailed, # As your deposit has not reached the required block confirmations, we have temporarily locked {0} asset
1602
+ '-5001': BadRequest, # Don't allow transfer to micro assets.
1603
+ '-5002': InsufficientFunds, # You have insufficient balance.
1604
+ '-5003': InsufficientFunds, # You don't have self asset.
1605
+ '-5004': OperationRejected, # The residual balances of %s have exceeded 0.001BTC, Please re-choose.
1606
+ '-5005': OperationRejected, # The residual balances of %s is too low, Please re-choose.
1607
+ '-5006': OperationFailed, # Only transfer once in 24 hours.
1608
+ '-5007': BadRequest, # Quantity must be greater than zero.
1609
+ '-5008': OperationRejected, # Insufficient amount of returnable assets.
1610
+ '-5009': BadSymbol, # Product does not exist.
1611
+ '-5010': OperationFailed, # Asset transfer fail.
1612
+ '-5011': BadRequest, # future account not exists.
1613
+ '-5012': OperationFailed, # Asset transfer is in pending.
1614
+ '-5013': InsufficientFunds, # {"code":-5013,"msg":"Asset transfer failed: insufficient balance""} # undocumented
1615
+ '-5021': BadRequest, # This parent sub have no relation
1616
+ '-5022': BadRequest, # future account or sub relation not exists.
1617
+ '-6001': BadSymbol, # Daily product not exists.
1618
+ '-6003': PermissionDenied, # Product not exist or you don't have permission
1619
+ '-6004': BadRequest, # Product not in purchase status
1620
+ '-6005': BadRequest, # Smaller than min purchase limit
1621
+ '-6006': BadRequest, # Redeem amount error
1622
+ '-6007': OperationFailed, # Not in redeem time
1623
+ '-6008': OperationFailed, # Product not in redeem status
1624
+ '-6009': RateLimitExceeded, # Request frequency too high
1625
+ '-6011': OperationRejected, # Exceeding the maximum num allowed to purchase per user
1626
+ '-6012': InsufficientFunds, # Balance not enough
1627
+ '-6013': BadResponse, # Purchasing failed
1628
+ '-6014': OperationRejected, # Exceed up-limit allowed to purchased
1629
+ '-6015': BadRequest, # Empty request body
1630
+ '-6016': BadRequest, # Parameter err
1631
+ '-6017': PermissionDenied, # Not in whitelist
1632
+ '-6018': InsufficientFunds, # Asset not enough
1633
+ '-6019': OperationRejected, # Need confirm
1634
+ '-6020': BadRequest, # Project not exists
1635
+ '-7001': BadRequest, # Date range is not supported.
1636
+ '-7002': BadRequest, # Data request type is not supported.
1637
+ '-10001': OperationFailed, # The system is under maintenance, please try again later.
1638
+ '-10002': BadRequest, # Invalid input parameters.
1639
+ '-10005': BadResponse, # No records found.
1640
+ '-10007': BadRequest, # This coin is not loanable
1641
+ '-10008': BadRequest, # This coin is not loanable
1642
+ '-10009': BadRequest, # This coin can not be used.
1643
+ '-10010': BadRequest, # This coin can not be used.
1644
+ '-10011': InsufficientFunds, # Insufficient spot assets.
1645
+ '-10012': BadRequest, # Invalid repayment amount.
1646
+ '-10013': InsufficientFunds, # Insufficient collateral amount.
1647
+ '-10015': OperationFailed, # Collateral deduction failed.
1648
+ '-10016': OperationFailed, # Failed to provide loan.
1649
+ '-10017': OperationRejected, # {"code":-10017,"msg":"Repay amount should not be larger than liability."}
1650
+ '-10018': BadRequest, # Invalid repayment amount.
1651
+ '-10019': BadRequest, # Configuration does not exists.
1652
+ '-10020': BadRequest, # User ID does not exist.
1653
+ '-10021': InvalidOrder, # Order does not exist.
1654
+ '-10022': BadRequest, # Invalid adjustment amount.
1655
+ '-10023': OperationFailed, # Failed to adjust LTV.
1656
+ '-10024': BadRequest, # LTV adjustment not supported.
1657
+ '-10025': OperationFailed, # Repayment failed.
1658
+ '-10026': BadRequest, # Invalid parameter.
1659
+ '-10028': BadRequest, # Invalid parameter.
1660
+ '-10029': OperationRejected, # Loan amount is too small.
1661
+ '-10030': OperationRejected, # Loan amount is too much.
1662
+ '-10031': OperationRejected, # Individual loan quota reached.
1663
+ '-10032': OperationFailed, # Repayment is temporarily unavailable.
1664
+ '-10034': OperationRejected, # Repay with collateral is not available currently, please try to repay with borrowed coin.
1665
+ '-10039': OperationRejected, # Repayment amount is too small.
1666
+ '-10040': OperationRejected, # Repayment amount is too large.
1667
+ '-10041': OperationFailed, # Due to high demand, there are currently insufficient loanable assets for {0}. Please adjust your borrow amount or try again tomorrow.
1668
+ '-10042': BadSymbol, # asset %s is not supported
1669
+ '-10043': OperationRejected, # {0} borrowing is currently not supported.
1670
+ '-10044': OperationRejected, # Collateral amount has reached the limit. Please reduce your collateral amount or try with other collaterals.
1671
+ '-10045': OperationRejected, # The loan coin does not support collateral repayment. Please try again later.
1672
+ '-10046': OperationRejected, # Collateral Adjustment exceeds the maximum limit. Please try again.
1673
+ '-10047': PermissionDenied, # This coin is currently not supported in your location due to local regulations.
1674
+ '-11008': OperationRejected, # undocumented: Exceeding the account’s maximum borrowable limit
1675
+ '-12014': RateLimitExceeded, # More than 1 request in 2 seconds
1676
+ # BLVT
1677
+ '-13000': OperationRejected, # Redeption of the token is forbiden now
1678
+ '-13001': OperationRejected, # Exceeds individual 24h redemption limit of the token
1679
+ '-13002': OperationRejected, # Exceeds total 24h redemption limit of the token
1680
+ '-13003': PermissionDenied, # Subscription of the token is forbiden now
1681
+ '-13004': OperationRejected, # Exceeds individual 24h subscription limit of the token
1682
+ '-13005': OperationRejected, # Exceeds total 24h subscription limit of the token
1683
+ '-13006': OperationRejected, # Subscription amount is too small
1684
+ '-13007': PermissionDenied, # The Agreement is not signed
1685
+ # 18xxx - BINANCE CODE
1686
+ '-18002': OperationRejected, # The total amount of codes you created has exceeded the 24-hour limit, please try again after UTC 0
1687
+ '-18003': OperationRejected, # Too many codes created in 24 hours, please try again after UTC 0
1688
+ '-18004': OperationRejected, # Too many invalid redeem attempts in 24 hours, please try again after UTC 0
1689
+ '-18005': PermissionDenied, # Too many invalid verify attempts, please try later
1690
+ '-18006': OperationRejected, # The amount is too small, please re-enter
1691
+ '-18007': OperationRejected, # This token is not currently supported, please re-enter
1692
+ # spot & futures algo(TBD for OPTIONS & PORTFOLIO MARGIN)
1693
+ '-20121': BadSymbol, # Invalid symbol.
1694
+ '-20124': BadRequest, # Invalid algo id or it has been completed.
1695
+ '-20130': BadRequest, # Invalid data sent for a parameter
1696
+ '-20132': BadRequest, # The client algo id is duplicated
1697
+ '-20194': BadRequest, # Duration is too short to execute all required quantity.
1698
+ '-20195': BadRequest, # The total size is too small.
1699
+ '-20196': BadRequest, # The total size is too large.
1700
+ '-20198': OperationRejected, # Reach the max open orders allowed.
1701
+ '-20204': BadRequest, # The notional of USD is less or more than the limit.
1702
+ # 21xxx - PORTFOLIO MARGIN
1703
+ '-21001': BadRequest, # Request ID is not a Portfolio Margin Account.
1704
+ '-21002': BadRequest, # Portfolio Margin Account doesn't support transfer from margin to futures.
1705
+ '-21003': BadResponse, # Fail to retrieve margin assets.
1706
+ '-21004': OperationRejected, # User doesn’t have portfolio margin bankruptcy loan
1707
+ '-21005': InsufficientFunds, # User’s spot wallet doesn’t have enough BUSD to repay portfolio margin bankruptcy loan
1708
+ '-21006': OperationFailed, # User had portfolio margin bankruptcy loan repayment in process
1709
+ '-21007': OperationFailed, # User failed to repay portfolio margin bankruptcy loan since liquidation was in process
1710
+ '-32603': BadRequest, # undocumented, Filter failure: LOT_SIZE & precision
1711
+ '400002': BadRequest, # undocumented, {“status”: “FAIL”, “code”: “400002”, “errorMessage”: “Signature for self request is not valid.”}
1712
+ '100001003': AuthenticationError, # undocumented, {"code":100001003,"msg":"Verification failed"}
1713
+ '200003903': AuthenticationError, # undocumented, {"code":200003903,"msg":"Your identity verification has been rejected. Please complete identity verification again."}
1714
+ },
1715
+ },
1716
+ 'linear': {
1717
+ # https://binance-docs.github.io/apidocs/futures/en/#error-codes
1718
+ 'exact': {
1719
+ '-1000': OperationFailed, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
1720
+ '-1001': OperationFailed, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
1721
+ '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
1722
+ '-1003': RateLimitExceeded, # {"code":-1003,"msg":"Too much request weight used, current limit is 1200 request weight per 1 MINUTE. Please use the websocket for live updates to avoid polling the API."}
1723
+ '-1004': OperationRejected, # DUPLICATE_IP : This IP is already on the white list
1724
+ '-1005': PermissionDenied, # {"code":-1005,"msg":"No such IP has been white listed"}
1725
+ '-1006': OperationFailed, # {"code":-1006,"msg":"An unexpected response was received from the message bus. Execution status unknown."}
1726
+ '-1007': RequestTimeout, # {"code":-1007,"msg":"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}
1727
+ '-1008': OperationFailed, # -1008 SERVER_BUSY: Server is currently overloaded with other requests. Please try again in a few minutes.
1728
+ '-1010': OperationFailed, # {"code":-1010,"msg":"ERROR_MSG_RECEIVED."}
1729
+ '-1011': PermissionDenied, # {"code":-1011,"msg":"This IP cannot access self route."}
1730
+ '-1013': BadRequest, # {"code":-1013,"msg":"createOrder -> 'invalid quantity'/'invalid price'/MIN_NOTIONAL"} | -1013 INVALID_MESSAGE
1731
+ '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
1732
+ '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
1733
+ '-1016': BadRequest, # {"code":-1016,"msg":"'This service is no longer available.',"}
1734
+ '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
1735
+ '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
1736
+ '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
1737
+ '-1023': BadRequest, # {"code":-1023,"msg":"Start time is greater than end time."}
1738
+ '-1099': AuthenticationError, # {"code":-1099,"msg":"Not found, authenticated, or authorized"}
1739
+ '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
1740
+ '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
1741
+ '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
1742
+ '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
1743
+ '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
1744
+ '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
1745
+ '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
1746
+ '-1108': BadSymbol, # {"code":-1108,"msg":"Invalid asset."}
1747
+ '-1109': PermissionDenied, # {"code":-1109,"msg":"Invalid account."}
1748
+ '-1110': BadRequest, # {"code":-1110,"msg":"Invalid symbolType."}
1749
+ '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
1750
+ '-1112': OperationFailed, # {"code":-1112,"msg":"No orders on book for symbol."}
1751
+ '-1113': BadRequest, # {"code":-1113,"msg":"Withdrawal amount must be negative."}
1752
+ '-1114': BadRequest, # {"code":-1114,"msg":"TimeInForce parameter sent when not required."}
1753
+ '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
1754
+ '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
1755
+ '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
1756
+ '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
1757
+ '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
1758
+ '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
1759
+ '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
1760
+ '-1122': BadRequest, # INVALID_SYMBOL_STATUS
1761
+ '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
1762
+ '-1126': BadSymbol, # ASSET_NOT_SUPPORTED
1763
+ '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
1764
+ '-1128': BadRequest, # {"code":-1128,"msg":"Combination of optional parameters invalid."}
1765
+ '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
1766
+ '-1136': BadRequest, # {"code":-1136,"msg":"Invalid newOrderRespType"}
1767
+ '-2010': OrderNotFound, # NEW_ORDER_REJECTED
1768
+ '-2011': OrderNotFound, # {"code":-2011,"msg":"cancelOrder(1, 'BTC/USDT') -> 'UNKNOWN_ORDER'"}
1769
+ '-2012': OperationFailed, # CANCEL_ALL_FAIL
1770
+ '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
1771
+ '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
1772
+ '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
1773
+ '-2016': OperationRejected, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
1774
+ '-2017': PermissionDenied, # API Keys are locked on self account.
1775
+ '-2018': InsufficientFunds, # {"code":-2018,"msg":"Balance is insufficient"}
1776
+ '-2019': InsufficientFunds, # {"code":-2019,"msg":"Margin is insufficient."}
1777
+ '-2020': OperationFailed, # {"code":-2020,"msg":"Unable to fill."}
1778
+ '-2021': OrderImmediatelyFillable, # {"code":-2021,"msg":"Order would immediately trigger."}
1779
+ '-2022': InvalidOrder, # {"code":-2022,"msg":"ReduceOnly Order is rejected."}
1780
+ '-2023': OperationFailed, # {"code":-2023,"msg":"User in liquidation mode now."}
1781
+ '-2024': InsufficientFunds, # {"code":-2024,"msg":"Position is not sufficient."}
1782
+ '-2025': OperationRejected, # {"code":-2025,"msg":"Reach max open order limit."}
1783
+ '-2026': InvalidOrder, # {"code":-2026,"msg":"This OrderType is not supported when reduceOnly."}
1784
+ '-2027': OperationRejected, # {"code":-2027,"msg":"Exceeded the maximum allowable position at current leverage."}
1785
+ '-2028': OperationRejected, # {"code":-2028,"msg":"Leverage is smaller than permitted: insufficient margin balance"}
1786
+ '-4000': InvalidOrder, # INVALID_ORDER_STATUS
1787
+ '-4001': BadRequest, # PRICE_LESS_THAN_ZERO
1788
+ '-4002': BadRequest, # PRICE_GREATER_THAN_MAX_PRICE
1789
+ '-4003': BadRequest, # QTY_LESS_THAN_ZERO
1790
+ '-4004': BadRequest, # QTY_LESS_THAN_MIN_QTY
1791
+ '-4005': BadRequest, # QTY_GREATER_THAN_MAX_QTY
1792
+ '-4006': BadRequest, # STOP_PRICE_LESS_THAN_ZERO
1793
+ '-4007': BadRequest, # STOP_PRICE_GREATER_THAN_MAX_PRICE
1794
+ '-4008': BadRequest, # TICK SIZE LESS THAN ZERO
1795
+ '-4009': BadRequest, # MAX_PRICE_LESS_THAN_MIN_PRICE
1796
+ '-4010': BadRequest, # MAX_QTY_LESS_THAN_MIN_QTY
1797
+ '-4011': BadRequest, # STEP_SIZE_LESS_THAN_ZERO
1798
+ '-4012': BadRequest, # MAX_NUM_ORDERS_LESS_THAN_ZERO
1799
+ '-4013': BadRequest, # PRICE_LESS_THAN_MIN_PRICE
1800
+ '-4014': BadRequest, # PRICE NOT INCREASED BY TICK SIZE
1801
+ '-4015': BadRequest, # Client order id is not valid
1802
+ '-4016': OperationRejected, # Price is higher than mark price multiplier cap.
1803
+ '-4017': BadRequest, # MULTIPLIER_UP_LESS_THAN_ZERO
1804
+ '-4018': BadRequest, # MULTIPLIER_DOWN_LESS_THAN_ZERO
1805
+ '-4019': OperationRejected, # COMPOSITE_SCALE_OVERFLOW
1806
+ '-4020': BadRequest, # TARGET_STRATEGY_INVALID
1807
+ '-4021': BadRequest, # INVALID_DEPTH_LIMIT
1808
+ '-4022': BadRequest, # WRONG_MARKET_STATUS
1809
+ '-4023': BadRequest, # QTY_NOT_INCREASED_BY_STEP_SIZE
1810
+ '-4024': BadRequest, # PRICE_LOWER_THAN_MULTIPLIER_DOWN
1811
+ '-4025': BadRequest, # MULTIPLIER_DECIMAL_LESS_THAN_ZERO
1812
+ '-4026': BadRequest, # COMMISSION_INVALID
1813
+ '-4027': BadRequest, # INVALID_ACCOUNT_TYPE
1814
+ '-4028': BadRequest, # INVALID_LEVERAGE
1815
+ '-4029': BadRequest, # INVALID TICK SIZE PRECISION
1816
+ '-4030': BadRequest, # INVALID_STEP_SIZE_PRECISION
1817
+ '-4031': BadRequest, # INVALID_WORKING_TYPE
1818
+ '-4032': OperationRejected, # EXCEED_MAX_CANCEL_ORDER_SIZE
1819
+ '-4033': BadRequest, # INSURANCE_ACCOUNT_NOT_FOUND
1820
+ '-4044': BadRequest, # INVALID_BALANCE_TYPE
1821
+ '-4045': OperationRejected, # MAX_STOP_ORDER_EXCEEDED
1822
+ '-4046': OperationRejected, # NO_NEED_TO_CHANGE_MARGIN_TYPE
1823
+ '-4047': OperationRejected, # Margin type cannot be changed if there exists open orders.
1824
+ '-4048': OperationRejected, # Margin type cannot be changed if there exists position.
1825
+ '-4049': BadRequest, # Add margin only support for isolated position.
1826
+ '-4050': InsufficientFunds, # Cross balance insufficient
1827
+ '-4051': InsufficientFunds, # Isolated balance insufficient.
1828
+ '-4052': OperationRejected, # No need to change auto add margin.
1829
+ '-4053': BadRequest, # Auto add margin only support for isolated position.
1830
+ '-4054': OperationRejected, # Cannot add position margin: position is 0.
1831
+ '-4055': BadRequest, # Amount must be positive.
1832
+ '-4056': AuthenticationError, # Invalid api key type.
1833
+ '-4057': AuthenticationError, # Invalid api public key
1834
+ '-4058': BadRequest, # MAX_PRICE_TOO_LARGE
1835
+ '-4059': OperationRejected, # NO_NEED_TO_CHANGE_POSITION_SIDE
1836
+ '-4060': BadRequest, # INVALID_POSITION_SIDE
1837
+ '-4061': BadRequest, # POSITION_SIDE_NOT_MATCH
1838
+ '-4062': BadRequest, # REDUCE_ONLY_CONFLICT
1839
+ '-4063': BadRequest, # INVALID_OPTIONS_REQUEST_TYPE
1840
+ '-4064': BadRequest, # INVALID_OPTIONS_TIME_FRAME
1841
+ '-4065': BadRequest, # INVALID_OPTIONS_AMOUNT
1842
+ '-4066': BadRequest, # INVALID_OPTIONS_EVENT_TYPE
1843
+ '-4067': OperationRejected, # Position side cannot be changed if there exists open orders.
1844
+ '-4068': OperationRejected, # Position side cannot be changed if there exists position.
1845
+ '-4069': BadRequest, # Position INVALID_OPTIONS_PREMIUM_FEE
1846
+ '-4070': BadRequest, # Client options id is not valid.
1847
+ '-4071': BadRequest, # Invalid options direction
1848
+ '-4072': OperationRejected, # premium fee is not updated, reject order
1849
+ '-4073': BadRequest, # OPTIONS_PREMIUM_INPUT_LESS_THAN_ZERO
1850
+ '-4074': OperationRejected, # Order amount is bigger than upper boundary or less than 0, reject order
1851
+ '-4075': BadRequest, # output premium fee is less than 0, reject order
1852
+ '-4076': OperationRejected, # original fee is too much higher than last fee
1853
+ '-4077': OperationRejected, # place order amount has reached to limit, reject order
1854
+ '-4078': OperationFailed, # options internal error
1855
+ '-4079': BadRequest, # invalid options id
1856
+ '-4080': PermissionDenied, # user not found with id: %s
1857
+ '-4081': BadRequest, # OPTIONS_NOT_FOUND
1858
+ '-4082': OperationRejected, # Invalid number of batch place orders
1859
+ '-4083': OperationFailed, # Fail to place batch orders.
1860
+ '-4084': BadRequest, # UPCOMING_METHOD
1861
+ '-4085': BadRequest, # Invalid notional limit coefficient
1862
+ '-4086': BadRequest, # Invalid price spread threshold
1863
+ '-4087': PermissionDenied, # User can only place reduce only order
1864
+ '-4088': PermissionDenied, # User can not place order currently
1865
+ '-4104': BadRequest, # INVALID_CONTRACT_TYPE
1866
+ '-4114': BadRequest, # INVALID_CLIENT_TRAN_ID_LEN
1867
+ '-4115': BadRequest, # DUPLICATED_CLIENT_TRAN_ID
1868
+ '-4118': OperationRejected, # REDUCE_ONLY_MARGIN_CHECK_FAILED
1869
+ '-4131': OperationRejected, # The counterparty's best price does not meet the PERCENT_PRICE filter limit
1870
+ '-4135': BadRequest, # Invalid activation price
1871
+ '-4137': BadRequest, # Quantity must be zero with closePosition equals True
1872
+ '-4138': BadRequest, # Reduce only must be True with closePosition equals True
1873
+ '-4139': BadRequest, # Order type can not be market if it's unable to cancel
1874
+ '-4140': BadRequest, # Invalid symbol status for opening position
1875
+ '-4141': OperationRejected, # Symbol is closed
1876
+ '-4142': OrderImmediatelyFillable, # REJECT: take profit or stop order will be triggered immediately
1877
+ '-4144': BadSymbol, # Invalid pair
1878
+ '-4164': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions
1879
+ '-4165': BadRequest, # Invalid time interval
1880
+ '-4167': BadRequest, # Unable to adjust to Multi-Assets mode with symbols of USDⓈ-M Futures under isolated-margin mode.
1881
+ '-4168': BadRequest, # Unable to adjust to isolated-margin mode under the Multi-Assets mode.
1882
+ '-4169': OperationRejected, # Unable to adjust Multi-Assets Mode with insufficient margin balance in USDⓈ-M Futures
1883
+ '-4170': OperationRejected, # Unable to adjust Multi-Assets Mode with open orders in USDⓈ-M Futures
1884
+ '-4171': OperationRejected, # Adjusted asset mode is currently set and does not need to be adjusted repeatedly
1885
+ '-4172 ': OperationRejected, # Unable to adjust Multi-Assets Mode with a negative wallet balance of margin available asset in USDⓈ-M Futures account.
1886
+ '-4183': BadRequest, # Price is higher than stop price multiplier cap.
1887
+ '-4184': BadRequest, # Price is lower than stop price multiplier floor.
1888
+ '-4192': PermissionDenied, # Trade forbidden due to Cooling-off Period.
1889
+ '-4202': PermissionDenied, # Intermediate Personal Verification is required for adjusting leverage over 20x
1890
+ '-4203': PermissionDenied, # More than 20x leverage is available one month after account registration.
1891
+ '-4205': PermissionDenied, # More than 20x leverage is available %s days after Futures account registration.
1892
+ '-4206': PermissionDenied, # hasattr(self, Users) country has limited adjust leverage.
1893
+ '-4208': OperationRejected, # Current symbol leverage cannot exceed 20 when using position limit adjustment service.
1894
+ '-4209': OperationRejected, # Leverage adjustment failed. Current symbol max leverage limit is %sx
1895
+ '-4210': BadRequest, # Stop price is higher than price multiplier cap
1896
+ '-4211': BadRequest, # Stop price is lower than price multiplier floor
1897
+ '-4400': PermissionDenied, # Futures Trading Quantitative Rules violated, only reduceOnly order is allowed, please try again later.
1898
+ '-4401': PermissionDenied, # Compliance restricted account permission: can only place reduceOnly order.
1899
+ '-4402': PermissionDenied, # Dear user, our Terms of Use and compliance with local regulations, self feature is currently not available in your region.
1900
+ '-4403': PermissionDenied, # Dear user, our Terms of Use and compliance with local regulations, the leverage can only up to %sx in your region
1901
+ '-5021': OrderNotFillable, # Due to the order could not be filled immediately, the FOK order has been rejected.
1902
+ '-5022': OrderNotFillable, # Due to the order could not be executed, the Post Only order will be rejected.
1903
+ '-5024': OperationRejected, # Symbol is not in trading status. Order amendment is not permitted.
1904
+ '-5025': OperationRejected, # Only limit order is supported.
1905
+ '-5026': OperationRejected, # Exceed maximum modify order limit.
1906
+ '-5027': OperationRejected, # No need to modify the order.
1907
+ '-5028': BadRequest, # Timestamp for self request is outside of the ME recvWindow.
1908
+ '-5037': BadRequest, # Invalid price match
1909
+ '-5038': BadRequest, # Price match only supports order type: LIMIT, STOP AND TAKE_PROFIT
1910
+ '-5039': BadRequest, # Invalid self trade prevention mode
1911
+ '-5040': BadRequest, # The goodTillDate timestamp must be greater than the current time plus 600 seconds and smaller than 253402300799000
1912
+ '-5041': OperationFailed, # No depth matches self BBO order
1913
+ #
1914
+ # spot & futures algo(TBD for OPTIONS & PORTFOLIO MARGIN)
1915
+ #
1916
+ '-20121': BadSymbol, # Invalid symbol.
1917
+ '-20124': BadRequest, # Invalid algo id or it has been completed.
1918
+ '-20130': BadRequest, # Invalid data sent for a parameter
1919
+ '-20132': BadRequest, # The client algo id is duplicated
1920
+ '-20194': BadRequest, # Duration is too short to execute all required quantity.
1921
+ '-20195': BadRequest, # The total size is too small.
1922
+ '-20196': BadRequest, # The total size is too large.
1923
+ '-20198': OperationRejected, # Reach the max open orders allowed.
1924
+ '-20204': BadRequest, # The notional of USD is less or more than the limit.
1925
+ },
1926
+ },
1927
+ 'inverse': {
1928
+ # https://binance-docs.github.io/apidocs/delivery/en/#error-codes
1929
+ 'exact': {
1930
+ '-1000': OperationFailed, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
1931
+ '-1001': OperationFailed, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
1932
+ '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
1933
+ '-1003': RateLimitExceeded, # {"code":-1003,"msg":"Too much request weight used, current limit is 1200 request weight per 1 MINUTE. Please use the websocket for live updates to avoid polling the API."}
1934
+ '-1004': OperationRejected, # DUPLICATE_IP : This IP is already on the white list
1935
+ '-1005': PermissionDenied, # {"code":-1005,"msg":"No such IP has been white listed"}
1936
+ '-1006': OperationFailed, # {"code":-1006,"msg":"An unexpected response was received from the message bus. Execution status unknown."}
1937
+ '-1007': RequestTimeout, # {"code":-1007,"msg":"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}
1938
+ '-1010': OperationFailed, # {"code":-1010,"msg":"ERROR_MSG_RECEIVED."}
1939
+ '-1011': PermissionDenied, # {"code":-1011,"msg":"This IP cannot access self route."}
1940
+ '-1013': BadRequest, # {"code":-1013,"msg":"createOrder -> 'invalid quantity'/'invalid price'/MIN_NOTIONAL"} | -1013 INVALID_MESSAGE
1941
+ '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
1942
+ '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
1943
+ '-1016': BadRequest, # {"code":-1016,"msg":"'This service is no longer available.',"}
1944
+ '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
1945
+ '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
1946
+ '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
1947
+ '-1023': BadRequest, # {"code":-1023,"msg":"Start time is greater than end time."}
1948
+ '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
1949
+ '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
1950
+ '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
1951
+ '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
1952
+ '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
1953
+ '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
1954
+ '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
1955
+ '-1108': BadSymbol, # {"code":-1108,"msg":"Invalid asset."}
1956
+ '-1109': AuthenticationError, # {"code":-1109,"msg":"Invalid account."}
1957
+ '-1110': BadSymbol, # {"code":-1110,"msg":"Invalid symbolType."}
1958
+ '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
1959
+ '-1112': OperationFailed, # {"code":-1112,"msg":"No orders on book for symbol."}
1960
+ '-1113': BadRequest, # {"code":-1113,"msg":"Withdrawal amount must be negative."}
1961
+ '-1114': BadRequest, # {"code":-1114,"msg":"TimeInForce parameter sent when not required."}
1962
+ '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
1963
+ '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
1964
+ '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
1965
+ '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
1966
+ '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
1967
+ '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
1968
+ '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
1969
+ '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
1970
+ '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
1971
+ '-1128': BadRequest, # {"code":-1128,"msg":"Combination of optional parameters invalid."}
1972
+ '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
1973
+ '-1136': BadRequest, # {"code":-1136,"msg":"Invalid newOrderRespType"}
1974
+ '-2010': InvalidOrder, # NEW_ORDER_REJECTED
1975
+ '-2011': OrderNotFound, # {"code":-2011,"msg":"cancelOrder(1, 'BTC/USDT') -> 'UNKNOWN_ORDER'"}
1976
+ '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
1977
+ '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
1978
+ '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
1979
+ '-2016': OperationRejected, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
1980
+ '-2018': InsufficientFunds, # {"code":-2018,"msg":"Balance is insufficient"}
1981
+ '-2019': InsufficientFunds, # {"code":-2019,"msg":"Margin is insufficient."}
1982
+ '-2020': OperationFailed, # {"code":-2020,"msg":"Unable to fill."}
1983
+ '-2021': OrderImmediatelyFillable, # {"code":-2021,"msg":"Order would immediately trigger."}
1984
+ '-2022': InvalidOrder, # {"code":-2022,"msg":"ReduceOnly Order is rejected."}
1985
+ '-2023': OperationFailed, # {"code":-2023,"msg":"User in liquidation mode now."}
1986
+ '-2024': BadRequest, # {"code":-2024,"msg":"Position is not sufficient."}
1987
+ '-2025': OperationRejected, # {"code":-2025,"msg":"Reach max open order limit."}
1988
+ '-2026': InvalidOrder, # {"code":-2026,"msg":"This OrderType is not supported when reduceOnly."}
1989
+ '-2027': OperationRejected, # {"code":-2027,"msg":"Exceeded the maximum allowable position at current leverage."}
1990
+ '-2028': OperationRejected, # {"code":-2028,"msg":"Leverage is smaller than permitted: insufficient margin balance"}
1991
+ '-4000': InvalidOrder, # INVALID_ORDER_STATUS
1992
+ '-4001': BadRequest, # PRICE_LESS_THAN_ZERO
1993
+ '-4002': BadRequest, # PRICE_GREATER_THAN_MAX_PRICE
1994
+ '-4003': BadRequest, # QTY_LESS_THAN_ZERO
1995
+ '-4004': BadRequest, # QTY_LESS_THAN_MIN_QTY
1996
+ '-4005': BadRequest, # QTY_GREATER_THAN_MAX_QTY
1997
+ '-4006': BadRequest, # STOP_PRICE_LESS_THAN_ZERO
1998
+ '-4007': BadRequest, # STOP_PRICE_GREATER_THAN_MAX_PRICE
1999
+ '-4008': BadRequest, # TICK SIZE LESS THAN ZERO
2000
+ '-4009': BadRequest, # MAX_PRICE_LESS_THAN_MIN_PRICE
2001
+ '-4010': BadRequest, # MAX_QTY_LESS_THAN_MIN_QTY
2002
+ '-4011': BadRequest, # STEP_SIZE_LESS_THAN_ZERO
2003
+ '-4012': BadRequest, # MAX_NUM_ORDERS_LESS_THAN_ZERO
2004
+ '-4013': BadRequest, # PRICE_LESS_THAN_MIN_PRICE
2005
+ '-4014': BadRequest, # PRICE NOT INCREASED BY TICK SIZE
2006
+ '-4015': BadRequest, # Client order id is not valid
2007
+ '-4016': BadRequest, # Price is higher than mark price multiplier cap.
2008
+ '-4017': BadRequest, # MULTIPLIER_UP_LESS_THAN_ZERO
2009
+ '-4018': BadRequest, # MULTIPLIER_DOWN_LESS_THAN_ZERO
2010
+ '-4019': OperationRejected, # COMPOSITE_SCALE_OVERFLOW
2011
+ '-4020': BadRequest, # TARGET_STRATEGY_INVALID
2012
+ '-4021': BadRequest, # INVALID_DEPTH_LIMIT
2013
+ '-4022': BadRequest, # WRONG_MARKET_STATUS
2014
+ '-4023': BadRequest, # QTY_NOT_INCREASED_BY_STEP_SIZE
2015
+ '-4024': BadRequest, # PRICE_LOWER_THAN_MULTIPLIER_DOWN
2016
+ '-4025': BadRequest, # MULTIPLIER_DECIMAL_LESS_THAN_ZERO
2017
+ '-4026': BadRequest, # COMMISSION_INVALID
2018
+ '-4027': BadRequest, # INVALID_ACCOUNT_TYPE
2019
+ '-4028': BadRequest, # INVALID_LEVERAGE
2020
+ '-4029': BadRequest, # INVALID TICK SIZE PRECISION
2021
+ '-4030': BadRequest, # INVALID_STEP_SIZE_PRECISION
2022
+ '-4031': BadRequest, # INVALID_WORKING_TYPE
2023
+ '-4032': OperationRejected, # Exceed maximum cancel order size. | Invalid parameter working type: %s
2024
+ '-4033': BadRequest, # INSURANCE_ACCOUNT_NOT_FOUND
2025
+ '-4044': BadRequest, # INVALID_BALANCE_TYPE
2026
+ '-4045': OperationRejected, # Reach max stop order limit.
2027
+ '-4046': BadRequest, # NO_NEED_TO_CHANGE_MARGIN_TYPE
2028
+ '-4047': OperationRejected, # Margin type cannot be changed if there exists open orders.
2029
+ '-4048': OperationRejected, # Margin type cannot be changed if there exists position.
2030
+ '-4049': OperationRejected, # ADD_ISOLATED_MARGIN_REJECT
2031
+ '-4050': InsufficientFunds, # CROSS_BALANCE_INSUFFICIENT
2032
+ '-4051': InsufficientFunds, # ISOLATED_BALANCE_INSUFFICIENT
2033
+ '-4052': OperationRejected, # NO_NEED_TO_CHANGE_AUTO_ADD_MARGIN
2034
+ '-4053': OperationRejected, # AUTO_ADD_CROSSED_MARGIN_REJECT
2035
+ '-4054': OperationRejected, # Cannot add position margin: position is 0.
2036
+ '-4055': BadRequest, # AMOUNT_MUST_BE_POSITIVE
2037
+ '-4056': AuthenticationError, # INVALID_API_KEY_TYPE
2038
+ '-4057': AuthenticationError, # INVALID_RSA_PUBLIC_KEY
2039
+ '-4058': BadRequest, # MAX_PRICE_TOO_LARGE
2040
+ '-4059': OperationRejected, # NO_NEED_TO_CHANGE_POSITION_SIDE
2041
+ '-4060': BadRequest, # INVALID_POSITION_SIDE
2042
+ '-4061': OperationRejected, # Order's position side does not match user's setting.
2043
+ '-4062': BadRequest, # Invalid or improper reduceOnly value.
2044
+ #
2045
+ '-4067': OperationRejected, # Position side cannot be changed if there exists open orders.
2046
+ '-4068': OperationRejected, # Position side cannot be changed if there exists position.
2047
+ '-4082': OperationRejected, # Invalid number of batch place orders.
2048
+ '-4083': OperationRejected, # PLACE_BATCH_ORDERS_FAIL
2049
+ '-4084': BadRequest, # Method is not allowed currently. Upcoming soon.
2050
+ '-4086': BadRequest, # Invalid price spread threshold.
2051
+ '-4087': BadSymbol, # Invalid pair
2052
+ '-4088': BadRequest, # Invalid time interval
2053
+ '-4089': PermissionDenied, # User can only place reduce only order.
2054
+ '-4090': PermissionDenied, # User can not place order currently.
2055
+ '-4104': BadRequest, # Invalid contract type
2056
+ '-4110': BadRequest, # clientTranId is not valid
2057
+ '-4111': BadRequest, # clientTranId is duplicated.
2058
+ '-4112': OperationRejected, # ReduceOnly Order Failed. Please check your existing position and open orders.
2059
+ '-4113': OperationRejected, # The counterparty's best price does not meet the PERCENT_PRICE filter limit.
2060
+ '-4135': BadRequest, # Invalid activation price.
2061
+ '-4137': BadRequest, # Quantity must be zero with closePosition equals True.
2062
+ '-4138': BadRequest, # Reduce only must be True with closePosition equals True.
2063
+ '-4139': BadRequest, # Order type can not be market if it's unable to cancel.
2064
+ '-4142': OrderImmediatelyFillable, # REJECT: take profit or stop order will be triggered immediately.
2065
+ '-4150': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions.
2066
+ '-4151': BadRequest, # Price is higher than stop price multiplier cap.
2067
+ '-4152': BadRequest, # Price is lower than stop price multiplier floor.
2068
+ '-4154': BadRequest, # Stop price is higher than price multiplier cap.
2069
+ '-4155': BadRequest, # Stop price is lower than price multiplier floor
2070
+ '-4178': BadRequest, # Order's notional must be no smaller than one(unless you choose reduce only)
2071
+ '-4192': PermissionDenied, # Trade forbidden due to Cooling-off Period.
2072
+ '-4194': PermissionDenied, # Intermediate Personal Verification is required for adjusting leverage over 20x.
2073
+ '-4195': PermissionDenied, # More than 20x leverage is available one month after account registration.
2074
+ '-4196': BadRequest, # Only limit order is supported.
2075
+ '-4197': OperationRejected, # No need to modify the order.
2076
+ '-4198': OperationRejected, # Exceed maximum modify order limit.
2077
+ '-4199': BadRequest, # Symbol is not in trading status. Order amendment is not permitted.
2078
+ '-4200': PermissionDenied, # More than 20x leverage is available %s days after Futures account registration.
2079
+ '-4201': PermissionDenied, # Users in your location/country can only access a maximum leverage of %s
2080
+ '-4202': OperationRejected, # Current symbol leverage cannot exceed 20 when using position limit adjustment service.
2081
+ '-4188': BadRequest, # Timestamp for self request is outside of the ME recvWindow.
2082
+ #
2083
+ # spot & futures algo
2084
+ #
2085
+ '-20121': BadSymbol, # Invalid symbol.
2086
+ '-20124': BadRequest, # Invalid algo id or it has been completed.
2087
+ '-20130': BadRequest, # Invalid data sent for a parameter
2088
+ '-20132': BadRequest, # The client algo id is duplicated
2089
+ '-20194': BadRequest, # Duration is too short to execute all required quantity.
2090
+ '-20195': BadRequest, # The total size is too small.
2091
+ '-20196': BadRequest, # The total size is too large.
2092
+ '-20198': OperationRejected, # Reach the max open orders allowed.
2093
+ '-20204': BadRequest, # The notional of USD is less or more than the limit.
2094
+ },
2095
+ },
2096
+ 'option': {
2097
+ # https://binance-docs.github.io/apidocs/voptions/en/#error-codes
2098
+ 'exact': {
2099
+ '-1000': OperationFailed, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
2100
+ '-1001': OperationFailed, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
2101
+ '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
2102
+ '-1008': RateLimitExceeded, # TOO_MANY_REQUESTS
2103
+ '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
2104
+ '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
2105
+ '-1016': BadRequest, # {"code":-1016,"msg":"'This service is no longer available.',"}
2106
+ '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
2107
+ '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
2108
+ '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
2109
+ '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
2110
+ '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
2111
+ '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
2112
+ '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
2113
+ '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
2114
+ '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
2115
+ '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
2116
+ '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
2117
+ '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
2118
+ '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
2119
+ '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
2120
+ '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
2121
+ '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
2122
+ '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
2123
+ '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
2124
+ '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
2125
+ '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
2126
+ '-1128': BadSymbol, # BAD_CONTRACT
2127
+ '-1129': BadSymbol, # BAD_CURRENCY
2128
+ '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
2129
+ '-1131': BadRequest, # {"code":-1131,"msg":"recvWindow must be less than 60000"}
2130
+ '-2010': InvalidOrder, # NEW_ORDER_REJECTED
2131
+ '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
2132
+ '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
2133
+ '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
2134
+ '-2018': InsufficientFunds, # BALANCE_NOT_SUFFICIENT
2135
+ '-2027': InsufficientFunds, # OPTION_MARGIN_NOT_SUFFICIENT
2136
+ '-3029': OperationFailed, # {"code":-3029,"msg":"Transfer failed."}
2137
+ '-4001': BadRequest, # PRICE_LESS_THAN_ZERO
2138
+ '-4002': BadRequest, # PRICE_GREATER_THAN_MAX_PRICE
2139
+ '-4003': BadRequest, # QTY_LESS_THAN_ZERO
2140
+ '-4004': BadRequest, # QTY_LESS_THAN_MIN_QTY
2141
+ '-4005': BadRequest, # QTY_GREATER_THAN_MAX_QTY
2142
+ '-4013': BadRequest, # PRICE_LESS_THAN_MIN_PRICE
2143
+ '-4029': BadRequest, # INVALID TICK SIZE PRECISION
2144
+ '-4030': BadRequest, # INVALID_QTY_PRECISION
2145
+ '-4055': BadRequest, # AMOUNT_MUST_BE_POSITIVE
2146
+ },
2147
+ },
2148
+ 'portfolioMargin': {
2149
+ 'exact': {
2150
+ '-1000': OperationFailed, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
2151
+ '-1001': OperationFailed, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
2152
+ '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
2153
+ '-1003': RateLimitExceeded, # {"code":-1003,"msg":"Too much request weight used, current limit is 1200 request weight per 1 MINUTE. Please use the websocket for live updates to avoid polling the API."}
2154
+ '-1004': OperationRejected, # DUPLICATE_IP : This IP is already on the white list
2155
+ '-1005': PermissionDenied, # {"code":-1005,"msg":"No such IP has been white listed"}
2156
+ '-1006': OperationFailed, # {"code":-1006,"msg":"An unexpected response was received from the message bus. Execution status unknown."}
2157
+ '-1007': RequestTimeout, # {"code":-1007,"msg":"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}
2158
+ '-1010': OperationFailed, # {"code":-1010,"msg":"ERROR_MSG_RECEIVED."}
2159
+ '-1011': PermissionDenied, # {"code":-1011,"msg":"This IP cannot access self route."}
2160
+ '-1013': OperationFailed, #
2161
+ '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
2162
+ '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
2163
+ '-1016': BadRequest, # {"code":-1016,"msg":"'This service is no longer available.',"}
2164
+ '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
2165
+ '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
2166
+ '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
2167
+ '-1023': BadRequest, # START_TIME_GREATER_THAN_END_TIME
2168
+ '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
2169
+ '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
2170
+ '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
2171
+ '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
2172
+ '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
2173
+ '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
2174
+ '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
2175
+ '-1108': BadSymbol, # BAD_ASSET
2176
+ '-1109': BadRequest, # BAD_ACCOUNT
2177
+ '-1110': BadSymbol, # BAD_INSTRUMENT_TYPE
2178
+ '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
2179
+ '-1112': OperationFailed, # {"code":-1112,"msg":"No orders on book for symbol."}
2180
+ '-1113': BadRequest, # {"code":-1113,"msg":"Withdrawal amount must be negative."}
2181
+ '-1114': BadRequest, # {"code":-1114,"msg":"TimeInForce parameter sent when not required."}
2182
+ '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
2183
+ '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
2184
+ '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
2185
+ '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
2186
+ '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
2187
+ '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
2188
+ '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
2189
+ '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
2190
+ '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
2191
+ '-1128': BadRequest, # {"code":-1128,"msg":"Combination of optional parameters invalid."}
2192
+ '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
2193
+ '-1136': BadRequest, # INVALID_NEW_ORDER_RESP_TYPE
2194
+ '-2010': InvalidOrder, # NEW_ORDER_REJECTED
2195
+ '-2011': OrderNotFound, # {"code":-2011,"msg":"cancelOrder(1, 'BTC/USDT') -> 'UNKNOWN_ORDER'"}
2196
+ '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
2197
+ '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
2198
+ '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
2199
+ '-2016': OperationRejected, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
2200
+ '-2018': InsufficientFunds, # {"code":-2018,"msg":"Balance is insufficient"}
2201
+ '-2019': InsufficientFunds, # Margin is insufficient
2202
+ '-2020': OrderNotFillable, # UNABLE_TO_FILL
2203
+ '-2021': OrderImmediatelyFillable, # Order would immediately trigger.
2204
+ '-2022': InvalidOrder, # ReduceOnly Order is rejected
2205
+ '-2023': OperationFailed, # User in liquidation mode now
2206
+ '-2024': OperationRejected, # Position is not sufficient
2207
+ '-2025': OperationRejected, # Reach max open order limit.
2208
+ '-2026': InvalidOrder, # This OrderType is not supported when reduceOnly.
2209
+ '-2027': OperationRejected, # Exceeded the maximum allowable position at current leverage.
2210
+ '-2028': OperationRejected, # Leverage is smaller than permitted: insufficient margin balance.
2211
+ '-4000': InvalidOrder, # INVALID_ORDER_STATUS
2212
+ '-4001': BadRequest, # PRICE_LESS_THAN_ZERO
2213
+ '-4002': BadRequest, # PRICE_GREATER_THAN_MAX_PRICE
2214
+ '-4003': BadRequest, # QTY_LESS_THAN_ZERO
2215
+ '-4004': BadRequest, # QTY_LESS_THAN_MIN_QTY
2216
+ '-4005': BadRequest, # QTY_GREATER_THAN_MAX_QTY
2217
+ '-4006': BadRequest, # STOP_PRICE_LESS_THAN_ZERO
2218
+ '-4007': BadRequest, # STOP_PRICE_GREATER_THAN_MAX_PRICE
2219
+ '-4008': BadRequest, # TICK SIZE LESS THAN ZERO
2220
+ '-4009': BadRequest, # MAX_PRICE_LESS_THAN_MIN_PRICE
2221
+ '-4010': BadRequest, # MAX_QTY_LESS_THAN_MIN_QTY
2222
+ '-4011': BadRequest, # STEP_SIZE_LESS_THAN_ZERO
2223
+ '-4012': BadRequest, # MAX_NUM_ORDERS_LESS_THAN_ZERO
2224
+ '-4013': BadRequest, # PRICE_LESS_THAN_MIN_PRICE
2225
+ '-4014': BadRequest, # PRICE NOT INCREASED BY TICK SIZE
2226
+ '-4015': BadRequest, # Client order id is not valid
2227
+ '-4016': BadRequest, # Price is higher than mark price multiplier cap.
2228
+ '-4017': BadRequest, # MULTIPLIER_UP_LESS_THAN_ZERO
2229
+ '-4018': BadRequest, # MULTIPLIER_DOWN_LESS_THAN_ZERO
2230
+ '-4019': OperationRejected, # COMPOSITE_SCALE_OVERFLOW
2231
+ '-4020': BadRequest, # TARGET_STRATEGY_INVALID
2232
+ '-4021': BadRequest, # INVALID_DEPTH_LIMIT
2233
+ '-4022': BadRequest, # WRONG_MARKET_STATUS
2234
+ '-4023': BadRequest, # QTY_NOT_INCREASED_BY_STEP_SIZE
2235
+ '-4024': BadRequest, # PRICE_LOWER_THAN_MULTIPLIER_DOWN
2236
+ '-4025': BadRequest, # MULTIPLIER_DECIMAL_LESS_THAN_ZERO
2237
+ '-4026': BadRequest, # COMMISSION_INVALID
2238
+ '-4027': BadRequest, # INVALID_ACCOUNT_TYPE
2239
+ '-4028': BadRequest, # INVALID_LEVERAGE
2240
+ '-4029': BadRequest, # INVALID TICK SIZE PRECISION
2241
+ '-4030': BadRequest, # INVALID_STEP_SIZE_PRECISION
2242
+ '-4031': BadRequest, # INVALID_WORKING_TYPE
2243
+ '-4032': OperationRejected, # EXCEED_MAX_CANCEL_ORDER_SIZE
2244
+ '-4033': BadRequest, # INSURANCE_ACCOUNT_NOT_FOUND
2245
+ '-4044': BadRequest, # INVALID_BALANCE_TYPE
2246
+ '-4045': OperationRejected, # MAX_STOP_ORDER_EXCEEDED
2247
+ '-4046': OperationRejected, # NO_NEED_TO_CHANGE_MARGIN_TYPE
2248
+ '-4047': OperationRejected, # Margin type cannot be changed if there exists open orders.
2249
+ '-4048': OperationRejected, # Margin type cannot be changed if there exists position.
2250
+ '-4049': BadRequest, # Add margin only support for isolated position.
2251
+ '-4050': InsufficientFunds, # Cross balance insufficient
2252
+ '-4051': InsufficientFunds, # Isolated balance insufficient.
2253
+ '-4052': OperationRejected, # No need to change auto add margin.
2254
+ '-4053': BadRequest, # Auto add margin only support for isolated position.
2255
+ '-4054': OperationRejected, # Cannot add position margin: position is 0.
2256
+ '-4055': BadRequest, # Amount must be positive.
2257
+ '-4056': AuthenticationError, # Invalid api key type.
2258
+ '-4057': AuthenticationError, # Invalid api public key
2259
+ '-4058': BadRequest, # MAX_PRICE_TOO_LARGE
2260
+ '-4059': OperationRejected, # NO_NEED_TO_CHANGE_POSITION_SIDE
2261
+ '-4060': BadRequest, # INVALID_POSITION_SIDE
2262
+ '-4061': BadRequest, # POSITION_SIDE_NOT_MATCH
2263
+ '-4062': BadRequest, # REDUCE_ONLY_CONFLICT
2264
+ '-4063': BadRequest, # INVALID_OPTIONS_REQUEST_TYPE
2265
+ '-4064': BadRequest, # INVALID_OPTIONS_TIME_FRAME
2266
+ '-4065': BadRequest, # INVALID_OPTIONS_AMOUNT
2267
+ '-4066': BadRequest, # INVALID_OPTIONS_EVENT_TYPE
2268
+ '-4067': OperationRejected, # Position side cannot be changed if there exists open orders.
2269
+ '-4068': OperationRejected, # Position side cannot be changed if there exists position.
2270
+ '-4069': BadRequest, # Position INVALID_OPTIONS_PREMIUM_FEE
2271
+ '-4070': BadRequest, # Client options id is not valid.
2272
+ '-4071': BadRequest, # Invalid options direction
2273
+ '-4072': OperationRejected, # premium fee is not updated, reject order
2274
+ '-4073': BadRequest, # OPTIONS_PREMIUM_INPUT_LESS_THAN_ZERO
2275
+ '-4074': BadRequest, # Order amount is bigger than upper boundary or less than 0, reject order
2276
+ '-4075': BadRequest, # output premium fee is less than 0, reject order
2277
+ '-4076': OperationRejected, # original fee is too much higher than last fee
2278
+ '-4077': OperationRejected, # place order amount has reached to limit, reject order
2279
+ '-4078': OperationFailed, # options internal error
2280
+ '-4079': BadRequest, # invalid options id
2281
+ '-4080': PermissionDenied, # user not found with id: %s
2282
+ '-4081': BadRequest, # OPTIONS_NOT_FOUND
2283
+ '-4082': BadRequest, # Invalid number of batch place orders
2284
+ '-4083': OperationFailed, # Fail to place batch orders.
2285
+ '-4084': BadRequest, # UPCOMING_METHOD
2286
+ '-4085': BadRequest, # Invalid notional limit coefficient
2287
+ '-4086': BadRequest, # Invalid price spread threshold
2288
+ '-4087': PermissionDenied, # User can only place reduce only order
2289
+ '-4088': PermissionDenied, # User can not place order currently
2290
+ '-4104': BadRequest, # INVALID_CONTRACT_TYPE
2291
+ '-4114': BadRequest, # INVALID_CLIENT_TRAN_ID_LEN
2292
+ '-4115': BadRequest, # DUPLICATED_CLIENT_TRAN_ID
2293
+ '-4118': OperationRejected, # REDUCE_ONLY_MARGIN_CHECK_FAILED
2294
+ '-4131': OperationRejected, # The counterparty's best price does not meet the PERCENT_PRICE filter limit
2295
+ '-4135': BadRequest, # Invalid activation price
2296
+ '-4137': BadRequest, # Quantity must be zero with closePosition equals True
2297
+ '-4138': BadRequest, # Reduce only must be True with closePosition equals True
2298
+ '-4139': BadRequest, # Order type can not be market if it's unable to cancel
2299
+ '-4140': BadRequest, # Invalid symbol status for opening position
2300
+ '-4141': BadRequest, # Symbol is closed
2301
+ '-4142': OrderImmediatelyFillable, # REJECT: take profit or stop order will be triggered immediately
2302
+ '-4144': BadSymbol, # Invalid pair
2303
+ '-4161': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions
2304
+ '-4164': OperationRejected, # Leverage reduction is not supported in Isolated Margin Mode with open positions
2305
+ '-4165': BadRequest, # Invalid time interval
2306
+ '-4183': BadRequest, # Price is higher than stop price multiplier cap.
2307
+ '-4184': BadRequest, # Price is lower than stop price multiplier floor.
2308
+ '-5021': OrderNotFillable, # Due to the order could not be filled immediately, the FOK order has been rejected.
2309
+ '-5022': OrderNotFillable, # Due to the order could not be executed, the Post Only order will be rejected.
2310
+ },
2311
+ },
1458
2312
  'exact': {
1459
2313
  'System is under maintenance.': OnMaintenance, # {"code":1,"msg":"System is under maintenance."}
1460
- 'System abnormality': ExchangeError, # {"code":-1000,"msg":"System abnormality"}
2314
+ 'System abnormality': OperationFailed, # {"code":-1000,"msg":"System abnormality"}
1461
2315
  'You are not authorized to execute self request.': PermissionDenied, # {"msg":"You are not authorized to execute self request."}
1462
2316
  'API key does not exist': AuthenticationError,
1463
2317
  'Order would trigger immediately.': OrderImmediatelyFillable,
1464
2318
  'Stop price would trigger immediately.': OrderImmediatelyFillable, # {"code":-2010,"msg":"Stop price would trigger immediately."}
1465
2319
  'Order would immediately match and take.': OrderImmediatelyFillable, # {"code":-2010,"msg":"Order would immediately match and take."}
1466
2320
  'Account has insufficient balance for requested action.': InsufficientFunds,
1467
- 'Rest API trading is not enabled.': ExchangeNotAvailable,
1468
- 'This account may not place or cancel orders.': ExchangeNotAvailable,
2321
+ 'Rest API trading is not enabled.': PermissionDenied,
2322
+ 'This account may not place or cancel orders.': PermissionDenied,
1469
2323
  "You don't have permission.": PermissionDenied, # {"msg":"You don't have permission.","success":false}
1470
- 'Market is closed.': ExchangeNotAvailable, # {"code":-1013,"msg":"Market is closed."}
1471
- 'Too many requests. Please try again later.': DDoSProtection, # {"msg":"Too many requests. Please try again later.","success":false}
2324
+ 'Market is closed.': OperationRejected, # {"code":-1013,"msg":"Market is closed."}
2325
+ 'Too many requests. Please try again later.': RateLimitExceeded, # {"msg":"Too many requests. Please try again later.","success":false}
1472
2326
  'This action is disabled on self account.': AccountSuspended, # {"code":-2011,"msg":"This action is disabled on self account."}
1473
2327
  'Limit orders require GTC for self phase.': BadRequest,
1474
2328
  'This order type is not hasattr(self, possible) trading phase.': BadRequest,
1475
- 'This type of sub-account exceeds the maximum number limit': BadRequest, # {"code":-9000,"msg":"This type of sub-account exceeds the maximum number limit"}
2329
+ 'This type of sub-account exceeds the maximum number limit': OperationRejected, # {"code":-9000,"msg":"This type of sub-account exceeds the maximum number limit"}
1476
2330
  'This symbol is restricted for self account.': PermissionDenied,
1477
2331
  'This symbol is not permitted for self account.': PermissionDenied, # {"code":-2010,"msg":"This symbol is not permitted for self account."}
1478
- '-1000': ExchangeNotAvailable, # {"code":-1000,"msg":"An unknown error occured while processing the request."}
1479
- '-1001': ExchangeNotAvailable, # {"code":-1001,"msg":"'Internal error; unable to process your request. Please try again.'"}
1480
- '-1002': AuthenticationError, # {"code":-1002,"msg":"'You are not authorized to execute self request.'"}
1481
- '-1003': RateLimitExceeded, # {"code":-1003,"msg":"Too much request weight used, current limit is 1200 request weight per 1 MINUTE. Please use the websocket for live updates to avoid polling the API."}
1482
- '-1004': DDoSProtection, # {"code":-1004,"msg":"Server is busy, please wait and try again"}
1483
- '-1005': PermissionDenied, # {"code":-1005,"msg":"No such IP has been white listed"}
1484
- '-1006': BadResponse, # {"code":-1006,"msg":"An unexpected response was received from the message bus. Execution status unknown."}
1485
- '-1007': RequestTimeout, # {"code":-1007,"msg":"Timeout waiting for response from backend server. Send status unknown; execution status unknown."}
1486
- '-1010': BadResponse, # {"code":-1010,"msg":"ERROR_MSG_RECEIVED."}
1487
- '-1011': PermissionDenied, # {"code":-1011,"msg":"This IP cannot access self route."}
1488
- '-1013': InvalidOrder, # {"code":-1013,"msg":"createOrder -> 'invalid quantity'/'invalid price'/MIN_NOTIONAL"}
1489
- '-1014': InvalidOrder, # {"code":-1014,"msg":"Unsupported order combination."}
1490
- '-1015': RateLimitExceeded, # {"code":-1015,"msg":"'Too many new orders; current limit is %s orders per %s.'"}
1491
- '-1016': ExchangeNotAvailable, # {"code":-1016,"msg":"'This service is no longer available.',"}
1492
- '-1020': BadRequest, # {"code":-1020,"msg":"'This operation is not supported.'"}
1493
- '-1021': InvalidNonce, # {"code":-1021,"msg":"'your time is ahead of server'"}
1494
- '-1022': AuthenticationError, # {"code":-1022,"msg":"Signature for self request is not valid."}
1495
- '-1023': BadRequest, # {"code":-1023,"msg":"Start time is greater than end time."}
1496
- '-1099': AuthenticationError, # {"code":-1099,"msg":"Not found, authenticated, or authorized"}
1497
- '-1100': BadRequest, # {"code":-1100,"msg":"createOrder(symbol, 1, asdf) -> 'Illegal characters found in parameter 'price'"}
1498
- '-1101': BadRequest, # {"code":-1101,"msg":"Too many parameters; expected %s and received %s."}
1499
- '-1102': BadRequest, # {"code":-1102,"msg":"Param %s or %s must be sent, but both were empty"}
1500
- '-1103': BadRequest, # {"code":-1103,"msg":"An unknown parameter was sent."}
1501
- '-1104': BadRequest, # {"code":-1104,"msg":"Not all sent parameters were read, read 8 parameters but was sent 9"}
1502
- '-1105': BadRequest, # {"code":-1105,"msg":"Parameter %s was empty."}
1503
- '-1106': BadRequest, # {"code":-1106,"msg":"Parameter %s sent when not required."}
1504
- '-1108': BadRequest, # {"code":-1108,"msg":"Invalid asset."}
1505
- '-1109': AuthenticationError, # {"code":-1109,"msg":"Invalid account."}
1506
- '-1110': BadRequest, # {"code":-1110,"msg":"Invalid symbolType."}
1507
- '-1111': BadRequest, # {"code":-1111,"msg":"Precision is over the maximum defined for self asset."}
1508
- '-1112': InvalidOrder, # {"code":-1112,"msg":"No orders on book for symbol."}
1509
- '-1113': BadRequest, # {"code":-1113,"msg":"Withdrawal amount must be negative."}
1510
- '-1114': BadRequest, # {"code":-1114,"msg":"TimeInForce parameter sent when not required."}
1511
- '-1115': BadRequest, # {"code":-1115,"msg":"Invalid timeInForce."}
1512
- '-1116': BadRequest, # {"code":-1116,"msg":"Invalid orderType."}
1513
- '-1117': BadRequest, # {"code":-1117,"msg":"Invalid side."}
1514
- '-1118': BadRequest, # {"code":-1118,"msg":"New client order ID was empty."}
1515
- '-1119': BadRequest, # {"code":-1119,"msg":"Original client order ID was empty."}
1516
- '-1120': BadRequest, # {"code":-1120,"msg":"Invalid interval."}
1517
- '-1121': BadSymbol, # {"code":-1121,"msg":"Invalid symbol."}
1518
- '-1125': AuthenticationError, # {"code":-1125,"msg":"This listenKey does not exist."}
1519
- '-1127': BadRequest, # {"code":-1127,"msg":"More than %s hours between startTime and endTime."}
1520
- '-1128': BadRequest, # {"code":-1128,"msg":"{"code":-1128,"msg":"Combination of optional parameters invalid."}"}
1521
- '-1130': BadRequest, # {"code":-1130,"msg":"Data sent for paramter %s is not valid."}
1522
- '-1131': BadRequest, # {"code":-1131,"msg":"recvWindow must be less than 60000"}
1523
- '-1135': BadRequest, # This error code will occur if a parameter requiring a JSON object is invalid.
1524
- '-1136': BadRequest, # {"code":-1136,"msg":"Invalid newOrderRespType"}
1525
- '-2008': AuthenticationError, # {"code":-2008,"msg":"Invalid Api-Key ID."}
1526
- '-2010': ExchangeError, # {"code":-2010,"msg":"generic error code for createOrder -> 'Account has insufficient balance for requested action.', {"code":-2010,"msg":"Rest API trading is not enabled."}, etc..."}
1527
- '-2011': OrderNotFound, # {"code":-2011,"msg":"cancelOrder(1, 'BTC/USDT') -> 'UNKNOWN_ORDER'"}
1528
- '-2013': OrderNotFound, # {"code":-2013,"msg":"fetchOrder(1, 'BTC/USDT') -> 'Order does not exist'"}
1529
- '-2014': AuthenticationError, # {"code":-2014,"msg":"API-key format invalid."}
1530
- '-2015': AuthenticationError, # {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
1531
- '-2016': BadRequest, # {"code":-2016,"msg":"No trading window could be found for the symbol. Try ticker/24hrs instead."}
1532
- '-2018': InsufficientFunds, # {"code":-2018,"msg":"Balance is insufficient"}
1533
- '-2019': InsufficientFunds, # {"code":-2019,"msg":"Margin is insufficient."}
1534
- '-2020': OrderNotFillable, # {"code":-2020,"msg":"Unable to fill."}
1535
- '-2021': OrderImmediatelyFillable, # {"code":-2021,"msg":"Order would immediately trigger."}
1536
- '-2022': InvalidOrder, # {"code":-2022,"msg":"ReduceOnly Order is rejected."}
1537
- '-2023': InsufficientFunds, # {"code":-2023,"msg":"User in liquidation mode now."}
1538
- '-2024': InsufficientFunds, # {"code":-2024,"msg":"Position is not sufficient."}
1539
- '-2025': InvalidOrder, # {"code":-2025,"msg":"Reach max open order limit."}
1540
- '-2026': InvalidOrder, # {"code":-2026,"msg":"This OrderType is not supported when reduceOnly."}
1541
- '-2027': InvalidOrder, # {"code":-2027,"msg":"Exceeded the maximum allowable position at current leverage."}
1542
- '-2028': InsufficientFunds, # {"code":-2028,"msg":"Leverage is smaller than permitted: insufficient margin balance"}
1543
- '-3000': ExchangeError, # {"code":-3000,"msg":"Internal server error."}
1544
- '-3001': AuthenticationError, # {"code":-3001,"msg":"Please enable 2FA first."}
1545
- '-3002': BadSymbol, # {"code":-3002,"msg":"We don't have self asset."}
1546
- '-3003': BadRequest, # {"code":-3003,"msg":"Margin account does not exist."}
1547
- '-3004': ExchangeError, # {"code":-3004,"msg":"Trade not allowed."}
1548
- '-3005': InsufficientFunds, # {"code":-3005,"msg":"Transferring out not allowed. Transfer out amount exceeds max amount."}
1549
- '-3006': InsufficientFunds, # {"code":-3006,"msg":"Your borrow amount has exceed maximum borrow amount."}
1550
- '-3007': ExchangeError, # {"code":-3007,"msg":"You have pending transaction, please try again later.."}
1551
- '-3008': InsufficientFunds, # {"code":-3008,"msg":"Borrow not allowed. Your borrow amount has exceed maximum borrow amount."}
1552
- '-3009': BadRequest, # {"code":-3009,"msg":"This asset are not allowed to transfer into margin account currently."}
1553
- '-3010': BadRequest, # {"code":-3010,"msg":"Repay not allowed. Repay amount exceeds borrow amount."}
1554
- '-3011': BadRequest, # {"code":-3011,"msg":"Your input date is invalid."}
1555
- '-3012': InsufficientFunds, # {"code":-3012,"msg":"Borrow is banned for self asset."}
1556
- '-3013': BadRequest, # {"code":-3013,"msg":"Borrow amount less than minimum borrow amount."}
1557
- '-3014': AccountSuspended, # {"code":-3014,"msg":"Borrow is banned for self account."}
1558
- '-3015': BadRequest, # {"code":-3015,"msg":"Repay amount exceeds borrow amount."}
1559
- '-3016': BadRequest, # {"code":-3016,"msg":"Repay amount less than minimum repay amount."}
1560
- '-3017': ExchangeError, # {"code":-3017,"msg":"This asset are not allowed to transfer into margin account currently."}
1561
- '-3018': AccountSuspended, # {"code":-3018,"msg":"Transferring in has been banned for self account."}
1562
- '-3019': AccountSuspended, # {"code":-3019,"msg":"Transferring out has been banned for self account."}
1563
- '-3020': InsufficientFunds, # {"code":-3020,"msg":"Transfer out amount exceeds max amount."}
1564
- '-3021': BadRequest, # {"code":-3021,"msg":"Margin account are not allowed to trade self trading pair."}
1565
- '-3022': AccountSuspended, # {"code":-3022,"msg":"You account's trading is banned."}
1566
- '-3023': BadRequest, # {"code":-3023,"msg":"You can't transfer out/place order under current margin level."}
1567
- '-3024': ExchangeError, # {"code":-3024,"msg":"The unpaid debt is too small after self repayment."}
1568
- '-3025': BadRequest, # {"code":-3025,"msg":"Your input date is invalid."}
1569
- '-3026': BadRequest, # {"code":-3026,"msg":"Your input param is invalid."}
1570
- '-3027': BadSymbol, # {"code":-3027,"msg":"Not a valid margin asset."}
1571
- '-3028': BadSymbol, # {"code":-3028,"msg":"Not a valid margin pair."}
1572
- '-3029': ExchangeError, # {"code":-3029,"msg":"Transfer failed."}
1573
- '-3036': AccountSuspended, # {"code":-3036,"msg":"This account is not allowed to repay."}
1574
- '-3037': ExchangeError, # {"code":-3037,"msg":"PNL is clearing. Wait a second."}
1575
- '-3038': BadRequest, # {"code":-3038,"msg":"Listen key not found."}
1576
- '-3041': InsufficientFunds, # {"code":-3041,"msg":"Balance is not enough"}
1577
- '-3042': BadRequest, # {"code":-3042,"msg":"PriceIndex not available for self margin pair."}
1578
- '-3043': BadRequest, # {"code":-3043,"msg":"Transferring in not allowed."}
1579
- '-3044': DDoSProtection, # {"code":-3044,"msg":"System busy."}
1580
- '-3045': ExchangeError, # {"code":-3045,"msg":"The system doesn't have enough asset now."}
1581
- '-3999': ExchangeError, # {"code":-3999,"msg":"This function is only available for invited users."}
1582
- '-4001': BadRequest, # {"code":-4001 ,"msg":"Invalid operation."}
1583
- '-4002': BadRequest, # {"code":-4002 ,"msg":"Invalid get."}
1584
- '-4003': BadRequest, # {"code":-4003 ,"msg":"Your input email is invalid."}
1585
- '-4004': AuthenticationError, # {"code":-4004,"msg":"You don't login or auth."}
1586
- '-4005': RateLimitExceeded, # {"code":-4005 ,"msg":"Too many new requests."}
1587
- '-4006': BadRequest, # {"code":-4006 ,"msg":"Support main account only."}
1588
- '-4007': BadRequest, # {"code":-4007 ,"msg":"Address validation is not passed."}
1589
- '-4008': BadRequest, # {"code":-4008 ,"msg":"Address tag validation is not passed."}
1590
- '-4010': BadRequest, # {"code":-4010 ,"msg":"White list mail has been confirmed."} # [TODO] possible bug: it should probably be "has not been confirmed"
1591
- '-4011': BadRequest, # {"code":-4011 ,"msg":"White list mail is invalid."}
1592
- '-4012': BadRequest, # {"code":-4012 ,"msg":"White list is not opened."}
1593
- '-4013': AuthenticationError, # {"code":-4013 ,"msg":"2FA is not opened."}
1594
- '-4014': PermissionDenied, # {"code":-4014 ,"msg":"Withdraw is not allowed within 2 min login."}
1595
- '-4015': ExchangeError, # {"code":-4015 ,"msg":"Withdraw is limited."}
1596
- '-4016': PermissionDenied, # {"code":-4016 ,"msg":"Within 24 hours after password modification, withdrawal is prohibited."} | on swap: {"code":-4016,"msg":"Limit price can't be higher than 27330.52."}
1597
- '-4017': PermissionDenied, # {"code":-4017 ,"msg":"Within 24 hours after the release of 2FA, withdrawal is prohibited."}
1598
- '-4018': BadSymbol, # {"code":-4018,"msg":"We don't have self asset."}
1599
- '-4019': BadSymbol, # {"code":-4019,"msg":"Current asset is not open for withdrawal."}
1600
- '-4021': BadRequest, # {"code":-4021,"msg":"Asset withdrawal must be an %s multiple of %s."}
1601
- '-4022': BadRequest, # {"code":-4022,"msg":"Not less than the minimum pick-up quantity %s."}
1602
- '-4023': ExchangeError, # {"code":-4023,"msg":"Within 24 hours, the withdrawal exceeds the maximum amount."}
1603
- '-4024': InsufficientFunds, # {"code":-4024,"msg":"You don't have self asset."}
1604
- '-4025': InsufficientFunds, # {"code":-4025,"msg":"The number of hold asset is less than zero."}
1605
- '-4026': InsufficientFunds, # {"code":-4026,"msg":"You have insufficient balance."}
1606
- '-4027': ExchangeError, # {"code":-4027,"msg":"Failed to obtain tranId."}
1607
- '-4028': BadRequest, # {"code":-4028,"msg":"The amount of withdrawal must be greater than the Commission."}
1608
- '-4029': BadRequest, # {"code":-4029,"msg":"The withdrawal record does not exist."}
1609
- '-4030': ExchangeError, # {"code":-4030,"msg":"Confirmation of successful asset withdrawal. [TODO] possible bug in docs"}
1610
- '-4031': ExchangeError, # {"code":-4031,"msg":"Cancellation failed."}
1611
- '-4032': ExchangeError, # {"code":-4032,"msg":"Withdraw verification exception."}
1612
- '-4033': BadRequest, # {"code":-4033,"msg":"Illegal address."}
1613
- '-4034': ExchangeError, # {"code":-4034,"msg":"The address is suspected of fake."}
1614
- '-4035': PermissionDenied, # {"code":-4035,"msg":"This address is not on the whitelist. Please join and try again."}
1615
- '-4036': BadRequest, # {"code":-4036,"msg":"The new address needs to be withdrawn in {0} hours."}
1616
- '-4037': ExchangeError, # {"code":-4037,"msg":"Re-sending Mail failed."}
1617
- '-4038': ExchangeError, # {"code":-4038,"msg":"Please try again in 5 minutes."}
1618
- '-4039': BadRequest, # {"code":-4039,"msg":"The user does not exist."}
1619
- '-4040': BadRequest, # {"code":-4040,"msg":"This address not charged."}
1620
- '-4041': ExchangeError, # {"code":-4041,"msg":"Please try again in one minute."}
1621
- '-4042': ExchangeError, # {"code":-4042,"msg":"This asset cannot get deposit address again."}
1622
- '-4043': BadRequest, # {"code":-4043,"msg":"More than 100 recharge addresses were used in 24 hours."}
1623
- '-4044': BadRequest, # {"code":-4044,"msg":"This is a blacklist country."}
1624
- '-4045': ExchangeError, # {"code":-4045,"msg":"Failure to acquire assets."}
1625
- '-4046': AuthenticationError, # {"code":-4046,"msg":"Agreement not confirmed."}
1626
- '-4047': BadRequest, # {"code":-4047,"msg":"Time interval must be within 0-90 days"}
1627
- '-4054': BadRequest, # {"code":-4054,"msg":"Cannot add position margin: position is 0."}
1628
- '-4164': InvalidOrder, # {"code":-4164,"msg":"Order's notional must be no smaller than 5(unless you choose reduce only)."}
1629
- '-5001': BadRequest, # {"code":-5001,"msg":"Don't allow transfer to micro assets."}
1630
- '-5002': InsufficientFunds, # {"code":-5002,"msg":"You have insufficient balance."}
1631
- '-5003': InsufficientFunds, # {"code":-5003,"msg":"You don't have self asset."}
1632
- '-5004': BadRequest, # {"code":-5004,"msg":"The residual balances of %s have exceeded 0.001BTC, Please re-choose."}
1633
- '-5005': InsufficientFunds, # {"code":-5005,"msg":"The residual balances of %s is too low, Please re-choose."}
1634
- '-5006': BadRequest, # {"code":-5006,"msg":"Only transfer once in 24 hours."}
1635
- '-5007': BadRequest, # {"code":-5007,"msg":"Quantity must be greater than zero."}
1636
- '-5008': InsufficientFunds, # {"code":-5008,"msg":"Insufficient amount of returnable assets."}
1637
- '-5009': BadRequest, # {"code":-5009,"msg":"Product does not exist."}
1638
- '-5010': ExchangeError, # {"code":-5010,"msg":"Asset transfer fail."}
1639
- '-5011': BadRequest, # {"code":-5011,"msg":"future account not exists."}
1640
- '-5012': ExchangeError, # {"code":-5012,"msg":"Asset transfer is in pending."}
1641
- '-5013': InsufficientFunds, # {"code":-5013,"msg":"Asset transfer failed: insufficient balance""} # undocumented
1642
- '-5021': BadRequest, # {"code":-5021,"msg":"This parent sub have no relation"}
1643
- '-6001': BadRequest, # {"code":-6001,"msg":"Daily product not exists."}
1644
- '-6003': BadRequest, # {"code":-6003,"msg":"Product not exist or you don't have permission"}
1645
- '-6004': ExchangeError, # {"code":-6004,"msg":"Product not in purchase status"}
1646
- '-6005': InvalidOrder, # {"code":-6005,"msg":"Smaller than min purchase limit"}
1647
- '-6006': BadRequest, # {"code":-6006,"msg":"Redeem amount error"}
1648
- '-6007': BadRequest, # {"code":-6007,"msg":"Not in redeem time"}
1649
- '-6008': BadRequest, # {"code":-6008,"msg":"Product not in redeem status"}
1650
- '-6009': RateLimitExceeded, # {"code":-6009,"msg":"Request frequency too high"}
1651
- '-6011': BadRequest, # {"code":-6011,"msg":"Exceeding the maximum num allowed to purchase per user"}
1652
- '-6012': InsufficientFunds, # {"code":-6012,"msg":"Balance not enough"}
1653
- '-6013': ExchangeError, # {"code":-6013,"msg":"Purchasing failed"}
1654
- '-6014': BadRequest, # {"code":-6014,"msg":"Exceed up-limit allowed to purchased"}
1655
- '-6015': BadRequest, # {"code":-6015,"msg":"Empty request body"}
1656
- '-6016': BadRequest, # {"code":-6016,"msg":"Parameter err"}
1657
- '-6017': BadRequest, # {"code":-6017,"msg":"Not in whitelist"}
1658
- '-6018': BadRequest, # {"code":-6018,"msg":"Asset not enough"}
1659
- '-6019': AuthenticationError, # {"code":-6019,"msg":"Need confirm"}
1660
- '-6020': BadRequest, # {"code":-6020,"msg":"Project not exists"}
1661
- '-7001': BadRequest, # {"code":-7001,"msg":"Date range is not supported."}
1662
- '-7002': BadRequest, # {"code":-7002,"msg":"Data request type is not supported."}
1663
- '-9000': InsufficientFunds, # {"code":-9000,"msg":"user have no avaliable amount"}"
1664
- '-10017': BadRequest, # {"code":-10017,"msg":"Repay amount should not be larger than liability."}
1665
- '-11008': InsufficientFunds, # {"code":-11008,"msg":"Exceeding the account's maximum borrowable limit."} # undocumented
1666
- '-12014': RateLimitExceeded, # {"code":-12014,"msg":"More than 1 request in 3 seconds"}
1667
- '-13000': BadRequest, # {"code":-13000,"msg":"Redeption of the token is forbiden now"}
1668
- '-13001': BadRequest, # {"code":-13001,"msg":"Exceeds individual 24h redemption limit of the token"}
1669
- '-13002': BadRequest, # {"code":-13002,"msg":"Exceeds total 24h redemption limit of the token"}
1670
- '-13003': BadRequest, # {"code":-13003,"msg":"Subscription of the token is forbiden now"}
1671
- '-13004': BadRequest, # {"code":-13004,"msg":"Exceeds individual 24h subscription limit of the token"}
1672
- '-13005': BadRequest, # {"code":-13005,"msg":"Exceeds total 24h subscription limit of the token"}
1673
- '-13006': InvalidOrder, # {"code":-13006,"msg":"Subscription amount is too small"}
1674
- '-13007': AuthenticationError, # {"code":-13007,"msg":"The Agreement is not signed"}
1675
- '-21001': BadRequest, # {"code":-21001,"msg":"USER_IS_NOT_UNIACCOUNT"}
1676
- '-21002': BadRequest, # {"code":-21002,"msg":"UNI_ACCOUNT_CANT_TRANSFER_FUTURE"}
1677
- '-21003': BadRequest, # {"code":-21003,"msg":"NET_ASSET_MUST_LTE_RATIO"}
1678
- '100001003': AuthenticationError, # {"code":100001003,"msg":"Verification failed"} # undocumented
1679
- '200003903': AuthenticationError, # {"code":200003903,"msg":"Your identity verification has been rejected. Please complete identity verification again."}
1680
2332
  },
1681
2333
  'broad': {
1682
2334
  'has no operation privilege': PermissionDenied,
1683
- 'MAX_POSITION': InvalidOrder, # {"code":-2010,"msg":"Filter failure: MAX_POSITION"}
2335
+ 'MAX_POSITION': BadRequest, # {"code":-2010,"msg":"Filter failure: MAX_POSITION"}
1684
2336
  },
1685
2337
  },
1686
2338
  })
@@ -2332,7 +2984,7 @@ class binance(Exchange, ImplicitAPI):
2332
2984
  if permissions[j] == 'TRD_GRP_003':
2333
2985
  active = False
2334
2986
  break
2335
- isMarginTradingAllowed = self.safe_value(market, 'isMarginTradingAllowed', False)
2987
+ isMarginTradingAllowed = self.safe_bool(market, 'isMarginTradingAllowed', False)
2336
2988
  unifiedType = None
2337
2989
  if spot:
2338
2990
  unifiedType = 'spot'
@@ -3020,7 +3672,7 @@ class binance(Exchange, ImplicitAPI):
3020
3672
  elif market['inverse']:
3021
3673
  response = self.dapiPublicGetTicker24hr(self.extend(request, params))
3022
3674
  else:
3023
- rolling = self.safe_value(params, 'rolling', False)
3675
+ rolling = self.safe_bool(params, 'rolling', False)
3024
3676
  params = self.omit(params, 'rolling')
3025
3677
  if rolling:
3026
3678
  response = self.publicGetTicker(self.extend(request, params))
@@ -4336,7 +4988,7 @@ class binance(Exchange, ImplicitAPI):
4336
4988
  method = 'eapiPrivatePostOrder'
4337
4989
  # support for testing orders
4338
4990
  if market['spot'] or marketType == 'margin':
4339
- test = self.safe_value(query, 'test', False)
4991
+ test = self.safe_bool(query, 'test', False)
4340
4992
  if test:
4341
4993
  method += 'Test'
4342
4994
  response = getattr(self, method)(request)
@@ -4862,7 +5514,7 @@ class binance(Exchange, ImplicitAPI):
4862
5514
  params = self.omit(params, 'type')
4863
5515
  orders = self.fetch_orders(symbol, since, None, params)
4864
5516
  filteredOrders = self.filter_by(orders, 'status', 'canceled')
4865
- return self.filter_by_limit(filteredOrders, limit)
5517
+ return self.filter_by_since_limit(filteredOrders, since, limit)
4866
5518
 
4867
5519
  def cancel_order(self, id: str, symbol: Str = None, params={}):
4868
5520
  """
@@ -5339,7 +5991,7 @@ class binance(Exchange, ImplicitAPI):
5339
5991
  response = None
5340
5992
  request = {}
5341
5993
  legalMoney = self.safe_value(self.options, 'legalMoney', {})
5342
- fiatOnly = self.safe_value(params, 'fiat', False)
5994
+ fiatOnly = self.safe_bool(params, 'fiat', False)
5343
5995
  params = self.omit(params, 'fiatOnly')
5344
5996
  until = self.safe_integer(params, 'until')
5345
5997
  params = self.omit(params, 'until')
@@ -5438,7 +6090,7 @@ class binance(Exchange, ImplicitAPI):
5438
6090
  if paginate:
5439
6091
  return self.fetch_paginated_call_dynamic('fetchWithdrawals', code, since, limit, params)
5440
6092
  legalMoney = self.safe_value(self.options, 'legalMoney', {})
5441
- fiatOnly = self.safe_value(params, 'fiat', False)
6093
+ fiatOnly = self.safe_bool(params, 'fiat', False)
5442
6094
  params = self.omit(params, 'fiatOnly')
5443
6095
  request = {}
5444
6096
  until = self.safe_integer(params, 'until')
@@ -8091,6 +8743,24 @@ class binance(Exchange, ImplicitAPI):
8091
8743
  url += '?' + self.urlencode(params)
8092
8744
  return {'url': url, 'method': method, 'body': body, 'headers': headers}
8093
8745
 
8746
+ def get_exceptions_by_url(self, url, exactOrBroad):
8747
+ marketType = None
8748
+ hostname = self.hostname if (self.hostname is not None) else 'binance.com'
8749
+ if url.startswith('https://api.' + hostname + '/'):
8750
+ marketType = 'spot'
8751
+ elif url.startswith('https://dapi.' + hostname + '/'):
8752
+ marketType = 'inverse'
8753
+ elif url.startswith('https://fapi.' + hostname + '/'):
8754
+ marketType = 'linear'
8755
+ elif url.startswith('https://eapi.' + hostname + '/'):
8756
+ marketType = 'option'
8757
+ elif url.startswith('https://papi.' + hostname + '/'):
8758
+ marketType = 'portfoliomargin'
8759
+ if marketType is not None:
8760
+ exceptionsForMarketType = self.safe_value(self.exceptions, marketType, {})
8761
+ return self.safe_value(exceptionsForMarketType, exactOrBroad, {})
8762
+ return {}
8763
+
8094
8764
  def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
8095
8765
  if (code == 418) or (code == 429):
8096
8766
  raise DDoSProtection(self.id + ' ' + str(code) + ' ' + reason + ' ' + body)
@@ -8107,7 +8777,7 @@ class binance(Exchange, ImplicitAPI):
8107
8777
  if response is None:
8108
8778
  return None # fallback to default error handler
8109
8779
  # response in format {'msg': 'The coin does not exist.', 'success': True/false}
8110
- success = self.safe_value(response, 'success', True)
8780
+ success = self.safe_bool(response, 'success', True)
8111
8781
  if not success:
8112
8782
  messageNew = self.safe_string(response, 'msg')
8113
8783
  parsedMessage = None
@@ -8121,7 +8791,9 @@ class binance(Exchange, ImplicitAPI):
8121
8791
  response = parsedMessage
8122
8792
  message = self.safe_string(response, 'msg')
8123
8793
  if message is not None:
8794
+ self.throw_exactly_matched_exception(self.get_exceptions_by_url(url, 'exact'), message, self.id + ' ' + message)
8124
8795
  self.throw_exactly_matched_exception(self.exceptions['exact'], message, self.id + ' ' + message)
8796
+ self.throw_broadly_matched_exception(self.get_exceptions_by_url(url, 'broad'), message, self.id + ' ' + message)
8125
8797
  self.throw_broadly_matched_exception(self.exceptions['broad'], message, self.id + ' ' + message)
8126
8798
  # checks against error codes
8127
8799
  error = self.safe_string(response, 'code')
@@ -8143,6 +8815,7 @@ class binance(Exchange, ImplicitAPI):
8143
8815
  # POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
8144
8816
  # binanceusdm {"code":-4046,"msg":"No need to change margin type."}
8145
8817
  raise MarginModeAlreadySet(feedback)
8818
+ self.throw_exactly_matched_exception(self.get_exceptions_by_url(url, 'exact'), error, feedback)
8146
8819
  self.throw_exactly_matched_exception(self.exceptions['exact'], error, feedback)
8147
8820
  raise ExchangeError(feedback)
8148
8821
  if not success:
@@ -8154,6 +8827,7 @@ class binance(Exchange, ImplicitAPI):
8154
8827
  element = response[0]
8155
8828
  errorCode = self.safe_string(element, 'code')
8156
8829
  if errorCode is not None:
8830
+ self.throw_exactly_matched_exception(self.get_exceptions_by_url(url, 'exact'), errorCode, self.id + ' ' + body)
8157
8831
  self.throw_exactly_matched_exception(self.exceptions['exact'], errorCode, self.id + ' ' + body)
8158
8832
  return None
8159
8833