ccxt 4.2.85__py2.py3-none-any.whl → 4.2.87__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.
- ccxt/__init__.py +1 -1
- ccxt/abstract/coinex.py +232 -123
- ccxt/ascendex.py +16 -6
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +16 -6
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +18 -5
- ccxt/async_support/bingx.py +72 -22
- ccxt/async_support/bitbank.py +19 -21
- ccxt/async_support/bitfinex.py +2 -0
- ccxt/async_support/bitfinex2.py +18 -4
- ccxt/async_support/bitflyer.py +18 -0
- ccxt/async_support/bitget.py +20 -6
- ccxt/async_support/bitopro.py +2 -0
- ccxt/async_support/bitrue.py +16 -8
- ccxt/async_support/bitvavo.py +2 -0
- ccxt/async_support/btcmarkets.py +1 -1
- ccxt/async_support/btcturk.py +2 -1
- ccxt/async_support/coinex.py +572 -306
- ccxt/async_support/currencycom.py +1 -1
- ccxt/async_support/delta.py +8 -6
- ccxt/async_support/digifinex.py +9 -7
- ccxt/async_support/exmo.py +15 -15
- ccxt/async_support/gate.py +9 -6
- ccxt/async_support/hitbtc.py +31 -7
- ccxt/async_support/htx.py +2 -2
- ccxt/async_support/huobijp.py +1 -1
- ccxt/async_support/hyperliquid.py +242 -16
- ccxt/async_support/idex.py +11 -11
- ccxt/async_support/krakenfutures.py +2 -4
- ccxt/async_support/kucoinfutures.py +2 -2
- ccxt/async_support/lbank.py +2 -0
- ccxt/async_support/mexc.py +3 -3
- ccxt/async_support/oceanex.py +1 -1
- ccxt/async_support/okcoin.py +2 -1
- ccxt/async_support/okx.py +29 -15
- ccxt/async_support/phemex.py +6 -4
- ccxt/async_support/wazirx.py +1 -1
- ccxt/async_support/zonda.py +2 -0
- ccxt/base/exchange.py +1 -1
- ccxt/base/types.py +12 -0
- ccxt/binance.py +18 -5
- ccxt/bingx.py +72 -22
- ccxt/bitbank.py +19 -21
- ccxt/bitfinex.py +2 -0
- ccxt/bitfinex2.py +18 -4
- ccxt/bitflyer.py +18 -0
- ccxt/bitget.py +20 -6
- ccxt/bitopro.py +2 -0
- ccxt/bitrue.py +16 -8
- ccxt/bitvavo.py +2 -0
- ccxt/btcmarkets.py +1 -1
- ccxt/btcturk.py +2 -1
- ccxt/coinex.py +572 -306
- ccxt/currencycom.py +1 -1
- ccxt/delta.py +8 -6
- ccxt/digifinex.py +9 -7
- ccxt/exmo.py +15 -15
- ccxt/gate.py +9 -6
- ccxt/hitbtc.py +31 -7
- ccxt/htx.py +2 -2
- ccxt/huobijp.py +1 -1
- ccxt/hyperliquid.py +241 -16
- ccxt/idex.py +11 -11
- ccxt/krakenfutures.py +2 -4
- ccxt/kucoinfutures.py +2 -2
- ccxt/lbank.py +2 -0
- ccxt/mexc.py +3 -3
- ccxt/oceanex.py +1 -1
- ccxt/okcoin.py +2 -1
- ccxt/okx.py +29 -15
- ccxt/phemex.py +6 -4
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +1 -0
- ccxt/pro/kucoin.py +10 -6
- ccxt/test/base/test_last_price.py +0 -1
- ccxt/test/base/test_shared_methods.py +1 -2
- ccxt/test/base/test_status.py +1 -1
- ccxt/wazirx.py +1 -1
- ccxt/zonda.py +2 -0
- {ccxt-4.2.85.dist-info → ccxt-4.2.87.dist-info}/METADATA +6 -6
- {ccxt-4.2.85.dist-info → ccxt-4.2.87.dist-info}/RECORD +84 -84
- {ccxt-4.2.85.dist-info → ccxt-4.2.87.dist-info}/WHEEL +0 -0
- {ccxt-4.2.85.dist-info → ccxt-4.2.87.dist-info}/top_level.txt +0 -0
ccxt/async_support/zonda.py
CHANGED
@@ -1181,6 +1181,8 @@ class zonda(Exchange, ImplicitAPI):
|
|
1181
1181
|
}
|
1182
1182
|
if limit is None:
|
1183
1183
|
limit = 100
|
1184
|
+
else:
|
1185
|
+
limit = min(limit, 11000) # supports up to 11k candles diapason
|
1184
1186
|
duration = self.parse_timeframe(timeframe)
|
1185
1187
|
timerange = limit * duration * 1000
|
1186
1188
|
if since is None:
|
ccxt/base/exchange.py
CHANGED
ccxt/base/types.py
CHANGED
@@ -324,6 +324,7 @@ class Option(TypedDict):
|
|
324
324
|
|
325
325
|
OptionChain = Dict[str, Option]
|
326
326
|
|
327
|
+
|
327
328
|
class MarketInterface(TypedDict):
|
328
329
|
info: Dict[str, Any]
|
329
330
|
id: Str
|
@@ -375,6 +376,17 @@ class LastPrice(TypedDict):
|
|
375
376
|
info: Dict[str, Any]
|
376
377
|
|
377
378
|
|
379
|
+
class MarginModification(TypedDict):
|
380
|
+
info: Dict[str, any]
|
381
|
+
symbol: str
|
382
|
+
type: Optional[Literal['add', 'reduce', 'set']]
|
383
|
+
amount: Optional[float]
|
384
|
+
code: Str
|
385
|
+
status: Str
|
386
|
+
timestamp: Int
|
387
|
+
datetime: Str
|
388
|
+
|
389
|
+
|
378
390
|
LastPrices = Dict[Str, LastPrice]
|
379
391
|
|
380
392
|
Market = Optional[MarketInterface]
|
ccxt/binance.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.binance import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Currency, Greeks, Int, Leverage, Leverages, MarginMode, MarginModes, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import PermissionDenied
|
@@ -10312,7 +10312,17 @@ class binance(Exchange, ImplicitAPI):
|
|
10312
10312
|
'code': code,
|
10313
10313
|
})
|
10314
10314
|
|
10315
|
-
def parse_margin_modification(self, data, market: Market = None):
|
10315
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
10316
|
+
#
|
10317
|
+
# add/reduce margin
|
10318
|
+
#
|
10319
|
+
# {
|
10320
|
+
# "code": 200,
|
10321
|
+
# "msg": "Successfully modify position margin.",
|
10322
|
+
# "amount": 0.001,
|
10323
|
+
# "type": 1
|
10324
|
+
# }
|
10325
|
+
#
|
10316
10326
|
rawType = self.safe_integer(data, 'type')
|
10317
10327
|
resultType = 'add' if (rawType == 1) else 'reduce'
|
10318
10328
|
resultAmount = self.safe_number(data, 'amount')
|
@@ -10320,14 +10330,17 @@ class binance(Exchange, ImplicitAPI):
|
|
10320
10330
|
status = 'ok' if (errorCode == '200') else 'failed'
|
10321
10331
|
return {
|
10322
10332
|
'info': data,
|
10333
|
+
'symbol': market['symbol'],
|
10323
10334
|
'type': resultType,
|
10324
10335
|
'amount': resultAmount,
|
10336
|
+
'total': None,
|
10325
10337
|
'code': None,
|
10326
|
-
'symbol': market['symbol'],
|
10327
10338
|
'status': status,
|
10339
|
+
'timestamp': None,
|
10340
|
+
'datetime': None,
|
10328
10341
|
}
|
10329
10342
|
|
10330
|
-
def reduce_margin(self, symbol: str, amount, params={}):
|
10343
|
+
def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
10331
10344
|
"""
|
10332
10345
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
|
10333
10346
|
:see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
|
@@ -10339,7 +10352,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10339
10352
|
"""
|
10340
10353
|
return self.modify_margin_helper(symbol, amount, 2, params)
|
10341
10354
|
|
10342
|
-
def add_margin(self, symbol: str, amount, params={}):
|
10355
|
+
def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
10343
10356
|
"""
|
10344
10357
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
|
10345
10358
|
:see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
|
ccxt/bingx.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bingx import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import numbers
|
10
|
-
from ccxt.base.types import Balances, Currency, Int, Leverage, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Currency, Int, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import PermissionDenied
|
@@ -43,6 +43,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
43
43
|
'swap': True,
|
44
44
|
'future': False,
|
45
45
|
'option': False,
|
46
|
+
'addMargin': True,
|
46
47
|
'cancelAllOrders': True,
|
47
48
|
'cancelOrder': True,
|
48
49
|
'cancelOrders': True,
|
@@ -89,6 +90,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
89
90
|
'fetchTrades': True,
|
90
91
|
'fetchTransfers': True,
|
91
92
|
'fetchWithdrawals': True,
|
93
|
+
'reduceMargin': True,
|
92
94
|
'setLeverage': True,
|
93
95
|
'setMargin': True,
|
94
96
|
'setMarginMode': True,
|
@@ -630,7 +632,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
630
632
|
if settle is not None:
|
631
633
|
symbol += ':' + settle
|
632
634
|
fees = self.safe_dict(self.fees, type, {})
|
633
|
-
contractSize = self.
|
635
|
+
contractSize = self.parse_number('1') if (swap) else None
|
634
636
|
isActive = self.safe_string(market, 'status') == '1'
|
635
637
|
isInverse = None if (spot) else False
|
636
638
|
isLinear = None if (spot) else swap
|
@@ -671,7 +673,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
671
673
|
'max': self.safe_integer(market, 'maxLongLeverage'),
|
672
674
|
},
|
673
675
|
'amount': {
|
674
|
-
'min': self.
|
676
|
+
'min': self.safe_number_2(market, 'minQty', 'tradeMinQuantity'),
|
675
677
|
'max': self.safe_number(market, 'maxQty'),
|
676
678
|
},
|
677
679
|
'price': {
|
@@ -679,7 +681,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
679
681
|
'max': None,
|
680
682
|
},
|
681
683
|
'cost': {
|
682
|
-
'min': self.
|
684
|
+
'min': self.safe_number_2(market, 'minNotional', 'tradeMinUSDT'),
|
683
685
|
'max': self.safe_number(market, 'maxNotional'),
|
684
686
|
},
|
685
687
|
},
|
@@ -1009,6 +1011,12 @@ class bingx(Exchange, ImplicitAPI):
|
|
1009
1011
|
isMaker = self.safe_bool(trade, 'isMaker')
|
1010
1012
|
if isMaker is not None:
|
1011
1013
|
takeOrMaker = 'maker' if isMaker else 'taker'
|
1014
|
+
amount = self.safe_string_n(trade, ['qty', 'amount', 'q'])
|
1015
|
+
if (market is not None) and market['swap'] and ('volume' in trade):
|
1016
|
+
# private trade returns num of contracts instead of base currency(as the order-related methods do)
|
1017
|
+
contractSize = self.safe_string(market['info'], 'tradeMinQuantity')
|
1018
|
+
volume = self.safe_string(trade, 'volume')
|
1019
|
+
amount = Precise.string_mul(volume, contractSize)
|
1012
1020
|
return self.safe_trade({
|
1013
1021
|
'id': self.safe_string_n(trade, ['id', 't']),
|
1014
1022
|
'info': trade,
|
@@ -1020,7 +1028,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1020
1028
|
'side': self.parse_order_side(side),
|
1021
1029
|
'takerOrMaker': takeOrMaker,
|
1022
1030
|
'price': self.safe_string_2(trade, 'price', 'p'),
|
1023
|
-
'amount':
|
1031
|
+
'amount': amount,
|
1024
1032
|
'cost': cost,
|
1025
1033
|
'fee': {
|
1026
1034
|
'cost': self.parse_number(Precise.string_abs(self.safe_string_2(trade, 'commission', 'n'))),
|
@@ -1607,19 +1615,27 @@ class bingx(Exchange, ImplicitAPI):
|
|
1607
1615
|
|
1608
1616
|
def parse_position(self, position, market: Market = None):
|
1609
1617
|
#
|
1610
|
-
#
|
1611
|
-
#
|
1612
|
-
#
|
1613
|
-
#
|
1614
|
-
#
|
1615
|
-
#
|
1616
|
-
#
|
1617
|
-
#
|
1618
|
-
#
|
1619
|
-
#
|
1620
|
-
#
|
1621
|
-
#
|
1622
|
-
#
|
1618
|
+
# {
|
1619
|
+
# "positionId":"1773122376147623936",
|
1620
|
+
# "symbol":"XRP-USDT",
|
1621
|
+
# "currency":"USDT",
|
1622
|
+
# "positionAmt":"3",
|
1623
|
+
# "availableAmt":"3",
|
1624
|
+
# "positionSide":"LONG",
|
1625
|
+
# "isolated":false,
|
1626
|
+
# "avgPrice":"0.6139",
|
1627
|
+
# "initialMargin":"0.0897",
|
1628
|
+
# "leverage":20,
|
1629
|
+
# "unrealizedProfit":"-0.0023",
|
1630
|
+
# "realisedProfit":"-0.0009",
|
1631
|
+
# "liquidationPrice":0,
|
1632
|
+
# "pnlRatio":"-0.0260",
|
1633
|
+
# "maxMarginReduction":"",
|
1634
|
+
# "riskRate":"",
|
1635
|
+
# "markPrice":"",
|
1636
|
+
# "positionValue":"",
|
1637
|
+
# "onlyOnePosition":false
|
1638
|
+
# }
|
1623
1639
|
#
|
1624
1640
|
# standard position
|
1625
1641
|
#
|
@@ -1645,7 +1661,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1645
1661
|
'info': position,
|
1646
1662
|
'id': self.safe_string(position, 'positionId'),
|
1647
1663
|
'symbol': self.safe_symbol(marketId, market, '-', 'swap'),
|
1648
|
-
'notional': self.safe_number(position, '
|
1664
|
+
'notional': self.safe_number(position, 'positionValue'),
|
1649
1665
|
'marginMode': marginMode,
|
1650
1666
|
'liquidationPrice': None,
|
1651
1667
|
'entryPrice': self.safe_number_2(position, 'avgPrice', 'entryPrice'),
|
@@ -1663,7 +1679,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1663
1679
|
'lastUpdateTimestamp': None,
|
1664
1680
|
'maintenanceMargin': None,
|
1665
1681
|
'maintenanceMarginPercentage': None,
|
1666
|
-
'collateral':
|
1682
|
+
'collateral': None,
|
1667
1683
|
'initialMargin': self.safe_number(position, 'initialMargin'),
|
1668
1684
|
'initialMarginPercentage': None,
|
1669
1685
|
'leverage': self.safe_number(position, 'leverage'),
|
@@ -3232,7 +3248,19 @@ class bingx(Exchange, ImplicitAPI):
|
|
3232
3248
|
}
|
3233
3249
|
return self.swapV2PrivatePostTradeMarginType(self.extend(request, params))
|
3234
3250
|
|
3235
|
-
def
|
3251
|
+
def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3252
|
+
request = {
|
3253
|
+
'type': 1,
|
3254
|
+
}
|
3255
|
+
return self.set_margin(symbol, amount, self.extend(request, params))
|
3256
|
+
|
3257
|
+
def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3258
|
+
request = {
|
3259
|
+
'type': 2,
|
3260
|
+
}
|
3261
|
+
return self.set_margin(symbol, amount, self.extend(request, params))
|
3262
|
+
|
3263
|
+
def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3236
3264
|
"""
|
3237
3265
|
Either adds or reduces margin in an isolated position in order to set the margin to a specific value
|
3238
3266
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Adjust%20isolated%20margin
|
@@ -3262,7 +3290,29 @@ class bingx(Exchange, ImplicitAPI):
|
|
3262
3290
|
# "type": 1
|
3263
3291
|
# }
|
3264
3292
|
#
|
3265
|
-
return response
|
3293
|
+
return self.parse_margin_modification(response, market)
|
3294
|
+
|
3295
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
3296
|
+
#
|
3297
|
+
# {
|
3298
|
+
# "code": 0,
|
3299
|
+
# "msg": "",
|
3300
|
+
# "amount": 1,
|
3301
|
+
# "type": 1
|
3302
|
+
# }
|
3303
|
+
#
|
3304
|
+
type = self.safe_string(data, 'type')
|
3305
|
+
return {
|
3306
|
+
'info': data,
|
3307
|
+
'symbol': self.safe_string(market, 'symbol'),
|
3308
|
+
'type': 'add' if (type == '1') else 'reduce',
|
3309
|
+
'amount': self.safe_number(data, 'amount'),
|
3310
|
+
'total': self.safe_number(data, 'margin'),
|
3311
|
+
'code': self.safe_string(market, 'settle'),
|
3312
|
+
'status': None,
|
3313
|
+
'timestamp': None,
|
3314
|
+
'datetime': None,
|
3315
|
+
}
|
3266
3316
|
|
3267
3317
|
def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
3268
3318
|
"""
|
ccxt/bitbank.py
CHANGED
@@ -146,21 +146,23 @@ class bitbank(Exchange, ImplicitAPI):
|
|
146
146
|
},
|
147
147
|
'precisionMode': TICK_SIZE,
|
148
148
|
'exceptions': {
|
149
|
-
'
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
149
|
+
'exact': {
|
150
|
+
'20001': AuthenticationError,
|
151
|
+
'20002': AuthenticationError,
|
152
|
+
'20003': AuthenticationError,
|
153
|
+
'20005': AuthenticationError,
|
154
|
+
'20004': InvalidNonce,
|
155
|
+
'40020': InvalidOrder,
|
156
|
+
'40021': InvalidOrder,
|
157
|
+
'40025': ExchangeError,
|
158
|
+
'40013': OrderNotFound,
|
159
|
+
'40014': OrderNotFound,
|
160
|
+
'50008': PermissionDenied,
|
161
|
+
'50009': OrderNotFound,
|
162
|
+
'50010': OrderNotFound,
|
163
|
+
'60001': InsufficientFunds,
|
164
|
+
'60005': InvalidOrder,
|
165
|
+
},
|
164
166
|
},
|
165
167
|
})
|
166
168
|
|
@@ -944,12 +946,8 @@ class bitbank(Exchange, ImplicitAPI):
|
|
944
946
|
'70009': 'We are currently temporarily restricting orders to be carried out. Please use the limit order.',
|
945
947
|
'70010': 'We are temporarily raising the minimum order quantity system load is now rising.',
|
946
948
|
}
|
947
|
-
errorClasses = self.exceptions
|
948
949
|
code = self.safe_string(data, 'code')
|
949
950
|
message = self.safe_string(errorMessages, code, 'Error')
|
950
|
-
|
951
|
-
|
952
|
-
raise errorClasses[code](message)
|
953
|
-
else:
|
954
|
-
raise ExchangeError(self.id + ' ' + self.json(response))
|
951
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], code, message)
|
952
|
+
raise ExchangeError(self.id + ' ' + self.json(response))
|
955
953
|
return None
|
ccxt/bitfinex.py
CHANGED
ccxt/bitfinex2.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitfinex2 import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import PermissionDenied
|
@@ -1343,6 +1343,8 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1343
1343
|
market = self.market(symbol)
|
1344
1344
|
if limit is None:
|
1345
1345
|
limit = 10000
|
1346
|
+
else:
|
1347
|
+
limit = min(limit, 10000)
|
1346
1348
|
request = {
|
1347
1349
|
'symbol': market['id'],
|
1348
1350
|
'timeframe': self.safe_string(self.timeframes, timeframe, timeframe),
|
@@ -3279,7 +3281,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3279
3281
|
'datetime': self.iso8601(timestamp),
|
3280
3282
|
})
|
3281
3283
|
|
3282
|
-
def set_margin(self, symbol: str, amount: float, params={}):
|
3284
|
+
def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3283
3285
|
"""
|
3284
3286
|
either adds or reduces margin in a swap position in order to set the margin to a specific value
|
3285
3287
|
:see: https://docs.bitfinex.com/reference/rest-auth-deriv-pos-collateral-set
|
@@ -3307,16 +3309,28 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3307
3309
|
data = self.safe_value(response, 0)
|
3308
3310
|
return self.parse_margin_modification(data, market)
|
3309
3311
|
|
3310
|
-
def parse_margin_modification(self, data, market=None):
|
3312
|
+
def parse_margin_modification(self, data, market=None) -> MarginModification:
|
3313
|
+
#
|
3314
|
+
# setMargin
|
3315
|
+
#
|
3316
|
+
# [
|
3317
|
+
# [
|
3318
|
+
# 1
|
3319
|
+
# ]
|
3320
|
+
# ]
|
3321
|
+
#
|
3311
3322
|
marginStatusRaw = data[0]
|
3312
3323
|
marginStatus = 'ok' if (marginStatusRaw == 1) else 'failed'
|
3313
3324
|
return {
|
3314
3325
|
'info': data,
|
3326
|
+
'symbol': market['symbol'],
|
3315
3327
|
'type': None,
|
3316
3328
|
'amount': None,
|
3329
|
+
'total': None,
|
3317
3330
|
'code': None,
|
3318
|
-
'symbol': market['symbol'],
|
3319
3331
|
'status': marginStatus,
|
3332
|
+
'timestamp': None,
|
3333
|
+
'datetime': None,
|
3320
3334
|
}
|
3321
3335
|
|
3322
3336
|
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
ccxt/bitflyer.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 ArgumentsRequired
|
13
13
|
from ccxt.base.errors import OrderNotFound
|
14
|
+
from ccxt.base.errors import OnMaintenance
|
14
15
|
from ccxt.base.decimal_to_precision import TICK_SIZE
|
15
16
|
from ccxt.base.precise import Precise
|
16
17
|
|
@@ -118,6 +119,11 @@ class bitflyer(Exchange, ImplicitAPI):
|
|
118
119
|
},
|
119
120
|
},
|
120
121
|
'precisionMode': TICK_SIZE,
|
122
|
+
'exceptions': {
|
123
|
+
'exact': {
|
124
|
+
'-2': OnMaintenance, # {"status":-2,"error_message":"Under maintenance","data":null}
|
125
|
+
},
|
126
|
+
},
|
121
127
|
})
|
122
128
|
|
123
129
|
def parse_expiry_date(self, expiry):
|
@@ -973,3 +979,15 @@ class bitflyer(Exchange, ImplicitAPI):
|
|
973
979
|
'Content-Type': 'application/json',
|
974
980
|
}
|
975
981
|
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
982
|
+
|
983
|
+
def handle_errors(self, code, reason, url, method, headers, body, response, requestHeaders, requestBody):
|
984
|
+
if response is None:
|
985
|
+
return None # fallback to the default error handler
|
986
|
+
feedback = self.id + ' ' + body
|
987
|
+
# i.e. {"status":-2,"error_message":"Under maintenance","data":null}
|
988
|
+
errorMessage = self.safe_string(response, 'error_message')
|
989
|
+
statusCode = self.safe_number(response, 'status')
|
990
|
+
if errorMessage is not None:
|
991
|
+
self.throw_exactly_matched_exception(self.exceptions['exact'], statusCode, feedback)
|
992
|
+
self.throw_broadly_matched_exception(self.exceptions['broad'], errorMessage, feedback)
|
993
|
+
return None
|
ccxt/bitget.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitget import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Currency, FundingHistory, Int,
|
10
|
+
from ccxt.base.types import Balances, Currency, FundingHistory, Int, Liquidation, Leverage, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import PermissionDenied
|
@@ -1240,6 +1240,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
1240
1240
|
'40768': OrderNotFound, # Order does not exist"
|
1241
1241
|
'41114': OnMaintenance, # {"code":"41114","msg":"The current trading pair is under maintenance, please refer to the official announcement for the opening time","requestTime":1679196062544,"data":null}
|
1242
1242
|
'43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
|
1243
|
+
'43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
|
1243
1244
|
'43025': InvalidOrder, # Plan order does not exist
|
1244
1245
|
'43115': OnMaintenance, # {"code":"43115","msg":"The current trading pair is opening soon, please refer to the official announcement for the opening time","requestTime":1688907202434,"data":null}
|
1245
1246
|
'45110': InvalidOrder, # {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1669911118932,"data":null}
|
@@ -6427,7 +6428,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6427
6428
|
sorted = self.sort_by(result, 'timestamp')
|
6428
6429
|
return self.filter_by_since_limit(sorted, since, limit)
|
6429
6430
|
|
6430
|
-
def modify_margin_helper(self, symbol: str, amount, type, params={}):
|
6431
|
+
def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
6431
6432
|
self.load_markets()
|
6432
6433
|
holdSide = self.safe_string(params, 'holdSide')
|
6433
6434
|
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
@@ -6461,19 +6462,32 @@ class bitget(Exchange, ImplicitAPI):
|
|
6461
6462
|
'type': type,
|
6462
6463
|
})
|
6463
6464
|
|
6464
|
-
def parse_margin_modification(self, data, market: Market = None):
|
6465
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
6466
|
+
#
|
6467
|
+
# addMargin/reduceMargin
|
6468
|
+
#
|
6469
|
+
# {
|
6470
|
+
# "code": "00000",
|
6471
|
+
# "msg": "success",
|
6472
|
+
# "requestTime": 1700813444618,
|
6473
|
+
# "data": ""
|
6474
|
+
# }
|
6475
|
+
#
|
6465
6476
|
errorCode = self.safe_string(data, 'code')
|
6466
6477
|
status = 'ok' if (errorCode == '00000') else 'failed'
|
6467
6478
|
return {
|
6468
6479
|
'info': data,
|
6480
|
+
'symbol': market['symbol'],
|
6469
6481
|
'type': None,
|
6470
6482
|
'amount': None,
|
6483
|
+
'total': None,
|
6471
6484
|
'code': market['settle'],
|
6472
|
-
'symbol': market['symbol'],
|
6473
6485
|
'status': status,
|
6486
|
+
'timestamp': None,
|
6487
|
+
'datetime': None,
|
6474
6488
|
}
|
6475
6489
|
|
6476
|
-
def reduce_margin(self, symbol: str, amount, params={}):
|
6490
|
+
def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
6477
6491
|
"""
|
6478
6492
|
remove margin from a position
|
6479
6493
|
:see: https://www.bitget.com/api-doc/contract/account/Change-Margin
|
@@ -6489,7 +6503,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6489
6503
|
raise ArgumentsRequired(self.id + ' reduceMargin() requires a holdSide parameter, either long or short')
|
6490
6504
|
return self.modify_margin_helper(symbol, amount, 'reduce', params)
|
6491
6505
|
|
6492
|
-
def add_margin(self, symbol: str, amount, params={}):
|
6506
|
+
def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
6493
6507
|
"""
|
6494
6508
|
add margin
|
6495
6509
|
:see: https://www.bitget.com/api-doc/contract/account/Change-Margin
|
ccxt/bitopro.py
CHANGED
@@ -735,6 +735,8 @@ class bitopro(Exchange, ImplicitAPI):
|
|
735
735
|
# we need to have a limit argument because "to" and "from" are required
|
736
736
|
if limit is None:
|
737
737
|
limit = 500
|
738
|
+
else:
|
739
|
+
limit = min(limit, 75000) # supports slightly more than 75k candles atm, but limit here to avoid errors
|
738
740
|
timeframeInSeconds = self.parse_timeframe(timeframe)
|
739
741
|
alignedSince = None
|
740
742
|
if since is None:
|
ccxt/bitrue.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.bitrue import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import PermissionDenied
|
@@ -1310,8 +1310,6 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1310
1310
|
'interval': self.safe_string(timeframesFuture, timeframe, '1min'),
|
1311
1311
|
}
|
1312
1312
|
if limit is not None:
|
1313
|
-
if limit > 300:
|
1314
|
-
limit = 300
|
1315
1313
|
request['limit'] = limit
|
1316
1314
|
if market['linear']:
|
1317
1315
|
response = self.fapiV1PublicGetKlines(self.extend(request, params))
|
@@ -1326,8 +1324,6 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1326
1324
|
'scale': self.safe_string(timeframesSpot, timeframe, '1m'),
|
1327
1325
|
}
|
1328
1326
|
if limit is not None:
|
1329
|
-
if limit > 1440:
|
1330
|
-
limit = 1440
|
1331
1327
|
request['limit'] = limit
|
1332
1328
|
if since is not None:
|
1333
1329
|
request['fromIdx'] = since
|
@@ -2842,17 +2838,29 @@ class bitrue(Exchange, ImplicitAPI):
|
|
2842
2838
|
response = self.dapiV2PrivatePostLevelEdit(self.extend(request, params))
|
2843
2839
|
return response
|
2844
2840
|
|
2845
|
-
def parse_margin_modification(self, data, market=None):
|
2841
|
+
def parse_margin_modification(self, data, market=None) -> MarginModification:
|
2842
|
+
#
|
2843
|
+
# setMargin
|
2844
|
+
#
|
2845
|
+
# {
|
2846
|
+
# "code": 0,
|
2847
|
+
# "msg": "success"
|
2848
|
+
# "data": null
|
2849
|
+
# }
|
2850
|
+
#
|
2846
2851
|
return {
|
2847
2852
|
'info': data,
|
2853
|
+
'symbol': market['symbol'],
|
2848
2854
|
'type': None,
|
2849
2855
|
'amount': None,
|
2856
|
+
'total': None,
|
2850
2857
|
'code': None,
|
2851
|
-
'symbol': market['symbol'],
|
2852
2858
|
'status': None,
|
2859
|
+
'timestamp': None,
|
2860
|
+
'datetime': None,
|
2853
2861
|
}
|
2854
2862
|
|
2855
|
-
def set_margin(self, symbol: str, amount: float, params={}):
|
2863
|
+
def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
2856
2864
|
"""
|
2857
2865
|
Either adds or reduces margin in an isolated position in order to set the margin to a specific value
|
2858
2866
|
:see: https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
|
ccxt/bitvavo.py
CHANGED
@@ -923,6 +923,8 @@ class bitvavo(Exchange, ImplicitAPI):
|
|
923
923
|
request['start'] = since
|
924
924
|
if limit is None:
|
925
925
|
limit = 1440
|
926
|
+
else:
|
927
|
+
limit = min(limit, 1440)
|
926
928
|
request['end'] = self.sum(since, limit * duration * 1000)
|
927
929
|
request, params = self.handle_until_option('end', request, params)
|
928
930
|
if limit is not None:
|
ccxt/btcmarkets.py
CHANGED
@@ -522,7 +522,7 @@ class btcmarkets(Exchange, ImplicitAPI):
|
|
522
522
|
if since is not None:
|
523
523
|
request['from'] = self.iso8601(since)
|
524
524
|
if limit is not None:
|
525
|
-
request['limit'] = limit # default is 10, max 200
|
525
|
+
request['limit'] = min(limit, 200) # default is 10, max 200
|
526
526
|
response = self.publicGetMarketsMarketIdCandles(self.extend(request, params))
|
527
527
|
#
|
528
528
|
# [
|
ccxt/btcturk.py
CHANGED
@@ -570,6 +570,7 @@ class btcturk(Exchange, ImplicitAPI):
|
|
570
570
|
elif limit is None: # since will also be None
|
571
571
|
limit = 100 # default value
|
572
572
|
if limit is not None:
|
573
|
+
limit = min(limit, 11000) # max 11000 candles diapason can be covered
|
573
574
|
if timeframe == '1y': # difficult with leap years
|
574
575
|
raise BadRequest(self.id + ' fetchOHLCV() does not accept a limit parameter when timeframe == "1y"')
|
575
576
|
seconds = self.parse_timeframe(timeframe)
|
@@ -578,7 +579,7 @@ class btcturk(Exchange, ImplicitAPI):
|
|
578
579
|
to = self.parse_to_int(since / 1000) + limitSeconds
|
579
580
|
request['to'] = min(request['to'], to)
|
580
581
|
else:
|
581
|
-
request['from'] = self.parse_to_int(
|
582
|
+
request['from'] = self.parse_to_int(0 / 1000) - limitSeconds
|
582
583
|
response = self.graphGetKlinesHistory(self.extend(request, params))
|
583
584
|
#
|
584
585
|
# {
|