ccxt 4.4.22__py2.py3-none-any.whl → 4.4.24__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 (60) hide show
  1. ccxt/__init__.py +3 -1
  2. ccxt/abstract/binance.py +64 -43
  3. ccxt/abstract/binancecoinm.py +64 -43
  4. ccxt/abstract/binanceus.py +64 -43
  5. ccxt/abstract/binanceusdm.py +64 -43
  6. ccxt/abstract/coincatch.py +94 -0
  7. ccxt/abstract/kucoin.py +1 -0
  8. ccxt/abstract/kucoinfutures.py +1 -0
  9. ccxt/async_support/__init__.py +3 -1
  10. ccxt/async_support/base/exchange.py +1 -1
  11. ccxt/async_support/binance.py +87 -62
  12. ccxt/async_support/bitfinex.py +4 -0
  13. ccxt/async_support/bitflyer.py +1 -0
  14. ccxt/async_support/bitrue.py +3 -0
  15. ccxt/async_support/bybit.py +39 -6
  16. ccxt/async_support/cex.py +4 -0
  17. ccxt/async_support/coinbase.py +1 -1
  18. ccxt/async_support/coinbaseexchange.py +3 -0
  19. ccxt/async_support/coincatch.py +4955 -0
  20. ccxt/async_support/coinex.py +60 -1
  21. ccxt/async_support/gate.py +177 -59
  22. ccxt/async_support/hyperliquid.py +1 -1
  23. ccxt/async_support/kucoin.py +15 -8
  24. ccxt/async_support/latoken.py +6 -0
  25. ccxt/async_support/mexc.py +1 -1
  26. ccxt/async_support/oceanex.py +2 -0
  27. ccxt/async_support/okcoin.py +1 -0
  28. ccxt/async_support/poloniex.py +5 -0
  29. ccxt/async_support/yobit.py +1 -1
  30. ccxt/base/exchange.py +5 -4
  31. ccxt/binance.py +87 -62
  32. ccxt/bitfinex.py +4 -0
  33. ccxt/bitflyer.py +1 -0
  34. ccxt/bitrue.py +3 -0
  35. ccxt/bybit.py +39 -6
  36. ccxt/cex.py +4 -0
  37. ccxt/coinbase.py +1 -1
  38. ccxt/coinbaseexchange.py +3 -0
  39. ccxt/coincatch.py +4955 -0
  40. ccxt/coinex.py +60 -1
  41. ccxt/gate.py +177 -59
  42. ccxt/hyperliquid.py +1 -1
  43. ccxt/kucoin.py +15 -8
  44. ccxt/latoken.py +6 -0
  45. ccxt/mexc.py +1 -1
  46. ccxt/oceanex.py +2 -0
  47. ccxt/okcoin.py +1 -0
  48. ccxt/poloniex.py +5 -0
  49. ccxt/pro/__init__.py +3 -1
  50. ccxt/pro/coincatch.py +1429 -0
  51. ccxt/pro/kucoin.py +2 -1
  52. ccxt/pro/onetrading.py +2 -1
  53. ccxt/test/tests_async.py +29 -6
  54. ccxt/test/tests_sync.py +29 -6
  55. ccxt/yobit.py +1 -1
  56. {ccxt-4.4.22.dist-info → ccxt-4.4.24.dist-info}/METADATA +7 -6
  57. {ccxt-4.4.22.dist-info → ccxt-4.4.24.dist-info}/RECORD +60 -56
  58. {ccxt-4.4.22.dist-info → ccxt-4.4.24.dist-info}/LICENSE.txt +0 -0
  59. {ccxt-4.4.22.dist-info → ccxt-4.4.24.dist-info}/WHEEL +0 -0
  60. {ccxt-4.4.22.dist-info → ccxt-4.4.24.dist-info}/top_level.txt +0 -0
@@ -495,6 +495,7 @@ class binance(Exchange, ImplicitAPI):
495
495
  'portfolio/asset-index-price': 0.1,
496
496
  'portfolio/repay-futures-switch': 3, # Weight(IP): 30 => cost = 0.1 * 30 = 3
497
497
  'portfolio/margin-asset-leverage': 5, # Weight(IP): 50 => cost = 0.1 * 50 = 5
