ccxt 4.3.21__py2.py3-none-any.whl → 4.3.23__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/whitebit.py +9 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +1 -1
- ccxt/async_support/coinbase.py +4 -0
- ccxt/async_support/coinex.py +156 -178
- ccxt/async_support/phemex.py +58 -13
- ccxt/async_support/probit.py +1 -20
- ccxt/async_support/whitebit.py +9 -0
- ccxt/base/exchange.py +1 -1
- ccxt/binance.py +1 -1
- ccxt/coinbase.py +4 -0
- ccxt/coinex.py +156 -178
- ccxt/phemex.py +58 -13
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/poloniexfutures.py +20 -16
- ccxt/probit.py +1 -20
- ccxt/whitebit.py +9 -0
- {ccxt-4.3.21.dist-info → ccxt-4.3.23.dist-info}/METADATA +4 -4
- {ccxt-4.3.21.dist-info → ccxt-4.3.23.dist-info}/RECORD +23 -23
- {ccxt-4.3.21.dist-info → ccxt-4.3.23.dist-info}/WHEEL +0 -0
- {ccxt-4.3.21.dist-info → ccxt-4.3.23.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/whitebit.py
CHANGED
@@ -87,3 +87,12 @@ class ImplicitAPI:
|
|
87
87
|
v4_private_post_convert_estimate = v4PrivatePostConvertEstimate = Entry('convert/estimate', ['v4', 'private'], 'POST', {})
|
88
88
|
v4_private_post_convert_confirm = v4PrivatePostConvertConfirm = Entry('convert/confirm', ['v4', 'private'], 'POST', {})
|
89
89
|
v4_private_post_convert_history = v4PrivatePostConvertHistory = Entry('convert/history', ['v4', 'private'], 'POST', {})
|
90
|
+
v4_private_post_sub_account_create = v4PrivatePostSubAccountCreate = Entry('sub-account/create', ['v4', 'private'], 'POST', {})
|
91
|
+
v4_private_post_sub_account_delete = v4PrivatePostSubAccountDelete = Entry('sub-account/delete', ['v4', 'private'], 'POST', {})
|
92
|
+
v4_private_post_sub_account_edit = v4PrivatePostSubAccountEdit = Entry('sub-account/edit', ['v4', 'private'], 'POST', {})
|
93
|
+
v4_private_post_sub_account_list = v4PrivatePostSubAccountList = Entry('sub-account/list', ['v4', 'private'], 'POST', {})
|
94
|
+
v4_private_post_sub_account_transfer = v4PrivatePostSubAccountTransfer = Entry('sub-account/transfer', ['v4', 'private'], 'POST', {})
|
95
|
+
v4_private_post_sub_account_block = v4PrivatePostSubAccountBlock = Entry('sub-account/block', ['v4', 'private'], 'POST', {})
|
96
|
+
v4_private_post_sub_account_unblock = v4PrivatePostSubAccountUnblock = Entry('sub-account/unblock', ['v4', 'private'], 'POST', {})
|
97
|
+
v4_private_post_sub_account_balances = v4PrivatePostSubAccountBalances = Entry('sub-account/balances', ['v4', 'private'], 'POST', {})
|
98
|
+
v4_private_post_sub_account_transfer_history = v4PrivatePostSubAccountTransferHistory = Entry('sub-account/transfer/history', ['v4', 'private'], 'POST', {})
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/binance.py
CHANGED
@@ -9004,7 +9004,7 @@ class binance(Exchange, ImplicitAPI):
|
|
9004
9004
|
await self.load_markets()
|
9005
9005
|
# by default cache the leverage bracket
|
9006
9006
|
# it contains useful stuff like the maintenance margin and initial margin for positions
|
9007
|
-
leverageBrackets = self.safe_dict(self.options, 'leverageBrackets'
|
9007
|
+
leverageBrackets = self.safe_dict(self.options, 'leverageBrackets')
|
9008
9008
|
if (leverageBrackets is None) or (reload):
|
9009
9009
|
defaultType = self.safe_string(self.options, 'defaultType', 'future')
|
9010
9010
|
type = self.safe_string(params, 'type', defaultType)
|
ccxt/async_support/coinbase.py
CHANGED
@@ -1754,6 +1754,10 @@ class coinbase(Exchange, ImplicitAPI):
|
|
1754
1754
|
request = {}
|
1755
1755
|
if symbols is not None:
|
1756
1756
|
request['product_ids'] = self.market_ids(symbols)
|
1757
|
+
marketType = None
|
1758
|
+
marketType, params = self.handle_market_type_and_params('fetchTickers', self.get_market_from_symbols(symbols), params, 'default')
|
1759
|
+
if marketType is not None and marketType != 'default':
|
1760
|
+
request['product_type'] = 'FUTURE' if (marketType == 'swap') else 'SPOT'
|
1757
1761
|
response = await self.v3PublicGetBrokerageMarketProducts(self.extend(request, params))
|
1758
1762
|
#
|
1759
1763
|
# {
|
ccxt/async_support/coinex.py
CHANGED
@@ -11,6 +11,7 @@ from typing import List
|
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
13
13
|
from ccxt.base.errors import PermissionDenied
|
14
|
+
from ccxt.base.errors import AccountSuspended
|
14
15
|
from ccxt.base.errors import ArgumentsRequired
|
15
16
|
from ccxt.base.errors import BadRequest
|
16
17
|
from ccxt.base.errors import BadSymbol
|
@@ -481,10 +482,53 @@ class coinex(Exchange, ImplicitAPI):
|
|
481
482
|
'36': RequestTimeout, # Service timeout
|
482
483
|
'213': RateLimitExceeded, # Too many requests
|
483
484
|
'107': InsufficientFunds,
|
485
|
+
'158': PermissionDenied, # {"code":158,"data":{},"message":"API permission is not allowed"}
|
484
486
|
'600': OrderNotFound,
|
485
487
|
'601': InvalidOrder,
|
486
488
|
'602': InvalidOrder,
|
487
489
|
'606': InvalidOrder,
|
490
|
+
'3008': RequestTimeout, # Service busy, please try again later.
|
491
|
+
'3109': InsufficientFunds, # {"code":3109,"data":{},"message":"balance not enough"}
|
492
|
+
'3127': InvalidOrder, # The order quantity is below the minimum requirement. Please adjust the order quantity.
|
493
|
+
'3606': InvalidOrder, # The price difference between the order price and the latest price is too large. Please adjust the order amount accordingly.
|
494
|
+
'3610': ExchangeError, # Order cancellation prohibited during the Call Auction period.
|
495
|
+
'3612': InvalidOrder, # The est. ask price is lower than the current bottom ask price. Please reduce the amount.
|
496
|
+
'3613': InvalidOrder, # The est. bid price is higher than the current top bid price. Please reduce the amount.
|
497
|
+
'3614': InvalidOrder, # The deviation between your est. filled price and the index price. Please reduce the amount.
|
498
|
+
'3615': InvalidOrder, # The deviation between your order price and the index price is too high. Please adjust your order price and try again.
|
499
|
+
'3616': InvalidOrder, # The order price exceeds the current top bid price. Please adjust the order price and try again.
|
500
|
+
'3617': InvalidOrder, # The order price exceeds the current bottom ask price. Please adjust the order price and try again.
|
501
|
+
'3618': InvalidOrder, # The deviation between your order price and the index price is too high. Please adjust your order price and try again.
|
502
|
+
'3619': InvalidOrder, # The deviation between your order price and the trigger price is too high. Please adjust your order price and try again.
|
503
|
+
'3620': InvalidOrder, # Market order submission is temporarily unavailable due to insufficient depth in the current market
|
504
|
+
'3621': InvalidOrder, # This order can't be completely executed and has been canceled.
|
505
|
+
'3622': InvalidOrder, # This order can't be set Only and has been canceled.
|
506
|
+
'3627': InvalidOrder, # The current market depth is low, please reduce your order amount and try again.
|
507
|
+
'3628': InvalidOrder, # The current market depth is low, please reduce your order amount and try again.
|
508
|
+
'3629': InvalidOrder, # The current market depth is low, please reduce your order amount and try again.
|
509
|
+
'3632': InvalidOrder, # The order price exceeds the current top bid price. Please adjust the order price and try again.
|
510
|
+
'3633': InvalidOrder, # The order price exceeds the current bottom ask price. Please adjust the order price and try again.
|
511
|
+
'3634': InvalidOrder, # The deviation between your est. filled price and the index price is too high. Please reduce the amount and try again.
|
512
|
+
'3635': InvalidOrder, # The deviation between your est. filled price and the index price is too high. Please reduce the amount and try again.
|
513
|
+
'4001': ExchangeNotAvailable, # Service unavailable, please try again later.
|
514
|
+
'4002': RequestTimeout, # Service request timed out, please try again later.
|
515
|
+
'4003': ExchangeError, # Internal error, please contact customer service for help.
|
516
|
+
'4004': BadRequest, # Parameter error, please check whether the request parameters are abnormal.
|
517
|
+
'4005': AuthenticationError, # Abnormal access_id, please check whether the value passed by X-COINEX-KEY is normal.
|
518
|
+
'4006': AuthenticationError, # Signature verification failed, please check the signature according to the documentation instructions.
|
519
|
+
'4007': PermissionDenied, # IP address prohibited, please check whether the whitelist or export IP is normal.
|
520
|
+
'4008': AuthenticationError, # Abnormal X-COIN-SIGN value, please check.
|
521
|
+
'4009': ExchangeError, # Abnormal request method, please check.
|
522
|
+
'4010': ExchangeError, # Expired request, please try again later.
|
523
|
+
'4011': PermissionDenied, # User prohibited from accessing, please contact customer service for help.
|
524
|
+
'4017': ExchangeError, # Signature expired, please try again later.
|
525
|
+
'4115': AccountSuspended, # User prohibited from trading, please contact customer service for help.
|
526
|
+
'4117': BadSymbol, # Trading hasattr(self, prohibited) market, please try again later.
|
527
|
+
'4123': RateLimitExceeded, # Rate limit triggered. Please adjust your strategy and reduce the request rate.
|
528
|
+
'4130': ExchangeError, # Futures trading prohibited, please try again later.
|
529
|
+
'4158': ExchangeError, # Trading prohibited, please try again later.
|
530
|
+
'4213': RateLimitExceeded, # The request is too frequent, please try again later.
|
531
|
+
'4512': PermissionDenied, # Insufficient sub-account permissions, please check.
|
488
532
|
},
|
489
533
|
'broad': {
|
490
534
|
'ip not allow visit': PermissionDenied,
|
@@ -4139,8 +4183,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
4139
4183
|
|
4140
4184
|
async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4141
4185
|
"""
|
4142
|
-
fetch the history of funding payments paid and received on self account
|
4143
|
-
:see: https://
|
4186
|
+
fetch the history of funding fee payments paid and received on self account
|
4187
|
+
:see: https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
|
4144
4188
|
:param str symbol: unified market symbol
|
4145
4189
|
:param int [since]: the earliest time in ms to fetch funding history for
|
4146
4190
|
:param int [limit]: the maximum number of funding history structures to retrieve
|
@@ -4149,53 +4193,45 @@ class coinex(Exchange, ImplicitAPI):
|
|
4149
4193
|
"""
|
4150
4194
|
if symbol is None:
|
4151
4195
|
raise ArgumentsRequired(self.id + ' fetchFundingHistory() requires a symbol argument')
|
4152
|
-
limit = 100 if (limit is None) else limit
|
4153
4196
|
await self.load_markets()
|
4154
4197
|
market = self.market(symbol)
|
4155
4198
|
request = {
|
4156
4199
|
'market': market['id'],
|
4157
|
-
'
|
4158
|
-
# 'offset': 0,
|
4159
|
-
# 'end_time': 1638990636000,
|
4160
|
-
# 'windowtime': 1638990636000,
|
4200
|
+
'market_type': 'FUTURES',
|
4161
4201
|
}
|
4202
|
+
request, params = self.handle_until_option('end_time', request, params)
|
4162
4203
|
if since is not None:
|
4163
4204
|
request['start_time'] = since
|
4164
|
-
|
4205
|
+
if limit is not None:
|
4206
|
+
request['limit'] = limit
|
4207
|
+
response = await self.v2PrivateGetFuturesPositionFundingHistory(self.extend(request, params))
|
4165
4208
|
#
|
4166
4209
|
# {
|
4167
4210
|
# "code": 0,
|
4168
|
-
# "data":
|
4169
|
-
#
|
4170
|
-
#
|
4171
|
-
#
|
4172
|
-
#
|
4173
|
-
#
|
4174
|
-
#
|
4175
|
-
#
|
4176
|
-
#
|
4177
|
-
#
|
4178
|
-
#
|
4179
|
-
#
|
4180
|
-
#
|
4181
|
-
#
|
4182
|
-
#
|
4183
|
-
#
|
4184
|
-
# "user_id": 3620173,
|
4185
|
-
# "value": "47.76294"
|
4186
|
-
# },
|
4187
|
-
# ]
|
4188
|
-
# },
|
4189
|
-
# "message": "OK"
|
4211
|
+
# "data": [
|
4212
|
+
# {
|
4213
|
+
# "ccy": "USDT",
|
4214
|
+
# "created_at": 1715673620183,
|
4215
|
+
# "funding_rate": "0",
|
4216
|
+
# "funding_value": "0",
|
4217
|
+
# "market": "BTCUSDT",
|
4218
|
+
# "market_type": "FUTURES",
|
4219
|
+
# "position_id": 306458800,
|
4220
|
+
# "side": "long"
|
4221
|
+
# },
|
4222
|
+
# ],
|
4223
|
+
# "message": "OK",
|
4224
|
+
# "pagination": {
|
4225
|
+
# "has_next": True
|
4226
|
+
# }
|
4190
4227
|
# }
|
4191
4228
|
#
|
4192
|
-
data = self.
|
4193
|
-
resultList = self.safe_value(data, 'records', [])
|
4229
|
+
data = self.safe_list(response, 'data', [])
|
4194
4230
|
result = []
|
4195
|
-
for i in range(0, len(
|
4196
|
-
entry =
|
4197
|
-
timestamp = self.
|
4198
|
-
currencyId = self.safe_string(entry, '
|
4231
|
+
for i in range(0, len(data)):
|
4232
|
+
entry = data[i]
|
4233
|
+
timestamp = self.safe_integer(entry, 'created_at')
|
4234
|
+
currencyId = self.safe_string(entry, 'ccy')
|
4199
4235
|
code = self.safe_currency_code(currencyId)
|
4200
4236
|
result.append({
|
4201
4237
|
'info': entry,
|
@@ -4204,14 +4240,14 @@ class coinex(Exchange, ImplicitAPI):
|
|
4204
4240
|
'timestamp': timestamp,
|
4205
4241
|
'datetime': self.iso8601(timestamp),
|
4206
4242
|
'id': self.safe_number(entry, 'position_id'),
|
4207
|
-
'amount': self.safe_number(entry, '
|
4243
|
+
'amount': self.safe_number(entry, 'funding_value'),
|
4208
4244
|
})
|
4209
4245
|
return result
|
4210
4246
|
|
4211
4247
|
async def fetch_funding_rate(self, symbol: str, params={}):
|
4212
4248
|
"""
|
4213
4249
|
fetch the current funding rate
|
4214
|
-
:see: https://
|
4250
|
+
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
4215
4251
|
:param str symbol: unified market symbol
|
4216
4252
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4217
4253
|
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
@@ -4223,93 +4259,63 @@ class coinex(Exchange, ImplicitAPI):
|
|
4223
4259
|
request = {
|
4224
4260
|
'market': market['id'],
|
4225
4261
|
}
|
4226
|
-
response = await self.
|
4262
|
+
response = await self.v2PublicGetFuturesFundingRate(self.extend(request, params))
|
4227
4263
|
#
|
4228
4264
|
# {
|
4229
|
-
#
|
4230
|
-
# "data":
|
4231
|
-
#
|
4232
|
-
#
|
4233
|
-
#
|
4234
|
-
# "
|
4235
|
-
# "
|
4236
|
-
# "
|
4237
|
-
# "
|
4238
|
-
# "
|
4239
|
-
# "
|
4240
|
-
# "period": 86400,
|
4241
|
-
# "funding_time": 372,
|
4242
|
-
# "position_amount": "270.1956",
|
4243
|
-
# "funding_rate_last": "0.00022913",
|
4244
|
-
# "funding_rate_next": "0.00013158",
|
4245
|
-
# "funding_rate_predict": "0.00016552",
|
4246
|
-
# "insurance": "16045554.83969682659674035672",
|
4247
|
-
# "sign_price": "39652.48",
|
4248
|
-
# "index_price": "39648.44250000",
|
4249
|
-
# "sell_total": "22.3913",
|
4250
|
-
# "buy_total": "19.4498",
|
4251
|
-
# "buy_amount": "12.8942",
|
4252
|
-
# "sell": "39663.80",
|
4253
|
-
# "sell_amount": "0.9388"
|
4265
|
+
# "code": 0,
|
4266
|
+
# "data": [
|
4267
|
+
# {
|
4268
|
+
# "latest_funding_rate": "0",
|
4269
|
+
# "latest_funding_time": 1715731200000,
|
4270
|
+
# "mark_price": "61602.22",
|
4271
|
+
# "market": "BTCUSDT",
|
4272
|
+
# "max_funding_rate": "0.00375",
|
4273
|
+
# "min_funding_rate": "-0.00375",
|
4274
|
+
# "next_funding_rate": "0.00021074",
|
4275
|
+
# "next_funding_time": 1715760000000
|
4254
4276
|
# }
|
4255
|
-
#
|
4277
|
+
# ],
|
4256
4278
|
# "message": "OK"
|
4257
4279
|
# }
|
4258
4280
|
#
|
4259
|
-
data = self.
|
4260
|
-
|
4261
|
-
|
4262
|
-
ticker['timestamp'] = timestamp # avoid changing parseFundingRate signature
|
4263
|
-
return self.parse_funding_rate(ticker, market)
|
4281
|
+
data = self.safe_list(response, 'data', [])
|
4282
|
+
first = self.safe_dict(data, 0, {})
|
4283
|
+
return self.parse_funding_rate(first, market)
|
4264
4284
|
|
4265
4285
|
def parse_funding_rate(self, contract, market: Market = None):
|
4266
4286
|
#
|
4267
|
-
# fetchFundingRate
|
4287
|
+
# fetchFundingRate, fetchFundingRates
|
4268
4288
|
#
|
4269
4289
|
# {
|
4270
|
-
# "
|
4271
|
-
# "
|
4272
|
-
# "
|
4273
|
-
# "
|
4274
|
-
# "
|
4275
|
-
# "
|
4276
|
-
# "
|
4277
|
-
# "
|
4278
|
-
# "position_amount": "270.1956",
|
4279
|
-
# "funding_rate_last": "0.00022913",
|
4280
|
-
# "funding_rate_next": "0.00013158",
|
4281
|
-
# "funding_rate_predict": "0.00016552",
|
4282
|
-
# "insurance": "16045554.83969682659674035672",
|
4283
|
-
# "sign_price": "39652.48",
|
4284
|
-
# "index_price": "39648.44250000",
|
4285
|
-
# "sell_total": "22.3913",
|
4286
|
-
# "buy_total": "19.4498",
|
4287
|
-
# "buy_amount": "12.8942",
|
4288
|
-
# "sell": "39663.80",
|
4289
|
-
# "sell_amount": "0.9388"
|
4290
|
+
# "latest_funding_rate": "0",
|
4291
|
+
# "latest_funding_time": 1715731200000,
|
4292
|
+
# "mark_price": "61602.22",
|
4293
|
+
# "market": "BTCUSDT",
|
4294
|
+
# "max_funding_rate": "0.00375",
|
4295
|
+
# "min_funding_rate": "-0.00375",
|
4296
|
+
# "next_funding_rate": "0.00021074",
|
4297
|
+
# "next_funding_time": 1715760000000
|
4290
4298
|
# }
|
4291
4299
|
#
|
4292
|
-
|
4293
|
-
|
4294
|
-
|
4295
|
-
fundingHour = (timestamp + fundingDelta) / 3600000
|
4296
|
-
fundingTimestamp = int(round(fundingHour)) * 3600000
|
4300
|
+
currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
|
4301
|
+
futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
|
4302
|
+
marketId = self.safe_string(contract, 'market')
|
4297
4303
|
return {
|
4298
4304
|
'info': contract,
|
4299
|
-
'symbol': self.safe_symbol(None,
|
4300
|
-
'markPrice': self.safe_number(contract, '
|
4301
|
-
'indexPrice':
|
4305
|
+
'symbol': self.safe_symbol(marketId, market, None, 'swap'),
|
4306
|
+
'markPrice': self.safe_number(contract, 'mark_price'),
|
4307
|
+
'indexPrice': None,
|
4302
4308
|
'interestRate': None,
|
4303
4309
|
'estimatedSettlePrice': None,
|
4304
|
-
'timestamp':
|
4305
|
-
'datetime':
|
4306
|
-
'fundingRate': self.safe_number(contract, '
|
4307
|
-
'fundingTimestamp':
|
4308
|
-
'fundingDatetime': self.iso8601(
|
4309
|
-
'nextFundingRate': self.safe_number(contract, '
|
4310
|
-
'nextFundingTimestamp':
|
4311
|
-
'nextFundingDatetime':
|
4312
|
-
'previousFundingRate':
|
4310
|
+
'timestamp': None,
|
4311
|
+
'datetime': None,
|
4312
|
+
'fundingRate': self.safe_number(contract, 'latest_funding_rate'),
|
4313
|
+
'fundingTimestamp': currentFundingTimestamp,
|
4314
|
+
'fundingDatetime': self.iso8601(currentFundingTimestamp),
|
4315
|
+
'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
|
4316
|
+
'nextFundingTimestamp': futureFundingTimestamp,
|
4317
|
+
'nextFundingDatetime': self.iso8601(futureFundingTimestamp),
|
4318
|
+
'previousFundingRate': None,
|
4313
4319
|
'previousFundingTimestamp': None,
|
4314
4320
|
'previousFundingDatetime': None,
|
4315
4321
|
}
|
@@ -4317,65 +4323,43 @@ class coinex(Exchange, ImplicitAPI):
|
|
4317
4323
|
async def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
4318
4324
|
"""
|
4319
4325
|
fetch the current funding rates
|
4320
|
-
:see: https://
|
4326
|
+
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
4321
4327
|
:param str[] symbols: unified market symbols
|
4322
4328
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4323
4329
|
:returns dict[]: an array of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
4324
4330
|
"""
|
4325
4331
|
await self.load_markets()
|
4326
4332
|
symbols = self.market_symbols(symbols)
|
4333
|
+
request = {}
|
4327
4334
|
market = None
|
4328
4335
|
if symbols is not None:
|
4329
4336
|
symbol = self.safe_value(symbols, 0)
|
4330
4337
|
market = self.market(symbol)
|
4331
4338
|
if not market['swap']:
|
4332
4339
|
raise BadSymbol(self.id + ' fetchFundingRates() supports swap contracts only')
|
4333
|
-
|
4340
|
+
marketIds = self.market_ids(symbols)
|
4341
|
+
request['market'] = ','.join(marketIds)
|
4342
|
+
response = await self.v2PublicGetFuturesFundingRate(self.extend(request, params))
|
4334
4343
|
#
|
4335
4344
|
# {
|
4336
4345
|
# "code": 0,
|
4337
|
-
# "data":
|
4338
|
-
#
|
4339
|
-
#
|
4340
|
-
#
|
4341
|
-
# "
|
4342
|
-
#
|
4343
|
-
#
|
4344
|
-
#
|
4345
|
-
#
|
4346
|
-
#
|
4347
|
-
# "buy": "39663.79",
|
4348
|
-
# "period": 86400,
|
4349
|
-
# "funding_time": 372,
|
4350
|
-
# "position_amount": "270.1956",
|
4351
|
-
# "funding_rate_last": "0.00022913",
|
4352
|
-
# "funding_rate_next": "0.00013158",
|
4353
|
-
# "funding_rate_predict": "0.00016552",
|
4354
|
-
# "insurance": "16045554.83969682659674035672",
|
4355
|
-
# "sign_price": "39652.48",
|
4356
|
-
# "index_price": "39648.44250000",
|
4357
|
-
# "sell_total": "22.3913",
|
4358
|
-
# "buy_total": "19.4498",
|
4359
|
-
# "buy_amount": "12.8942",
|
4360
|
-
# "sell": "39663.80",
|
4361
|
-
# "sell_amount": "0.9388"
|
4362
|
-
# }
|
4346
|
+
# "data": [
|
4347
|
+
# {
|
4348
|
+
# "latest_funding_rate": "0",
|
4349
|
+
# "latest_funding_time": 1715731200000,
|
4350
|
+
# "mark_price": "61602.22",
|
4351
|
+
# "market": "BTCUSDT",
|
4352
|
+
# "max_funding_rate": "0.00375",
|
4353
|
+
# "min_funding_rate": "-0.00375",
|
4354
|
+
# "next_funding_rate": "0.00021074",
|
4355
|
+
# "next_funding_time": 1715760000000
|
4363
4356
|
# }
|
4364
|
-
#
|
4357
|
+
# ],
|
4365
4358
|
# "message": "OK"
|
4366
4359
|
# }
|
4367
|
-
|
4368
|
-
|
4369
|
-
|
4370
|
-
result = []
|
4371
|
-
marketIds = list(tickers.keys())
|
4372
|
-
for i in range(0, len(marketIds)):
|
4373
|
-
marketId = marketIds[i]
|
4374
|
-
if marketId.find('_') == -1: # skip _signprice and _indexprice
|
4375
|
-
marketInner = self.safe_market(marketId, None, None, 'swap')
|
4376
|
-
ticker = tickers[marketId]
|
4377
|
-
ticker['timestamp'] = timestamp
|
4378
|
-
result.append(self.parse_funding_rate(ticker, marketInner))
|
4360
|
+
#
|
4361
|
+
data = self.safe_list(response, 'data', [])
|
4362
|
+
result = self.parse_funding_rates(data, market)
|
4379
4363
|
return self.filter_by_array(result, 'symbol', symbols)
|
4380
4364
|
|
4381
4365
|
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}):
|
@@ -4443,13 +4427,13 @@ class coinex(Exchange, ImplicitAPI):
|
|
4443
4427
|
|
4444
4428
|
async def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4445
4429
|
"""
|
4446
|
-
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
|
4447
4430
|
fetches historical funding rate prices
|
4431
|
+
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
|
4448
4432
|
:param str symbol: unified symbol of the market to fetch the funding rate history for
|
4449
4433
|
:param int [since]: timestamp in ms of the earliest funding rate to fetch
|
4450
4434
|
:param int [limit]: the maximum amount of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>` to fetch
|
4451
4435
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4452
|
-
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [
|
4436
|
+
:param boolean [params.paginate]: default False, when True will automatically paginate by calling self endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
4453
4437
|
:param int [params.until]: timestamp in ms of the latest funding rate
|
4454
4438
|
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-history-structure>`
|
4455
4439
|
"""
|
@@ -4460,50 +4444,44 @@ class coinex(Exchange, ImplicitAPI):
|
|
4460
4444
|
paginate, params = self.handle_option_and_params(params, 'fetchFundingRateHistory', 'paginate')
|
4461
4445
|
if paginate:
|
4462
4446
|
return await self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000)
|
4463
|
-
if limit is None:
|
4464
|
-
limit = 100
|
4465
4447
|
market = self.market(symbol)
|
4466
4448
|
request = {
|
4467
4449
|
'market': market['id'],
|
4468
|
-
'limit': limit,
|
4469
|
-
'offset': 0,
|
4470
|
-
# 'end_time': 1638990636,
|
4471
4450
|
}
|
4472
4451
|
if since is not None:
|
4473
4452
|
request['start_time'] = since
|
4453
|
+
if limit is not None:
|
4454
|
+
request['limit'] = limit
|
4474
4455
|
request, params = self.handle_until_option('end_time', request, params)
|
4475
|
-
response = await self.
|
4456
|
+
response = await self.v2PublicGetFuturesFundingRateHistory(self.extend(request, params))
|
4476
4457
|
#
|
4477
4458
|
# {
|
4478
4459
|
# "code": 0,
|
4479
|
-
# "data":
|
4480
|
-
#
|
4481
|
-
#
|
4482
|
-
#
|
4483
|
-
#
|
4484
|
-
#
|
4485
|
-
#
|
4486
|
-
#
|
4487
|
-
#
|
4488
|
-
#
|
4489
|
-
#
|
4490
|
-
#
|
4491
|
-
# },
|
4492
|
-
# "message": "OK"
|
4460
|
+
# "data": [
|
4461
|
+
# {
|
4462
|
+
# "actual_funding_rate": "0",
|
4463
|
+
# "funding_time": 1715731221761,
|
4464
|
+
# "market": "BTCUSDT",
|
4465
|
+
# "theoretical_funding_rate": "0"
|
4466
|
+
# },
|
4467
|
+
# ],
|
4468
|
+
# "message": "OK",
|
4469
|
+
# "pagination": {
|
4470
|
+
# "has_next": True
|
4471
|
+
# }
|
4493
4472
|
# }
|
4494
4473
|
#
|
4495
|
-
data = self.
|
4496
|
-
result = self.safe_value(data, 'records', [])
|
4474
|
+
data = self.safe_list(response, 'data', [])
|
4497
4475
|
rates = []
|
4498
|
-
for i in range(0, len(
|
4499
|
-
entry =
|
4476
|
+
for i in range(0, len(data)):
|
4477
|
+
entry = data[i]
|
4500
4478
|
marketId = self.safe_string(entry, 'market')
|
4501
4479
|
symbolInner = self.safe_symbol(marketId, market, None, 'swap')
|
4502
|
-
timestamp = self.
|
4480
|
+
timestamp = self.safe_integer(entry, 'funding_time')
|
4503
4481
|
rates.append({
|
4504
4482
|
'info': entry,
|
4505
4483
|
'symbol': symbolInner,
|
4506
|
-
'fundingRate': self.safe_number(entry, '
|
4484
|
+
'fundingRate': self.safe_number(entry, 'actual_funding_rate'),
|
4507
4485
|
'timestamp': timestamp,
|
4508
4486
|
'datetime': self.iso8601(timestamp),
|
4509
4487
|
})
|
@@ -5550,7 +5528,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5550
5528
|
code = self.safe_string(response, 'code')
|
5551
5529
|
data = self.safe_value(response, 'data')
|
5552
5530
|
message = self.safe_string(response, 'message')
|
5553
|
-
if (code != '0') or ((message != 'Success') and (message != 'Succeeded') and (message != '
|
5531
|
+
if (code != '0') or ((message != 'Success') and (message != 'Succeeded') and (message.lower() != 'ok') and not data):
|
5554
5532
|
feedback = self.id + ' ' + message
|
5555
5533
|
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
5556
5534
|
self.throw_exactly_matched_exception(self.exceptions['exact'], code, feedback)
|