ccxt 4.3.20__py2.py3-none-any.whl → 4.3.21__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/binance.py +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/abstract/coinex.py +1 -1
- ccxt/abstract/okx.py +3 -0
- ccxt/ascendex.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +8 -2
- ccxt/async_support/bingx.py +1 -1
- ccxt/async_support/bitget.py +1 -1
- ccxt/async_support/bitmex.py +1 -0
- ccxt/async_support/coinex.py +139 -177
- ccxt/async_support/delta.py +1 -1
- ccxt/async_support/digifinex.py +1 -1
- ccxt/async_support/exmo.py +1 -1
- ccxt/async_support/gate.py +1 -1
- ccxt/async_support/hitbtc.py +1 -1
- ccxt/async_support/hyperliquid.py +25 -3
- ccxt/async_support/okx.py +4 -1
- ccxt/async_support/phemex.py +1 -1
- ccxt/base/exchange.py +2 -2
- ccxt/binance.py +8 -2
- ccxt/bingx.py +1 -1
- ccxt/bitget.py +1 -1
- ccxt/bitmex.py +1 -0
- ccxt/coinex.py +139 -177
- ccxt/delta.py +1 -1
- ccxt/digifinex.py +1 -1
- ccxt/exmo.py +1 -1
- ccxt/gate.py +1 -1
- ccxt/hitbtc.py +1 -1
- ccxt/hyperliquid.py +25 -3
- ccxt/okx.py +4 -1
- ccxt/phemex.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/kucoinfutures.py +89 -1
- ccxt/pro/woo.py +46 -22
- {ccxt-4.3.20.dist-info → ccxt-4.3.21.dist-info}/METADATA +4 -4
- {ccxt-4.3.20.dist-info → ccxt-4.3.21.dist-info}/RECORD +45 -45
- {ccxt-4.3.20.dist-info → ccxt-4.3.21.dist-info}/WHEEL +0 -0
- {ccxt-4.3.20.dist-info → ccxt-4.3.21.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/abstract/binance.py
CHANGED
@@ -465,6 +465,7 @@ class ImplicitAPI:
|
|
465
465
|
fapipublic_get_continuousklines = fapiPublicGetContinuousKlines = Entry('continuousKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
466
466
|
fapipublic_get_markpriceklines = fapiPublicGetMarkPriceKlines = Entry('markPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
467
467
|
fapipublic_get_indexpriceklines = fapiPublicGetIndexPriceKlines = Entry('indexPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
|
+
fapipublic_get_premiumindexklines = fapiPublicGetPremiumIndexKlines = Entry('premiumIndexKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
469
|
fapipublic_get_fundingrate = fapiPublicGetFundingRate = Entry('fundingRate', 'fapiPublic', 'GET', {'cost': 1})
|
469
470
|
fapipublic_get_fundinginfo = fapiPublicGetFundingInfo = Entry('fundingInfo', 'fapiPublic', 'GET', {'cost': 1})
|
470
471
|
fapipublic_get_premiumindex = fapiPublicGetPremiumIndex = Entry('premiumIndex', 'fapiPublic', 'GET', {'cost': 1})
|
ccxt/abstract/binancecoinm.py
CHANGED
@@ -465,6 +465,7 @@ class ImplicitAPI:
|
|
465
465
|
fapipublic_get_continuousklines = fapiPublicGetContinuousKlines = Entry('continuousKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
466
466
|
fapipublic_get_markpriceklines = fapiPublicGetMarkPriceKlines = Entry('markPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
467
467
|
fapipublic_get_indexpriceklines = fapiPublicGetIndexPriceKlines = Entry('indexPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
|
+
fapipublic_get_premiumindexklines = fapiPublicGetPremiumIndexKlines = Entry('premiumIndexKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
469
|
fapipublic_get_fundingrate = fapiPublicGetFundingRate = Entry('fundingRate', 'fapiPublic', 'GET', {'cost': 1})
|
469
470
|
fapipublic_get_fundinginfo = fapiPublicGetFundingInfo = Entry('fundingInfo', 'fapiPublic', 'GET', {'cost': 1})
|
470
471
|
fapipublic_get_premiumindex = fapiPublicGetPremiumIndex = Entry('premiumIndex', 'fapiPublic', 'GET', {'cost': 1})
|
ccxt/abstract/binanceus.py
CHANGED
@@ -517,6 +517,7 @@ class ImplicitAPI:
|
|
517
517
|
fapipublic_get_continuousklines = fapiPublicGetContinuousKlines = Entry('continuousKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
518
518
|
fapipublic_get_markpriceklines = fapiPublicGetMarkPriceKlines = Entry('markPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
519
519
|
fapipublic_get_indexpriceklines = fapiPublicGetIndexPriceKlines = Entry('indexPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
520
|
+
fapipublic_get_premiumindexklines = fapiPublicGetPremiumIndexKlines = Entry('premiumIndexKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
520
521
|
fapipublic_get_fundingrate = fapiPublicGetFundingRate = Entry('fundingRate', 'fapiPublic', 'GET', {'cost': 1})
|
521
522
|
fapipublic_get_fundinginfo = fapiPublicGetFundingInfo = Entry('fundingInfo', 'fapiPublic', 'GET', {'cost': 1})
|
522
523
|
fapipublic_get_premiumindex = fapiPublicGetPremiumIndex = Entry('premiumIndex', 'fapiPublic', 'GET', {'cost': 1})
|
ccxt/abstract/binanceusdm.py
CHANGED
@@ -465,6 +465,7 @@ class ImplicitAPI:
|
|
465
465
|
fapipublic_get_continuousklines = fapiPublicGetContinuousKlines = Entry('continuousKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
466
466
|
fapipublic_get_markpriceklines = fapiPublicGetMarkPriceKlines = Entry('markPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
467
467
|
fapipublic_get_indexpriceklines = fapiPublicGetIndexPriceKlines = Entry('indexPriceKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
|
+
fapipublic_get_premiumindexklines = fapiPublicGetPremiumIndexKlines = Entry('premiumIndexKlines', 'fapiPublic', 'GET', {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]})
|
468
469
|
fapipublic_get_fundingrate = fapiPublicGetFundingRate = Entry('fundingRate', 'fapiPublic', 'GET', {'cost': 1})
|
469
470
|
fapipublic_get_fundinginfo = fapiPublicGetFundingInfo = Entry('fundingInfo', 'fapiPublic', 'GET', {'cost': 1})
|
470
471
|
fapipublic_get_premiumindex = fapiPublicGetPremiumIndex = Entry('premiumIndex', 'fapiPublic', 'GET', {'cost': 1})
|
ccxt/abstract/coinex.py
CHANGED
@@ -125,7 +125,7 @@ class ImplicitAPI:
|
|
125
125
|
v1_perpetualprivate_post_order_cancel_by_client_id = v1PerpetualPrivatePostOrderCancelByClientId = Entry('order/cancel/by_client_id', ['v1', 'perpetualPrivate'], 'POST', {'cost': 20})
|
126
126
|
v1_perpetualprivate_post_order_cancel_stop_by_client_id = v1PerpetualPrivatePostOrderCancelStopByClientId = Entry('order/cancel_stop/by_client_id', ['v1', 'perpetualPrivate'], 'POST', {'cost': 20})
|
127
127
|
v1_perpetualprivate_post_market_preference = v1PerpetualPrivatePostMarketPreference = Entry('market/preference', ['v1', 'perpetualPrivate'], 'POST', {'cost': 20})
|
128
|
-
v2_public_get_maintain_info = v2PublicGetMaintainInfo = Entry('maintain
|
128
|
+
v2_public_get_maintain_info = v2PublicGetMaintainInfo = Entry('maintain/info', ['v2', 'public'], 'GET', {'cost': 1})
|
129
129
|
v2_public_get_ping = v2PublicGetPing = Entry('ping', ['v2', 'public'], 'GET', {'cost': 1})
|
130
130
|
v2_public_get_time = v2PublicGetTime = Entry('time', ['v2', 'public'], 'GET', {'cost': 1})
|
131
131
|
v2_public_get_spot_market = v2PublicGetSpotMarket = Entry('spot/market', ['v2', 'public'], 'GET', {'cost': 1})
|
ccxt/abstract/okx.py
CHANGED
@@ -59,6 +59,9 @@ class ImplicitAPI:
|
|
59
59
|
public_get_sprd_books = publicGetSprdBooks = Entry('sprd/books', 'public', 'GET', {'cost': 0.5})
|
60
60
|
public_get_sprd_ticker = publicGetSprdTicker = Entry('sprd/ticker', 'public', 'GET', {'cost': 1})
|
61
61
|
public_get_sprd_public_trades = publicGetSprdPublicTrades = Entry('sprd/public-trades', 'public', 'GET', {'cost': 0.2})
|
62
|
+
public_get_market_sprd_ticker = publicGetMarketSprdTicker = Entry('market/sprd-ticker', 'public', 'GET', {'cost': 2})
|
63
|
+
public_get_market_sprd_candles = publicGetMarketSprdCandles = Entry('market/sprd-candles', 'public', 'GET', {'cost': 2})
|
64
|
+
public_get_market_sprd_history_candles = publicGetMarketSprdHistoryCandles = Entry('market/sprd-history-candles', 'public', 'GET', {'cost': 2})
|
62
65
|
public_get_tradingbot_grid_ai_param = publicGetTradingBotGridAiParam = Entry('tradingBot/grid/ai-param', 'public', 'GET', {'cost': 1})
|
63
66
|
public_get_tradingbot_grid_min_investment = publicGetTradingBotGridMinInvestment = Entry('tradingBot/grid/min-investment', 'public', 'GET', {'cost': 1})
|
64
67
|
public_get_tradingbot_public_rsi_back_testing = publicGetTradingBotPublicRsiBackTesting = Entry('tradingBot/public/rsi-back-testing', 'public', 'GET', {'cost': 1})
|
ccxt/ascendex.py
CHANGED
@@ -2732,7 +2732,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
2732
2732
|
'type': type,
|
2733
2733
|
})
|
2734
2734
|
|
2735
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
2735
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
2736
2736
|
#
|
2737
2737
|
# addMargin/reduceMargin
|
2738
2738
|
#
|
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/ascendex.py
CHANGED
@@ -2732,7 +2732,7 @@ class ascendex(Exchange, ImplicitAPI):
|
|
2732
2732
|
'type': type,
|
2733
2733
|
})
|
2734
2734
|
|
2735
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
2735
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
2736
2736
|
#
|
2737
2737
|
# addMargin/reduceMargin
|
2738
2738
|
#
|
ccxt/async_support/binance.py
CHANGED
@@ -154,7 +154,7 @@ class binance(Exchange, ImplicitAPI):
|
|
154
154
|
'fetchPositions': True,
|
155
155
|
'fetchPositionsHistory': False,
|
156
156
|
'fetchPositionsRisk': True,
|
157
|
-
'fetchPremiumIndexOHLCV':
|
157
|
+
'fetchPremiumIndexOHLCV': True,
|
158
158
|
'fetchSettlementHistory': True,
|
159
159
|
'fetchStatus': True,
|
160
160
|
'fetchTicker': True,
|
@@ -803,6 +803,7 @@ class binance(Exchange, ImplicitAPI):
|
|
803
803
|
'continuousKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
|
804
804
|
'markPriceKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
|
805
805
|
'indexPriceKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
|
806
|
+
'premiumIndexKlines': {'cost': 1, 'byLimit': [[99, 1], [499, 2], [1000, 5], [10000, 10]]},
|
806
807
|
'fundingRate': 1,
|
807
808
|
'fundingInfo': 1,
|
808
809
|
'premiumIndex': 1,
|
@@ -4156,6 +4157,11 @@ class binance(Exchange, ImplicitAPI):
|
|
4156
4157
|
response = await self.dapiPublicGetIndexPriceKlines(self.extend(request, params))
|
4157
4158
|
else:
|
4158
4159
|
response = await self.fapiPublicGetIndexPriceKlines(self.extend(request, params))
|
4160
|
+
elif price == 'premiumIndex':
|
4161
|
+
if market['inverse']:
|
4162
|
+
response = await self.dapiPublicGetPremiumIndexKlines(self.extend(request, params))
|
4163
|
+
else:
|
4164
|
+
response = await self.fapiPublicGetPremiumIndexKlines(self.extend(request, params))
|
4159
4165
|
elif market['linear']:
|
4160
4166
|
response = await self.fapiPublicGetKlines(self.extend(request, params))
|
4161
4167
|
elif market['inverse']:
|
@@ -10357,7 +10363,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10357
10363
|
'code': code,
|
10358
10364
|
})
|
10359
10365
|
|
10360
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
10366
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
10361
10367
|
#
|
10362
10368
|
# add/reduce margin
|
10363
10369
|
#
|
ccxt/async_support/bingx.py
CHANGED
@@ -3437,7 +3437,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
3437
3437
|
#
|
3438
3438
|
return self.parse_margin_modification(response, market)
|
3439
3439
|
|
3440
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
3440
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
3441
3441
|
#
|
3442
3442
|
# {
|
3443
3443
|
# "code": 0,
|
ccxt/async_support/bitget.py
CHANGED
@@ -6479,7 +6479,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6479
6479
|
'type': type,
|
6480
6480
|
})
|
6481
6481
|
|
6482
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
6482
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
6483
6483
|
#
|
6484
6484
|
# addMargin/reduceMargin
|
6485
6485
|
#
|
ccxt/async_support/bitmex.py
CHANGED
@@ -253,6 +253,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
253
253
|
'orderQty is invalid': InvalidOrder,
|
254
254
|
'Invalid price': InvalidOrder,
|
255
255
|
'Invalid stopPx for ordType': InvalidOrder,
|
256
|
+
'Account is restricted': PermissionDenied, # {"error":{"message":"Account is restricted","name":"HTTPError"}}
|
256
257
|
},
|
257
258
|
'broad': {
|
258
259
|
'Signature not valid': AuthenticationError,
|
ccxt/async_support/coinex.py
CHANGED
@@ -308,7 +308,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
308
308
|
'v2': {
|
309
309
|
'public': {
|
310
310
|
'get': {
|
311
|
-
'maintain
|
311
|
+
'maintain/info': 1,
|
312
312
|
'ping': 1,
|
313
313
|
'time': 1,
|
314
314
|
'spot/market': 1,
|
@@ -3988,160 +3988,127 @@ class coinex(Exchange, ImplicitAPI):
|
|
3988
3988
|
async def modify_margin_helper(self, symbol: str, amount, addOrReduce, params={}):
|
3989
3989
|
await self.load_markets()
|
3990
3990
|
market = self.market(symbol)
|
3991
|
+
rawAmount = self.amount_to_precision(symbol, amount)
|
3992
|
+
requestAmount = rawAmount
|
3993
|
+
if addOrReduce == 'reduce':
|
3994
|
+
requestAmount = Precise.string_neg(rawAmount)
|
3991
3995
|
request = {
|
3992
3996
|
'market': market['id'],
|
3993
|
-
'
|
3994
|
-
'
|
3997
|
+
'market_type': 'FUTURES',
|
3998
|
+
'amount': requestAmount,
|
3995
3999
|
}
|
3996
|
-
response = await self.
|
4000
|
+
response = await self.v2PrivatePostFuturesAdjustPositionMargin(self.extend(request, params))
|
3997
4001
|
#
|
3998
4002
|
# {
|
3999
4003
|
# "code": 0,
|
4000
4004
|
# "data": {
|
4001
|
-
# "
|
4002
|
-
# "
|
4003
|
-
# "
|
4004
|
-
# "
|
4005
|
-
# "
|
4006
|
-
# "
|
4007
|
-
# "
|
4008
|
-
# "
|
4009
|
-
# "create_time": 1651202571.320778,
|
4010
|
-
# "deal_all": "19.72000000000000000000",
|
4011
|
-
# "deal_asset_fee": "0.00000000000000000000",
|
4012
|
-
# "fee_asset": "",
|
4013
|
-
# "finish_type": 1,
|
4014
|
-
# "first_price": "39441.12",
|
4015
|
-
# "insurance": "0.00000000000000000000",
|
4016
|
-
# "latest_price": "39441.12",
|
4005
|
+
# "adl_level": 1,
|
4006
|
+
# "ath_margin_size": "2.034928",
|
4007
|
+
# "ath_position_amount": "0.0001",
|
4008
|
+
# "avg_entry_price": "61047.84",
|
4009
|
+
# "bkr_price": "30698.5600000000000004142",
|
4010
|
+
# "close_avbl": "0.0001",
|
4011
|
+
# "cml_position_value": "6.104784",
|
4012
|
+
# "created_at": 1715488472908,
|
4017
4013
|
# "leverage": "3",
|
4018
|
-
# "
|
4019
|
-
# "
|
4020
|
-
# "
|
4021
|
-
# "
|
4022
|
-
# "
|
4023
|
-
# "liq_profit": "0.00000000000000000000",
|
4024
|
-
# "liq_time": 0,
|
4025
|
-
# "mainten_margin": "0.005",
|
4026
|
-
# "mainten_margin_amount": "0.09860280000000000000",
|
4027
|
-
# "maker_fee": "0.00000000000000000000",
|
4028
|
-
# "margin_amount": "11.57352000000000000000",
|
4014
|
+
# "liq_price": "30852.82412060301507579316",
|
4015
|
+
# "maintenance_margin_rate": "0.005",
|
4016
|
+
# "maintenance_margin_value": "0.03051465",
|
4017
|
+
# "margin_avbl": "3.034928",
|
4018
|
+
# "margin_mode": "isolated",
|
4029
4019
|
# "market": "BTCUSDT",
|
4030
|
-
# "
|
4031
|
-
# "
|
4032
|
-
# "
|
4033
|
-
# "
|
4034
|
-
# "
|
4035
|
-
# "
|
4036
|
-
# "
|
4037
|
-
# "
|
4038
|
-
# "
|
4039
|
-
# "
|
4040
|
-
# "
|
4041
|
-
# "
|
4042
|
-
# "
|
4043
|
-
# "
|
4044
|
-
# "
|
4045
|
-
# "taker_fee": "0.00000000000000000000",
|
4046
|
-
# "total": 3464,
|
4047
|
-
# "type": 1,
|
4048
|
-
# "update_time": 1651202638.911212,
|
4049
|
-
# "user_id": 3620173
|
4020
|
+
# "market_type": "FUTURES",
|
4021
|
+
# "max_position_value": "6.104784",
|
4022
|
+
# "open_interest": "0.0001",
|
4023
|
+
# "position_id": 306458800,
|
4024
|
+
# "position_margin_rate": "0.49713929272518077625",
|
4025
|
+
# "realized_pnl": "-0.003052392",
|
4026
|
+
# "settle_price": "61047.84",
|
4027
|
+
# "settle_value": "6.104784",
|
4028
|
+
# "side": "long",
|
4029
|
+
# "stop_loss_price": "0",
|
4030
|
+
# "stop_loss_type": "",
|
4031
|
+
# "take_profit_price": "0",
|
4032
|
+
# "take_profit_type": "",
|
4033
|
+
# "unrealized_pnl": "0",
|
4034
|
+
# "updated_at": 1715488805563
|
4050
4035
|
# },
|
4051
|
-
# "message":"OK"
|
4036
|
+
# "message": "OK"
|
4052
4037
|
# }
|
4053
4038
|
#
|
4054
4039
|
data = self.safe_dict(response, 'data')
|
4055
|
-
status = self.
|
4040
|
+
status = self.safe_string_lower(response, 'message')
|
4041
|
+
type = 'reduce' if (addOrReduce == 'reduce') else 'add'
|
4056
4042
|
return self.extend(self.parse_margin_modification(data, market), {
|
4043
|
+
'type': type,
|
4057
4044
|
'amount': self.parse_number(amount),
|
4058
4045
|
'status': status,
|
4059
4046
|
})
|
4060
4047
|
|
4061
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
4048
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
4062
4049
|
#
|
4063
4050
|
# addMargin/reduceMargin
|
4064
4051
|
#
|
4065
|
-
#
|
4066
|
-
#
|
4067
|
-
#
|
4068
|
-
#
|
4069
|
-
#
|
4070
|
-
#
|
4071
|
-
#
|
4072
|
-
#
|
4073
|
-
#
|
4074
|
-
#
|
4075
|
-
#
|
4076
|
-
#
|
4077
|
-
#
|
4078
|
-
#
|
4079
|
-
#
|
4080
|
-
#
|
4081
|
-
#
|
4082
|
-
#
|
4083
|
-
#
|
4084
|
-
#
|
4085
|
-
#
|
4086
|
-
#
|
4087
|
-
#
|
4088
|
-
#
|
4089
|
-
#
|
4090
|
-
#
|
4091
|
-
#
|
4092
|
-
#
|
4093
|
-
#
|
4094
|
-
#
|
4095
|
-
#
|
4096
|
-
#
|
4097
|
-
# "open_price": "39441.12000000000000000000",
|
4098
|
-
# "open_val": "19.72056000000000000000",
|
4099
|
-
# "open_val_max": "19.72056000000000000000",
|
4100
|
-
# "position_id": 65171206,
|
4101
|
-
# "profit_clearing": "-0.00986028000000000000",
|
4102
|
-
# "profit_real": "-0.00986028000000000000",
|
4103
|
-
# "profit_unreal": "0.00",
|
4104
|
-
# "side": 2,
|
4105
|
-
# "stop_loss_price": "0.00000000000000000000",
|
4106
|
-
# "stop_loss_type": 0,
|
4107
|
-
# "sy s": 0,
|
4108
|
-
# "take_profit_price": "0.00000000000000000000",
|
4109
|
-
# "take_profit_type": 0,
|
4110
|
-
# "taker_fee": "0.00000000000000000000",
|
4111
|
-
# "total": 3464,
|
4112
|
-
# "type": 1,
|
4113
|
-
# "update_time": 1651202638.911212,
|
4114
|
-
# "user_id": 3620173
|
4115
|
-
# }
|
4052
|
+
# {
|
4053
|
+
# "adl_level": 1,
|
4054
|
+
# "ath_margin_size": "2.034928",
|
4055
|
+
# "ath_position_amount": "0.0001",
|
4056
|
+
# "avg_entry_price": "61047.84",
|
4057
|
+
# "bkr_price": "30698.5600000000000004142",
|
4058
|
+
# "close_avbl": "0.0001",
|
4059
|
+
# "cml_position_value": "6.104784",
|
4060
|
+
# "created_at": 1715488472908,
|
4061
|
+
# "leverage": "3",
|
4062
|
+
# "liq_price": "30852.82412060301507579316",
|
4063
|
+
# "maintenance_margin_rate": "0.005",
|
4064
|
+
# "maintenance_margin_value": "0.03051465",
|
4065
|
+
# "margin_avbl": "3.034928",
|
4066
|
+
# "margin_mode": "isolated",
|
4067
|
+
# "market": "BTCUSDT",
|
4068
|
+
# "market_type": "FUTURES",
|
4069
|
+
# "max_position_value": "6.104784",
|
4070
|
+
# "open_interest": "0.0001",
|
4071
|
+
# "position_id": 306458800,
|
4072
|
+
# "position_margin_rate": "0.49713929272518077625",
|
4073
|
+
# "realized_pnl": "-0.003052392",
|
4074
|
+
# "settle_price": "61047.84",
|
4075
|
+
# "settle_value": "6.104784",
|
4076
|
+
# "side": "long",
|
4077
|
+
# "stop_loss_price": "0",
|
4078
|
+
# "stop_loss_type": "",
|
4079
|
+
# "take_profit_price": "0",
|
4080
|
+
# "take_profit_type": "",
|
4081
|
+
# "unrealized_pnl": "0",
|
4082
|
+
# "updated_at": 1715488805563
|
4083
|
+
# }
|
4116
4084
|
#
|
4117
4085
|
# fetchMarginAdjustmentHistory
|
4118
4086
|
#
|
4119
|
-
#
|
4120
|
-
#
|
4121
|
-
#
|
4122
|
-
#
|
4123
|
-
#
|
4124
|
-
#
|
4125
|
-
#
|
4126
|
-
#
|
4127
|
-
#
|
4128
|
-
#
|
4129
|
-
#
|
4130
|
-
#
|
4131
|
-
#
|
4132
|
-
#
|
4133
|
-
# }
|
4087
|
+
# {
|
4088
|
+
# "bkr_pirce": "24698.56000000000000005224",
|
4089
|
+
# "created_at": 1715489978697,
|
4090
|
+
# "leverage": "3",
|
4091
|
+
# "liq_price": "24822.67336683417085432386",
|
4092
|
+
# "margin_avbl": "3.634928",
|
4093
|
+
# "margin_change": "-1.5",
|
4094
|
+
# "margin_mode": "isolated",
|
4095
|
+
# "market": "BTCUSDT",
|
4096
|
+
# "market_type": "FUTURES",
|
4097
|
+
# "open_interest": "0.0001",
|
4098
|
+
# "position_id": 306458800,
|
4099
|
+
# "settle_price": "61047.84"
|
4100
|
+
# }
|
4134
4101
|
#
|
4135
4102
|
marketId = self.safe_string(data, 'market')
|
4136
|
-
|
4137
|
-
|
4103
|
+
timestamp = self.safe_integer_2(data, 'updated_at', 'created_at')
|
4104
|
+
change = self.safe_string(data, 'margin_change')
|
4138
4105
|
return {
|
4139
4106
|
'info': data,
|
4140
4107
|
'symbol': self.safe_symbol(marketId, market, None, 'swap'),
|
4141
|
-
'type':
|
4108
|
+
'type': None,
|
4142
4109
|
'marginMode': 'isolated',
|
4143
|
-
'amount': self.
|
4144
|
-
'total': self.safe_number(data, '
|
4110
|
+
'amount': self.parse_number(Precise.string_abs(change)),
|
4111
|
+
'total': self.safe_number(data, 'margin_avbl'),
|
4145
4112
|
'code': market['quote'],
|
4146
4113
|
'status': None,
|
4147
4114
|
'timestamp': timestamp,
|
@@ -4151,24 +4118,24 @@ class coinex(Exchange, ImplicitAPI):
|
|
4151
4118
|
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
4152
4119
|
"""
|
4153
4120
|
add margin
|
4154
|
-
:see: https://
|
4121
|
+
:see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
|
4155
4122
|
:param str symbol: unified market symbol
|
4156
4123
|
:param float amount: amount of margin to add
|
4157
4124
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4158
4125
|
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=add-margin-structure>`
|
4159
4126
|
"""
|
4160
|
-
return await self.modify_margin_helper(symbol, amount,
|
4127
|
+
return await self.modify_margin_helper(symbol, amount, 'add', params)
|
4161
4128
|
|
4162
4129
|
async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
4163
4130
|
"""
|
4164
4131
|
remove margin from a position
|
4165
|
-
:see: https://
|
4132
|
+
:see: https://docs.coinex.com/api/v2/futures/position/http/adjust-position-margin
|
4166
4133
|
:param str symbol: unified market symbol
|
4167
4134
|
:param float amount: the amount of margin to remove
|
4168
4135
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4169
4136
|
:returns dict: a `margin structure <https://docs.ccxt.com/#/?id=reduce-margin-structure>`
|
4170
4137
|
"""
|
4171
|
-
return await self.modify_margin_helper(symbol, amount,
|
4138
|
+
return await self.modify_margin_helper(symbol, amount, 'reduce', params)
|
4172
4139
|
|
4173
4140
|
async def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4174
4141
|
"""
|
@@ -5593,65 +5560,60 @@ class coinex(Exchange, ImplicitAPI):
|
|
5593
5560
|
async def fetch_margin_adjustment_history(self, symbol: Str = None, type: Str = None, since: Num = None, limit: Num = None, params={}) -> List[MarginModification]:
|
5594
5561
|
"""
|
5595
5562
|
fetches the history of margin added or reduced from contract isolated positions
|
5596
|
-
:see: https://
|
5597
|
-
:param str
|
5563
|
+
:see: https://docs.coinex.com/api/v2/futures/position/http/list-position-margin-history
|
5564
|
+
:param str symbol: unified market symbol
|
5598
5565
|
:param str [type]: not used by coinex fetchMarginAdjustmentHistory
|
5599
5566
|
:param int [since]: timestamp in ms of the earliest change to fetch
|
5600
|
-
:param int [limit]: the maximum amount of changes to fetch, default
|
5567
|
+
:param int [limit]: the maximum amount of changes to fetch, default is 10
|
5601
5568
|
:param dict params: extra parameters specific to the exchange api endpoint
|
5602
5569
|
:param int [params.until]: timestamp in ms of the latest change to fetch
|
5603
|
-
|
5604
|
-
* EXCHANGE SPECIFIC PARAMETERS
|
5605
|
-
:param int [params.offset]: offset
|
5570
|
+
:param int [params.positionId]: the id of the position that you want to retrieve margin adjustment history for
|
5606
5571
|
:returns dict[]: a list of `margin structures <https://docs.ccxt.com/#/?id=margin-loan-structure>`
|
5607
5572
|
"""
|
5608
5573
|
await self.load_markets()
|
5609
|
-
|
5610
|
-
|
5611
|
-
|
5612
|
-
|
5574
|
+
if symbol is None:
|
5575
|
+
raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a symbol argument')
|
5576
|
+
positionId = self.safe_integer_2(params, 'positionId', 'position_id')
|
5577
|
+
params = self.omit(params, 'positionId')
|
5578
|
+
if positionId is None:
|
5579
|
+
raise ArgumentsRequired(self.id + ' fetchMarginAdjustmentHistory() requires a positionId parameter')
|
5580
|
+
market = self.market(symbol)
|
5613
5581
|
request = {
|
5614
|
-
'market': '',
|
5615
|
-
'
|
5616
|
-
'
|
5617
|
-
'limit': limit,
|
5582
|
+
'market': market['id'],
|
5583
|
+
'market_type': 'FUTURES',
|
5584
|
+
'position_id': positionId,
|
5618
5585
|
}
|
5619
|
-
|
5620
|
-
market = self.market(symbol)
|
5621
|
-
request['market'] = market['id']
|
5586
|
+
request, params = self.handle_until_option('end_time', request, params)
|
5622
5587
|
if since is not None:
|
5623
5588
|
request['start_time'] = since
|
5624
|
-
if
|
5625
|
-
request['
|
5626
|
-
response = await self.
|
5589
|
+
if limit is not None:
|
5590
|
+
request['limit'] = limit
|
5591
|
+
response = await self.v2PrivateGetFuturesPositionMarginHistory(self.extend(request, params))
|
5627
5592
|
#
|
5628
|
-
#
|
5629
|
-
#
|
5630
|
-
#
|
5631
|
-
#
|
5632
|
-
#
|
5633
|
-
#
|
5634
|
-
#
|
5635
|
-
#
|
5636
|
-
#
|
5637
|
-
#
|
5638
|
-
#
|
5639
|
-
#
|
5640
|
-
#
|
5641
|
-
#
|
5642
|
-
#
|
5643
|
-
#
|
5644
|
-
#
|
5645
|
-
#
|
5646
|
-
#
|
5647
|
-
#
|
5648
|
-
#
|
5649
|
-
#
|
5650
|
-
#
|
5651
|
-
# message: 'OK'
|
5652
|
-
# }
|
5593
|
+
# {
|
5594
|
+
# "code": 0,
|
5595
|
+
# "data": [
|
5596
|
+
# {
|
5597
|
+
# "bkr_pirce": "24698.56000000000000005224",
|
5598
|
+
# "created_at": 1715489978697,
|
5599
|
+
# "leverage": "3",
|
5600
|
+
# "liq_price": "24822.67336683417085432386",
|
5601
|
+
# "margin_avbl": "3.634928",
|
5602
|
+
# "margin_change": "-1.5",
|
5603
|
+
# "margin_mode": "isolated",
|
5604
|
+
# "market": "BTCUSDT",
|
5605
|
+
# "market_type": "FUTURES",
|
5606
|
+
# "open_interest": "0.0001",
|
5607
|
+
# "position_id": 306458800,
|
5608
|
+
# "settle_price": "61047.84"
|
5609
|
+
# },
|
5610
|
+
# ],
|
5611
|
+
# "message": "OK",
|
5612
|
+
# "pagination": {
|
5613
|
+
# "has_next": True
|
5614
|
+
# }
|
5615
|
+
# }
|
5653
5616
|
#
|
5654
|
-
data = self.
|
5655
|
-
|
5656
|
-
modifications = self.parse_margin_modifications(records, None, 'market', 'swap')
|
5617
|
+
data = self.safe_list(response, 'data', [])
|
5618
|
+
modifications = self.parse_margin_modifications(data, None, 'market', 'swap')
|
5657
5619
|
return self.filter_by_symbol_since_limit(modifications, symbol, since, limit)
|
ccxt/async_support/delta.py
CHANGED
@@ -2539,7 +2539,7 @@ class delta(Exchange, ImplicitAPI):
|
|
2539
2539
|
result = self.safe_dict(response, 'result', {})
|
2540
2540
|
return self.parse_margin_modification(result, market)
|
2541
2541
|
|
2542
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
2542
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
2543
2543
|
#
|
2544
2544
|
# {
|
2545
2545
|
# "auto_topup": False,
|
ccxt/async_support/digifinex.py
CHANGED
@@ -3792,7 +3792,7 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3792
3792
|
'status': status,
|
3793
3793
|
})
|
3794
3794
|
|
3795
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
3795
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
3796
3796
|
#
|
3797
3797
|
# {
|
3798
3798
|
# "instrument_id": "BTCUSDTPERP",
|
ccxt/async_support/exmo.py
CHANGED
@@ -270,7 +270,7 @@ class exmo(Exchange, ImplicitAPI):
|
|
270
270
|
margin['amount'] = amount
|
271
271
|
return margin
|
272
272
|
|
273
|
-
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
273
|
+
def parse_margin_modification(self, data: dict, market: Market = None) -> MarginModification:
|
274
274
|
#
|
275
275
|
# {}
|
276
276
|
#
|