498
+ 'portfolio/balance': 2,
498
499
  # staking
499
500
  'staking/productList': 0.1,
500
501
  'staking/position': 0.1,
@@ -697,6 +698,7 @@ class binance(Exchange, ImplicitAPI):
697
698
  'loan/flexible/ltv/adjustment/history': 40, # Weight(IP): 400 => cost = 0.1 * 400 = 40
698
699
  'loan/flexible/loanable/data': 40, # Weight(IP): 400 => cost = 0.1 * 400 = 40
699
700
  'loan/flexible/collateral/data': 40, # Weight(IP): 400 => cost = 0.1 * 400 = 40
701
+ 'portfolio/account': 2,
700
702
  },
701
703
  'post': {
702
704
  'eth-staking/eth/stake': 15, # Weight(IP): 150 => cost = 0.1 * 150 = 15
@@ -774,6 +776,10 @@ class binance(Exchange, ImplicitAPI):
774
776
  'commissionRate': 20,
775
777
  'income/asyn': 5,
776
778
  'income/asyn/id': 5,
779
+ 'trade/asyn': 0.5,
780
+ 'trade/asyn/id': 0.5,
781
+ 'order/asyn': 0.5,
782
+ 'order/asyn/id': 0.5,
777
783
  'pmExchangeInfo': 0.5, # Weight(IP): 5 => cost = 0.1 * 5 = 0.5
778
784
  'pmAccountInfo': 0.5, # Weight(IP): 5 => cost = 0.1 * 5 = 0.5
779
785
  },
@@ -1052,99 +1058,118 @@ class binance(Exchange, ImplicitAPI):
1052
1058
  },
1053
1059
  },
