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/binance.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.binance import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
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
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import PermissionDenied
|
@@ -10313,7 +10313,17 @@ class binance(Exchange, ImplicitAPI):
|
|
10313
10313
|
'code': code,
|
10314
10314
|
})
|
10315
10315
|
|
10316
|
-
def parse_margin_modification(self, data, market: Market = None):
|
10316
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
10317
|
+
#
|
10318
|
+
# add/reduce margin
|
10319
|
+
#
|
10320
|
+
# {
|
10321
|
+
# "code": 200,
|
10322
|
+
# "msg": "Successfully modify position margin.",
|
10323
|
+
# "amount": 0.001,
|
10324
|
+
# "type": 1
|
10325
|
+
# }
|
10326
|
+
#
|
10317
10327
|
rawType = self.safe_integer(data, 'type')
|
10318
10328
|
resultType = 'add' if (rawType == 1) else 'reduce'
|
10319
10329
|
resultAmount = self.safe_number(data, 'amount')
|
@@ -10321,14 +10331,17 @@ class binance(Exchange, ImplicitAPI):
|
|
10321
10331
|
status = 'ok' if (errorCode == '200') else 'failed'
|
10322
10332
|
return {
|
10323
10333
|
'info': data,
|
10334
|
+
'symbol': market['symbol'],
|
10324
10335
|
'type': resultType,
|
10325
10336
|
'amount': resultAmount,
|
10337
|
+
'total': None,
|
10326
10338
|
'code': None,
|
10327
|
-
'symbol': market['symbol'],
|
10328
10339
|
'status': status,
|
10340
|
+
'timestamp': None,
|
10341
|
+
'datetime': None,
|
10329
10342
|
}
|
10330
10343
|
|
10331
|
-
async def reduce_margin(self, symbol: str, amount, params={}):
|
10344
|
+
async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
10332
10345
|
"""
|
10333
10346
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
|
10334
10347
|
:see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
|
@@ -10340,7 +10353,7 @@ class binance(Exchange, ImplicitAPI):
|
|
10340
10353
|
"""
|
10341
10354
|
return await self.modify_margin_helper(symbol, amount, 2, params)
|
10342
10355
|
|
10343
|
-
async def add_margin(self, symbol: str, amount, params={}):
|
10356
|
+
async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
10344
10357
|
"""
|
10345
10358
|
:see: https://binance-docs.github.io/apidocs/delivery/en/#modify-isolated-position-margin-trade
|
10346
10359
|
:see: https://binance-docs.github.io/apidocs/futures/en/#modify-isolated-position-margin-trade
|
ccxt/async_support/bingx.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.bingx import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import numbers
|
11
|
-
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
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import PermissionDenied
|
@@ -44,6 +44,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
44
44
|
'swap': True,
|
45
45
|
'future': False,
|
46
46
|
'option': False,
|
47
|
+
'addMargin': True,
|
47
48
|
'cancelAllOrders': True,
|
48
49
|
'cancelOrder': True,
|
49
50
|
'cancelOrders': True,
|
@@ -90,6 +91,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
90
91
|
'fetchTrades': True,
|
91
92
|
'fetchTransfers': True,
|
92
93
|
'fetchWithdrawals': True,
|
94
|
+
'reduceMargin': True,
|
93
95
|
'setLeverage': True,
|
94
96
|
'setMargin': True,
|
95
97
|
'setMarginMode': True,
|
@@ -631,7 +633,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
631
633
|
if settle is not None:
|
632
634
|
symbol += ':' + settle
|
633
635
|
fees = self.safe_dict(self.fees, type, {})
|
634
|
-
contractSize = self.
|
636
|
+
contractSize = self.parse_number('1') if (swap) else None
|
635
637
|
isActive = self.safe_string(market, 'status') == '1'
|
636
638
|
isInverse = None if (spot) else False
|
637
639
|
isLinear = None if (spot) else swap
|
@@ -672,7 +674,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
672
674
|
'max': self.safe_integer(market, 'maxLongLeverage'),
|
673
675
|
},
|
674
676
|
'amount': {
|
675
|
-
'min': self.
|
677
|
+
'min': self.safe_number_2(market, 'minQty', 'tradeMinQuantity'),
|
676
678
|
'max': self.safe_number(market, 'maxQty'),
|
677
679
|
},
|
678
680
|
'price': {
|
@@ -680,7 +682,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
680
682
|
'max': None,
|
681
683
|
},
|
682
684
|
'cost': {
|
683
|
-
'min': self.
|
685
|
+
'min': self.safe_number_2(market, 'minNotional', 'tradeMinUSDT'),
|
684
686
|
'max': self.safe_number(market, 'maxNotional'),
|
685
687
|
},
|
686
688
|
},
|
@@ -1010,6 +1012,12 @@ class bingx(Exchange, ImplicitAPI):
|
|
1010
1012
|
isMaker = self.safe_bool(trade, 'isMaker')
|
1011
1013
|
if isMaker is not None:
|
1012
1014
|
takeOrMaker = 'maker' if isMaker else 'taker'
|
1015
|
+
amount = self.safe_string_n(trade, ['qty', 'amount', 'q'])
|
1016
|
+
if (market is not None) and market['swap'] and ('volume' in trade):
|
1017
|
+
# private trade returns num of contracts instead of base currency(as the order-related methods do)
|
1018
|
+
contractSize = self.safe_string(market['info'], 'tradeMinQuantity')
|
1019
|
+
volume = self.safe_string(trade, 'volume')
|
1020
|
+
amount = Precise.string_mul(volume, contractSize)
|
1013
1021
|
return self.safe_trade({
|
1014
1022
|
'id': self.safe_string_n(trade, ['id', 't']),
|
1015
1023
|
'info': trade,
|
@@ -1021,7 +1029,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1021
1029
|
'side': self.parse_order_side(side),
|
1022
1030
|
'takerOrMaker': takeOrMaker,
|
1023
1031
|
'price': self.safe_string_2(trade, 'price', 'p'),
|
1024
|
-
'amount':
|
1032
|
+
'amount': amount,
|
1025
1033
|
'cost': cost,
|
1026
1034
|
'fee': {
|
1027
1035
|
'cost': self.parse_number(Precise.string_abs(self.safe_string_2(trade, 'commission', 'n'))),
|
@@ -1608,19 +1616,27 @@ class bingx(Exchange, ImplicitAPI):
|
|
1608
1616
|
|
1609
1617
|
def parse_position(self, position, market: Market = None):
|
1610
1618
|
#
|
1611
|
-
#
|
1612
|
-
#
|
1613
|
-
#
|
1614
|
-
#
|
1615
|
-
#
|
1616
|
-
#
|
1617
|
-
#
|
1618
|
-
#
|
1619
|
-
#
|
1620
|
-
#
|
1621
|
-
#
|
1622
|
-
#
|
1623
|
-
#
|
1619
|
+
# {
|
1620
|
+
# "positionId":"1773122376147623936",
|
1621
|
+
# "symbol":"XRP-USDT",
|
1622
|
+
# "currency":"USDT",
|
1623
|
+
# "positionAmt":"3",
|
1624
|
+
# "availableAmt":"3",
|
1625
|
+
# "positionSide":"LONG",
|
1626
|
+
# "isolated":false,
|
1627
|
+
# "avgPrice":"0.6139",
|
1628
|
+
# "initialMargin":"0.0897",
|
1629
|
+
# "leverage":20,
|
1630
|
+
# "unrealizedProfit":"-0.0023",
|
1631
|
+
# "realisedProfit":"-0.0009",
|
1632
|
+
# "liquidationPrice":0,
|
1633
|
+
# "pnlRatio":"-0.0260",
|
1634
|
+
# "maxMarginReduction":"",
|
1635
|
+
# "riskRate":"",
|
1636
|
+
# "markPrice":"",
|
1637
|
+
# "positionValue":"",
|
1638
|
+
# "onlyOnePosition":false
|
1639
|
+
# }
|
1624
1640
|
#
|
1625
1641
|
# standard position
|
1626
1642
|
#
|
@@ -1646,7 +1662,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1646
1662
|
'info': position,
|
1647
1663
|
'id': self.safe_string(position, 'positionId'),
|
1648
1664
|
'symbol': self.safe_symbol(marketId, market, '-', 'swap'),
|
1649
|
-
'notional': self.safe_number(position, '
|
1665
|
+
'notional': self.safe_number(position, 'positionValue'),
|
1650
1666
|
'marginMode': marginMode,
|
1651
1667
|
'liquidationPrice': None,
|
1652
1668
|
'entryPrice': self.safe_number_2(position, 'avgPrice', 'entryPrice'),
|
@@ -1664,7 +1680,7 @@ class bingx(Exchange, ImplicitAPI):
|
|
1664
1680
|
'lastUpdateTimestamp': None,
|
1665
1681
|
'maintenanceMargin': None,
|
1666
1682
|
'maintenanceMarginPercentage': None,
|
1667
|
-
'collateral':
|
1683
|
+
'collateral': None,
|
1668
1684
|
'initialMargin': self.safe_number(position, 'initialMargin'),
|
1669
1685
|
'initialMarginPercentage': None,
|
1670
1686
|
'leverage': self.safe_number(position, 'leverage'),
|
@@ -3233,7 +3249,19 @@ class bingx(Exchange, ImplicitAPI):
|
|
3233
3249
|
}
|
3234
3250
|
return await self.swapV2PrivatePostTradeMarginType(self.extend(request, params))
|
3235
3251
|
|
3236
|
-
async def
|
3252
|
+
async def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3253
|
+
request = {
|
3254
|
+
'type': 1,
|
3255
|
+
}
|
3256
|
+
return await self.set_margin(symbol, amount, self.extend(request, params))
|
3257
|
+
|
3258
|
+
async def reduce_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3259
|
+
request = {
|
3260
|
+
'type': 2,
|
3261
|
+
}
|
3262
|
+
return await self.set_margin(symbol, amount, self.extend(request, params))
|
3263
|
+
|
3264
|
+
async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
3237
3265
|
"""
|
3238
3266
|
Either adds or reduces margin in an isolated position in order to set the margin to a specific value
|
3239
3267
|
:see: https://bingx-api.github.io/docs/#/swapV2/trade-api.html#Adjust%20isolated%20margin
|
@@ -3263,7 +3291,29 @@ class bingx(Exchange, ImplicitAPI):
|
|
3263
3291
|
# "type": 1
|
3264
3292
|
# }
|
3265
3293
|
#
|
3266
|
-
return response
|
3294
|
+
return self.parse_margin_modification(response, market)
|
3295
|
+
|
3296
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
3297
|
+
#
|
3298
|
+
# {
|
3299
|
+
# "code": 0,
|
3300
|
+
# "msg": "",
|
3301
|
+
# "amount": 1,
|
3302
|
+
# "type": 1
|
3303
|
+
# }
|
3304
|
+
#
|
3305
|
+
type = self.safe_string(data, 'type')
|
3306
|
+
return {
|
3307
|
+
'info': data,
|
3308
|
+
'symbol': self.safe_string(market, 'symbol'),
|
3309
|
+
'type': 'add' if (type == '1') else 'reduce',
|
3310
|
+
'amount': self.safe_number(data, 'amount'),
|
3311
|
+
'total': self.safe_number(data, 'margin'),
|
3312
|
+
'code': self.safe_string(market, 'settle'),
|
3313
|
+
'status': None,
|
3314
|
+
'timestamp': None,
|
3315
|
+
'datetime': None,
|
3316
|
+
}
|
3267
3317
|
|
3268
3318
|
async def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
3269
3319
|
"""
|
ccxt/async_support/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/async_support/bitfinex.py
CHANGED
ccxt/async_support/bitfinex2.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.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
|
-
async def set_margin(self, symbol: str, amount: float, params={}):
|
3284
|
+
async 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
|
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
ccxt/async_support/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/async_support/bitget.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.bitget import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import Balances, Currency, FundingHistory, Int,
|
11
|
+
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
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import PermissionDenied
|
@@ -1241,6 +1241,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
1241
1241
|
'40768': OrderNotFound, # Order does not exist"
|
1242
1242
|
'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}
|
1243
1243
|
'43011': InvalidOrder, # The parameter does not meet the specification executePrice <= 0
|
1244
|
+
'43012': InsufficientFunds, # {"code":"43012","msg":"Insufficient balance","requestTime":1711648951774,"data":null}
|
1244
1245
|
'43025': InvalidOrder, # Plan order does not exist
|
1245
1246
|
'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}
|
1246
1247
|
'45110': InvalidOrder, # {"code":"45110","msg":"less than the minimum amount 5 USDT","requestTime":1669911118932,"data":null}
|
@@ -6428,7 +6429,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6428
6429
|
sorted = self.sort_by(result, 'timestamp')
|
6429
6430
|
return self.filter_by_since_limit(sorted, since, limit)
|
6430
6431
|
|
6431
|
-
async def modify_margin_helper(self, symbol: str, amount, type, params={}):
|
6432
|
+
async def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|
6432
6433
|
await self.load_markets()
|
6433
6434
|
holdSide = self.safe_string(params, 'holdSide')
|
6434
6435
|
sandboxMode = self.safe_bool(self.options, 'sandboxMode', False)
|
@@ -6462,19 +6463,32 @@ class bitget(Exchange, ImplicitAPI):
|
|
6462
6463
|
'type': type,
|
6463
6464
|
})
|
6464
6465
|
|
6465
|
-
def parse_margin_modification(self, data, market: Market = None):
|
6466
|
+
def parse_margin_modification(self, data, market: Market = None) -> MarginModification:
|
6467
|
+
#
|
6468
|
+
# addMargin/reduceMargin
|
6469
|
+
#
|
6470
|
+
# {
|
6471
|
+
# "code": "00000",
|
6472
|
+
# "msg": "success",
|
6473
|
+
# "requestTime": 1700813444618,
|
6474
|
+
# "data": ""
|
6475
|
+
# }
|
6476
|
+
#
|
6466
6477
|
errorCode = self.safe_string(data, 'code')
|
6467
6478
|
status = 'ok' if (errorCode == '00000') else 'failed'
|
6468
6479
|
return {
|
6469
6480
|
'info': data,
|
6481
|
+
'symbol': market['symbol'],
|
6470
6482
|
'type': None,
|
6471
6483
|
'amount': None,
|
6484
|
+
'total': None,
|
6472
6485
|
'code': market['settle'],
|
6473
|
-
'symbol': market['symbol'],
|
6474
6486
|
'status': status,
|
6487
|
+
'timestamp': None,
|
6488
|
+
'datetime': None,
|
6475
6489
|
}
|
6476
6490
|
|
6477
|
-
async def reduce_margin(self, symbol: str, amount, params={}):
|
6491
|
+
async def reduce_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
6478
6492
|
"""
|
6479
6493
|
remove margin from a position
|
6480
6494
|
:see: https://www.bitget.com/api-doc/contract/account/Change-Margin
|
@@ -6490,7 +6504,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6490
6504
|
raise ArgumentsRequired(self.id + ' reduceMargin() requires a holdSide parameter, either long or short')
|
6491
6505
|
return await self.modify_margin_helper(symbol, amount, 'reduce', params)
|
6492
6506
|
|
6493
|
-
async def add_margin(self, symbol: str, amount, params={}):
|
6507
|
+
async def add_margin(self, symbol: str, amount, params={}) -> MarginModification:
|
6494
6508
|
"""
|
6495
6509
|
add margin
|
6496
6510
|
:see: https://www.bitget.com/api-doc/contract/account/Change-Margin
|
ccxt/async_support/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/async_support/bitrue.py
CHANGED
@@ -8,7 +8,7 @@ from ccxt.abstract.bitrue import ImplicitAPI
|
|
8
8
|
import asyncio
|
9
9
|
import hashlib
|
10
10
|
import json
|
11
|
-
from ccxt.base.types import Balances, Currency, Int, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
11
|
+
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
12
12
|
from typing import List
|
13
13
|
from ccxt.base.errors import ExchangeError
|
14
14
|
from ccxt.base.errors import PermissionDenied
|
@@ -1311,8 +1311,6 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1311
1311
|
'interval': self.safe_string(timeframesFuture, timeframe, '1min'),
|
1312
1312
|
}
|
1313
1313
|
if limit is not None:
|
1314
|
-
if limit > 300:
|
1315
|
-
limit = 300
|
1316
1314
|
request['limit'] = limit
|
1317
1315
|
if market['linear']:
|
1318
1316
|
response = await self.fapiV1PublicGetKlines(self.extend(request, params))
|
@@ -1327,8 +1325,6 @@ class bitrue(Exchange, ImplicitAPI):
|
|
1327
1325
|
'scale': self.safe_string(timeframesSpot, timeframe, '1m'),
|
1328
1326
|
}
|
1329
1327
|
if limit is not None:
|
1330
|
-
if limit > 1440:
|
1331
|
-
limit = 1440
|
1332
1328
|
request['limit'] = limit
|
1333
1329
|
if since is not None:
|
1334
1330
|
request['fromIdx'] = since
|
@@ -2843,17 +2839,29 @@ class bitrue(Exchange, ImplicitAPI):
|
|
2843
2839
|
response = await self.dapiV2PrivatePostLevelEdit(self.extend(request, params))
|
2844
2840
|
return response
|
2845
2841
|
|
2846
|
-
def parse_margin_modification(self, data, market=None):
|
2842
|
+
def parse_margin_modification(self, data, market=None) -> MarginModification:
|
2843
|
+
#
|
2844
|
+
# setMargin
|
2845
|
+
#
|
2846
|
+
# {
|
2847
|
+
# "code": 0,
|
2848
|
+
# "msg": "success"
|
2849
|
+
# "data": null
|
2850
|
+
# }
|
2851
|
+
#
|
2847
2852
|
return {
|
2848
2853
|
'info': data,
|
2854
|
+
'symbol': market['symbol'],
|
2849
2855
|
'type': None,
|
2850
2856
|
'amount': None,
|
2857
|
+
'total': None,
|
2851
2858
|
'code': None,
|
2852
|
-
'symbol': market['symbol'],
|
2853
2859
|
'status': None,
|
2860
|
+
'timestamp': None,
|
2861
|
+
'datetime': None,
|
2854
2862
|
}
|
2855
2863
|
|
2856
|
-
async def set_margin(self, symbol: str, amount: float, params={}):
|
2864
|
+
async def set_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
2857
2865
|
"""
|
2858
2866
|
Either adds or reduces margin in an isolated position in order to set the margin to a specific value
|
2859
2867
|
:see: https://www.bitrue.com/api-docs#modify-isolated-position-margin-trade-hmac-sha256
|
ccxt/async_support/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/async_support/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 = await self.publicGetMarketsMarketIdCandles(self.extend(request, params))
|
527
527
|
#
|
528
528
|
# [
|
ccxt/async_support/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 = await self.graphGetKlinesHistory(self.extend(request, params))
|
583
584
|
#
|
584
585
|
# {
|