1054
1060
  'papi': {
1061
+ # IP(papi) request rate limit of 6000 per minute
1062
+ # 1 IP(papi) => cost = 0.2 =>(1000 / (50 * 0.2)) * 60 = 6000
1063
+ # Order(papi) request rate limit of 1200 per minute
1064
+ # 1 Order(papi) => cost = 1 =>(1000 / (50 * 1)) * 60 = 1200
1055
1065
  'get': {
1056
- 'ping': 1,
1057
- 'um/order': 1, # 1
1058
- 'um/openOrder': 1, # 1
1066
+ 'ping': 0.2,
1067
+ 'um/order': 1,
1068
+ 'um/openOrder': 1,
1059
1069
  'um/openOrders': {'cost': 1, 'noSymbol': 40},
1060
- 'um/allOrders': 5, # 5
1061
- 'cm/order': 1, # 1
1062
- 'cm/openOrder': 1, # 1
1070
+ 'um/allOrders': 5,
1071
+ 'cm/order': 1,
1072
+ 'cm/openOrder': 1,
1063
1073
  'cm/openOrders': {'cost': 1, 'noSymbol': 40},
1064
- 'cm/allOrders': 20, # 20
1074
+ 'cm/allOrders': 20,
1065
1075
  'um/conditional/openOrder': 1,
1066
1076
  'um/conditional/openOrders': {'cost': 1, 'noSymbol': 40},
1067
1077
  'um/conditional/orderHistory': 1,
1068
- 'um/conditional/allOrders': 40,
1078
+ 'um/conditional/allOrders': {'cost': 1, 'noSymbol': 40},
1069
1079
  'cm/conditional/openOrder': 1,
1070
1080
  'cm/conditional/openOrders': {'cost': 1, 'noSymbol': 40},
1071
1081
  'cm/conditional/orderHistory': 1,
1072
1082
  'cm/conditional/allOrders': 40,
1073
- 'margin/order': 5,
1083
+ 'margin/order': 10,
1074
1084
  'margin/openOrders': 5,
1075
1085
  'margin/allOrders': 100,
1076
1086
  'margin/orderList': 5,
1077
1087
  'margin/allOrderList': 100,
1078
1088
  'margin/openOrderList': 5,
1079
1089
  'margin/myTrades': 5,
1080
- 'balance': 20, # 20
1081
- 'account': 20, # 20
1082
- 'margin/maxBorrowable': 5, # 5
1083
- 'margin/maxWithdraw': 5, # 5
1084
- 'um/positionRisk': 5, # 5
1085
- 'cm/positionRisk': 1, # 1
1086
- 'um/positionSide/dual': 30, # 30
1087
- 'cm/positionSide/dual': 30, # 30
1088
- 'um/userTrades': 5, # 5
1089
- 'cm/userTrades': 20, # 20
1090
- 'um/leverageBracket': 1, # 1
1091
- 'cm/leverageBracket': 1, # 1
1092
- 'margin/forceOrders': 1, # 1
1093
- 'um/forceOrders': 20, # 20
1094
- 'cm/forceOrders': 20, # 20
1095
- 'um/apiTradingStatus': 1, # 1
1096
- 'um/commissionRate': 20, # 20
1097
- 'cm/commissionRate': 20, # 20
1098
- 'margin/marginLoan': 10,
1099
- 'margin/repayLoan': 10,
1100
- 'margin/marginInterestHistory': 1,
1101
- 'portfolio/interest-history': 50, # 50
1102
- 'um/income': 30,
1103
- 'cm/income': 30,
1104
- 'um/account': 5,
1105
- 'cm/account': 5,
1106
- 'repay-futures-switch': 3, # Weight(IP): 30 => cost = 0.1 * 30 = 3
1090
+ 'balance': 4,
1091
+ 'account': 4,
1092
+ 'margin/maxBorrowable': 1,
1093
+ 'margin/maxWithdraw': 1,
1094
+ 'um/positionRisk': 1,
1095
+ 'cm/positionRisk': 0.2,
1096
+ 'um/positionSide/dual': 6,
1097
+ 'cm/positionSide/dual': 6,
1098
+ 'um/userTrades': 5,
1099
+ 'cm/userTrades': 20,
1100
+ 'um/leverageBracket': 0.2,
1101
+ 'cm/leverageBracket': 0.2,
1102
+ 'margin/forceOrders': 1,
1103
+ 'um/forceOrders': {'cost': 20, 'noSymbol': 50},
1104
+ 'cm/forceOrders': {'cost': 20, 'noSymbol': 50},
1105
+ 'um/apiTradingStatus': {'cost': 0.2, 'noSymbol': 2},
1106
+ 'um/commissionRate': 4,
1107
+ 'cm/commissionRate': 4,
1108
+ 'margin/marginLoan': 2,
1109
+ 'margin/repayLoan': 2,
1110
+ 'margin/marginInterestHistory': 0.2,
1111
+ 'portfolio/interest-history': 10,
1112
+ 'um/income': 6,
1113
+ 'cm/income': 6,
1114
+ 'um/account': 1,
1115
+ 'cm/account': 1,
1116
+ 'repay-futures-switch': 6,
1107
1117
  'um/adlQuantile': 5,
1108
1118
  'cm/adlQuantile': 5,
1119
+ 'um/trade/asyn': 300,
1120
+ 'um/trade/asyn/id': 2,
1121
+ 'um/order/asyn': 300,
1122
+ 'um/order/asyn/id': 2,
1123
+ 'um/income/asyn': 300,
1124
+ 'um/income/asyn/id': 2,
1125
+ 'um/orderAmendment': 1,
1126
+ 'cm/orderAmendment': 1,
1127
+ 'um/feeBurn': 30,
1128
+ 'um/accountConfig': 1,
1129
+ 'um/symbolConfig': 1,
1130
+ 'cm/accountConfig': 1,
1131
+ 'cm/symbolConfig': 1,
1109
1132
  },
1110
1133
  'post': {
1111
- 'um/order': 1, # 0
1134
+ 'um/order': 1,
1112
1135
  'um/conditional/order': 1,
1113
- 'cm/order': 1, # 0
1136
+ 'cm/order': 1,
1114
1137
  'cm/conditional/order': 1,
1115
- 'margin/order': 0.0133, # Weight(UID): 2 => cost = 0.006667 * 2 = 0.013334
1116
- 'marginLoan': 0.1333, # Weight(UID): 20 => cost = 0.006667 * 20 = 0.13334
1117
- 'repayLoan': 0.1333, # Weight(UID): 20 => cost = 0.006667 * 20 = 0.13334
1118
- 'margin/order/oco': 0.0400, # Weight(UID): 6 => cost = 0.006667 * 6 = 0.040002
1119
- 'um/leverage': 1, # 1
1120
- 'cm/leverage': 1, # 1
1121
- 'um/positionSide/dual': 1, # 1
1122
- 'cm/positionSide/dual': 1, # 1
1123
- 'auto-collection': 0.6667, # Weight(UID): 100 => cost = 0.006667 * 100 = 0.6667
1124
- 'bnb-transfer': 0.6667, # Weight(UID): 100 => cost = 0.006667 * 100 = 0.6667
1125
- 'repay-futures-switch': 150, # Weight(IP): 1500 => cost = 0.1 * 1500 = 150
1126
- 'repay-futures-negative-balance': 150, # Weight(IP): 1500 => cost = 0.1 * 1500 = 150
1127
- 'listenKey': 1, # 1
1128
- 'asset-collection': 3,
1129
- 'margin/repay-debt': 0.4, # Weight(Order): 0.4 =>(1000 / (50 * 0.4)) * 60 = 3000
1138
+ 'margin/order': 1,
1139
+ 'marginLoan': 100,
1140
+ 'repayLoan': 100,
1141
+ 'margin/order/oco': 1,
1142
+ 'um/leverage': 0.2,
1143
+ 'cm/leverage': 0.2,
1144
+ 'um/positionSide/dual': 0.2,
1145
+ 'cm/positionSide/dual': 0.2,
1146
+ 'auto-collection': 150,
1147
+ 'bnb-transfer': 150,
1148
+ 'repay-futures-switch': 150,
1149
+ 'repay-futures-negative-balance': 150,
1150
+ 'listenKey': 0.2,
1151
+ 'asset-collection': 6,
1152
+ 'margin/repay-debt': 3000,
1130
1153
  'um/feeBurn': 1,
1131
1154
  },
1132
1155
  'put': {
1133
- 'listenKey': 1, # 1
1156
+ 'listenKey': 0.2,
1157
+ 'um/order': 1,
1158
+ 'cm/order': 1,
1134
1159
  },
1135
1160
  'delete': {
1136
- 'um/order': 1, # 1
1161
+ 'um/order': 1,
1137
1162
  'um/conditional/order': 1,
1138
- 'um/allOpenOrders': 1, # 1
1163
+ 'um/allOpenOrders': 1,
1139
1164
  'um/conditional/allOpenOrders': 1,
1140
- 'cm/order': 1, # 1
1165
+ 'cm/order': 1,
1141
1166
  'cm/conditional/order': 1,
1142
- 'cm/allOpenOrders': 1, # 1
1167
+ 'cm/allOpenOrders': 1,
1143
1168
  'cm/conditional/allOpenOrders': 1,
1144
- 'margin/order': 1, # Weight(IP): 10 => cost = 0.1 * 10 = 1
1145
- 'margin/allOpenOrders': 5, # 5
1146
- 'margin/orderList': 2, # 2
1147
- 'listenKey': 1, # 1
1169
+ 'margin/order': 2,
1170
+ 'margin/allOpenOrders': 5,
1171
+ 'margin/orderList': 2,
1172
+ 'listenKey': 0.2,
1148
1173
  },
1149
1174
  },
1150
1175
  },
@@ -61,6 +61,10 @@ class bitfinex(Exchange, ImplicitAPI):
61
61
  'fetchDepositsWithdrawals': True,
62
62
  'fetchDepositWithdrawFee': 'emulated',
63
63
  'fetchDepositWithdrawFees': True,
64
+ 'fetchFundingHistory': False,
65
+ 'fetchFundingRate': False, # Endpoint 'lendbook/{currency}' is related to interest rates on spot margin lending
66
+ 'fetchFundingRateHistory': False,
67
+ 'fetchFundingRates': False,
64
68
  'fetchIndexOHLCV': False,
65
69
  'fetchLeverageTiers': False,
66
70
  'fetchMarginMode': False,
@@ -41,6 +41,7 @@ class bitflyer(Exchange, ImplicitAPI):
41
41
  'fetchDeposits': True,
42
42
  'fetchFundingRate': True,
43
43
  'fetchFundingRateHistory': False,
44
+ 'fetchFundingRates': False,
44
45
  'fetchMarginMode': False,
45
46
  'fetchMarkets': True,
46
47
  'fetchMyTrades': True,
@@ -73,7 +73,10 @@ class bitrue(Exchange, ImplicitAPI):
73
73
  'fetchDepositsWithdrawals': False,
74
74
  'fetchDepositWithdrawFee': 'emulated',
75
75
  'fetchDepositWithdrawFees': True,
76
+ 'fetchFundingHistory': False,
76
77
  'fetchFundingRate': False,
78
+ 'fetchFundingRateHistory': False,
79
+ 'fetchFundingRates': False,
77
80
  'fetchIsolatedBorrowRate': False,
78
81
  'fetchIsolatedBorrowRates': False,
79
82
  'fetchMarginMode': False,
@@ -1027,6 +1027,7 @@ class bybit(Exchange, ImplicitAPI):
1027
1027
  },
1028
1028
  'enableUnifiedMargin': None,
1029
1029
  'enableUnifiedAccount': None,
1030
+ 'unifiedMarginStatus': None,
1030
1031
  'createMarketBuyOrderRequiresPrice': True, # only True for classic accounts
1031
1032
  'createUnifiedMarginAccount': False,
1032
1033
  'defaultType': 'swap', # 'swap', 'future', 'option', 'spot'
@@ -1146,6 +1147,8 @@ class bybit(Exchange, ImplicitAPI):
1146
1147
 
1147
1148
  async def is_unified_enabled(self, params={}):
1148
1149
  """
1150
+ :see: https://bybit-exchange.github.io/docs/v5/user/apikey-info#http-request
1151
+ :see: https://bybit-exchange.github.io/docs/v5/account/account-info
1149
1152
  returns [enableUnifiedMargin, enableUnifiedAccount] so the user can check if unified account is enabled
1150
1153
  """
1151
1154
  # The API key of user id must own one of permissions will be allowed to call following API endpoints.
@@ -1159,8 +1162,12 @@ class bybit(Exchange, ImplicitAPI):
1159
1162
  # so we're assuming UTA is enabled
1160
1163
  self.options['enableUnifiedMargin'] = False
1161
1164
  self.options['enableUnifiedAccount'] = True
1165
+ self.options['unifiedMarginStatus'] = 3
1162
1166
  return [self.options['enableUnifiedMargin'], self.options['enableUnifiedAccount']]
1163
- response = await self.privateGetV5UserQueryApi(params)
1167
+ rawPromises = [self.privateGetV5UserQueryApi(params), self.privateGetV5AccountInfo(params)]
1168
+ promises = await asyncio.gather(*rawPromises)
1169
+ response = promises[0]
1170
+ accountInfo = promises[1]
1164
1171
  #
1165
1172
  # {
1166
1173
  # "retCode": 0,
@@ -1200,13 +1207,34 @@ class bybit(Exchange, ImplicitAPI):
1200
1207
  # "retExtInfo": {},
1201
1208
  # "time": 1676891757649
1202
1209
  # }
1210
+ # account info
1211
+ # {
1212
+ # "retCode": 0,
1213
+ # "retMsg": "OK",
1214
+ # "result": {
1215
+ # "marginMode": "REGULAR_MARGIN",
1216
+ # "updatedTime": "1697078946000",
1217
+ # "unifiedMarginStatus": 4,
1218
+ # "dcpStatus": "OFF",
1219
+ # "timeWindow": 10,
1220
+ # "smpGroup": 0,
1221
+ # "isMasterTrader": False,
1222
+ # "spotHedgingStatus": "OFF"
1223
+ # }
1224
+ # }
1203
1225
  #
1204
1226
  result = self.safe_dict(response, 'result', {})
1227
+ accountResult = self.safe_dict(accountInfo, 'result', {})
1205
1228
  self.options['enableUnifiedMargin'] = self.safe_integer(result, 'unified') == 1
1206
1229
  self.options['enableUnifiedAccount'] = self.safe_integer(result, 'uta') == 1
1230
+ self.options['unifiedMarginStatus'] = self.safe_integer(accountResult, 'unifiedMarginStatus', 3) # default to uta.1 if not found
1207
1231
  return [self.options['enableUnifiedMargin'], self.options['enableUnifiedAccount']]
1208
1232
 
1209
1233
  async def upgrade_unified_trade_account(self, params={}):
1234
+ """
1235
+ :see: https://bybit-exchange.github.io/docs/v5/account/upgrade-unified-account
1236
+ upgrades the account to unified trade account *warning* self is irreversible
1237
+ """
1210
1238
  return await self.privatePostV5AccountUpgradeToUta(params)
1211
1239
 
1212
1240
  def create_expired_option_market(self, symbol: str):
@@ -3019,10 +3047,15 @@ class bybit(Exchange, ImplicitAPI):
3019
3047
  isInverse = (type == 'inverse')
3020
3048
  isFunding = (lowercaseRawType == 'fund') or (lowercaseRawType == 'funding')
3021
3049
  if isUnifiedAccount:
3022
- if isInverse:
3023
- type = 'contract'
3050
+ unifiedMarginStatus = self.safe_integer(self.options, 'unifiedMarginStatus', 3)
3051
+ if unifiedMarginStatus < 5:
3052
+ # it's not uta.20 where inverse are unified
3053
+ if isInverse:
3054
+ type = 'contract'
3055
+ else:
3056
+ type = 'unified'
3024
3057
  else:
3025
- type = 'unified'
3058
+ type = 'unified' # uta.20 where inverse are unified
3026
3059
  else:
3027
3060
  if isLinear or isInverse:
3028
3061
  type = 'contract'
@@ -7088,13 +7121,13 @@ class bybit(Exchange, ImplicitAPI):
7088
7121
 
7089
7122
  def parse_margin_loan(self, info, currency: Currency = None):
7090
7123
  #
7091
- # borrowMargin
7124
+ # borrowCrossMargin
7092
7125
  #
7093
7126
  # {
7094
7127
  # "transactId": "14143"
7095
7128
  # }
7096
7129
  #
7097
- # repayMargin
7130
+ # repayCrossMargin
7098
7131
  #
7099
7132
  # {
7100
7133
  # "repayId": "12128"
ccxt/async_support/cex.py CHANGED
@@ -44,6 +44,10 @@ class cex(Exchange, ImplicitAPI):
44
44
  'fetchCurrencies': True,
45
45
  'fetchDepositAddress': True,
46
46
  'fetchDepositsWithdrawals': True,
47
+ 'fetchFundingHistory': False,
48
+ 'fetchFundingRate': False,
49
+ 'fetchFundingRateHistory': False,
50
+ 'fetchFundingRates': False,
47
51
  'fetchLedger': True,
48
52
  'fetchMarkets': True,
49
53
  'fetchOHLCV': True,
@@ -3492,7 +3492,7 @@ class coinbase(Exchange, ImplicitAPI):
3492
3492
  paginate = False
3493
3493
  paginate, params = self.handle_option_and_params(params, 'fetchMyTrades', 'paginate')
3494
3494
  if paginate:
3495
- return await self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, 'cursor', 'cursor', None, 100)
3495
+ return await self.fetch_paginated_call_cursor('fetchMyTrades', symbol, since, limit, params, 'cursor', 'cursor', None, 250)
3496
3496
  market = None
3497
3497
  if symbol is not None:
3498
3498
  market = self.market(symbol)
@@ -53,7 +53,10 @@ class coinbaseexchange(Exchange, ImplicitAPI):
53
53
  'fetchDepositAddress': False, # the exchange does not have self method, only createDepositAddress, see https://github.com/ccxt/ccxt/pull/7405
54
54
  'fetchDeposits': True,
55
55
  'fetchDepositsWithdrawals': True,
56
+ 'fetchFundingHistory': False,
56
57
  'fetchFundingRate': False,
58
+ 'fetchFundingRateHistory': False,
59
+ 'fetchFundingRates': False,
57
60
  'fetchLedger': True,
58
61
  'fetchMarginMode': False,
59
62
  'fetchMarkets': True,