ccxt 4.3.30__py2.py3-none-any.whl → 4.3.32__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/binance.py +2 -0
- ccxt/abstract/binancecoinm.py +2 -0
- ccxt/abstract/binanceus.py +2 -0
- ccxt/abstract/binanceusdm.py +2 -0
- ccxt/ace.py +14 -14
- ccxt/alpaca.py +16 -16
- ccxt/ascendex.py +46 -46
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ace.py +14 -14
- ccxt/async_support/alpaca.py +16 -16
- ccxt/async_support/ascendex.py +46 -46
- ccxt/async_support/base/exchange.py +23 -23
- ccxt/async_support/bigone.py +32 -32
- ccxt/async_support/binance.py +105 -96
- ccxt/async_support/bingx.py +21 -21
- ccxt/async_support/bit2c.py +13 -13
- ccxt/async_support/bitbank.py +19 -19
- ccxt/async_support/bitbns.py +17 -17
- ccxt/async_support/bitfinex.py +24 -24
- ccxt/async_support/bitfinex2.py +142 -109
- ccxt/async_support/bitflyer.py +23 -23
- ccxt/async_support/bitget.py +76 -76
- ccxt/async_support/bithumb.py +20 -20
- ccxt/async_support/bitmart.py +55 -55
- ccxt/async_support/bitmex.py +41 -41
- ccxt/async_support/bitopro.py +30 -30
- ccxt/async_support/bitrue.py +37 -37
- ccxt/async_support/bitso.py +30 -30
- ccxt/async_support/bitstamp.py +31 -31
- ccxt/async_support/bitteam.py +26 -26
- ccxt/async_support/bitvavo.py +27 -27
- ccxt/async_support/bl3p.py +8 -8
- ccxt/async_support/blockchaincom.py +24 -24
- ccxt/async_support/blofin.py +37 -37
- ccxt/async_support/btcalpha.py +19 -19
- ccxt/async_support/btcbox.py +11 -11
- ccxt/async_support/btcmarkets.py +22 -22
- ccxt/async_support/btcturk.py +13 -13
- ccxt/async_support/bybit.py +96 -96
- ccxt/async_support/cex.py +21 -21
- ccxt/async_support/coinbase.py +53 -53
- ccxt/async_support/coinbaseexchange.py +29 -29
- ccxt/async_support/coinbaseinternational.py +32 -32
- ccxt/async_support/coincheck.py +14 -14
- ccxt/async_support/coinex.py +208 -175
- ccxt/async_support/coinlist.py +35 -35
- ccxt/async_support/coinmate.py +22 -22
- ccxt/async_support/coinmetro.py +22 -22
- ccxt/async_support/coinone.py +18 -18
- ccxt/async_support/coinsph.py +32 -32
- ccxt/async_support/coinspot.py +8 -8
- ccxt/async_support/cryptocom.py +43 -43
- ccxt/async_support/currencycom.py +33 -33
- ccxt/async_support/delta.py +35 -35
- ccxt/async_support/deribit.py +54 -54
- ccxt/async_support/digifinex.py +56 -56
- ccxt/async_support/exmo.py +34 -34
- ccxt/async_support/gate.py +60 -60
- ccxt/async_support/gemini.py +24 -24
- ccxt/async_support/hitbtc.py +51 -51
- ccxt/async_support/hollaex.py +29 -29
- ccxt/async_support/htx.py +73 -73
- ccxt/async_support/huobijp.py +30 -30
- ccxt/async_support/hyperliquid.py +58 -58
- ccxt/async_support/idex.py +33 -33
- ccxt/async_support/independentreserve.py +12 -12
- ccxt/async_support/indodax.py +21 -21
- ccxt/async_support/kraken.py +46 -51
- ccxt/async_support/krakenfutures.py +29 -29
- ccxt/async_support/kucoin.py +51 -51
- ccxt/async_support/kucoinfutures.py +33 -33
- ccxt/async_support/kuna.py +27 -27
- ccxt/async_support/latoken.py +27 -27
- ccxt/async_support/lbank.py +35 -35
- ccxt/async_support/luno.py +19 -19
- ccxt/async_support/lykke.py +20 -20
- ccxt/async_support/mercado.py +17 -17
- ccxt/async_support/mexc.py +64 -64
- ccxt/async_support/ndax.py +38 -38
- ccxt/async_support/novadax.py +26 -26
- ccxt/async_support/oceanex.py +21 -21
- ccxt/async_support/okcoin.py +35 -35
- ccxt/async_support/okx.py +85 -85
- ccxt/async_support/onetrading.py +32 -32
- ccxt/async_support/p2b.py +14 -14
- ccxt/async_support/paymium.py +12 -12
- ccxt/async_support/phemex.py +50 -50
- ccxt/async_support/poloniex.py +35 -35
- ccxt/async_support/poloniexfutures.py +25 -21
- ccxt/async_support/probit.py +30 -30
- ccxt/async_support/timex.py +22 -22
- ccxt/async_support/tokocrypto.py +26 -26
- ccxt/async_support/tradeogre.py +12 -12
- ccxt/async_support/upbit.py +28 -28
- ccxt/async_support/wavesexchange.py +33 -33
- ccxt/async_support/wazirx.py +21 -21
- ccxt/async_support/whitebit.py +37 -37
- ccxt/async_support/woo.py +51 -51
- ccxt/async_support/woofipro.py +46 -46
- ccxt/async_support/yobit.py +20 -20
- ccxt/async_support/zaif.py +12 -12
- ccxt/async_support/zonda.py +22 -22
- ccxt/base/exchange.py +48 -36
- ccxt/base/types.py +13 -0
- ccxt/bigone.py +32 -32
- ccxt/binance.py +105 -96
- ccxt/bingx.py +21 -21
- ccxt/bit2c.py +13 -13
- ccxt/bitbank.py +19 -19
- ccxt/bitbns.py +17 -17
- ccxt/bitfinex.py +24 -24
- ccxt/bitfinex2.py +142 -109
- ccxt/bitflyer.py +23 -23
- ccxt/bitget.py +76 -76
- ccxt/bithumb.py +20 -20
- ccxt/bitmart.py +55 -55
- ccxt/bitmex.py +41 -41
- ccxt/bitopro.py +30 -30
- ccxt/bitrue.py +37 -37
- ccxt/bitso.py +30 -30
- ccxt/bitstamp.py +31 -31
- ccxt/bitteam.py +26 -26
- ccxt/bitvavo.py +27 -27
- ccxt/bl3p.py +8 -8
- ccxt/blockchaincom.py +24 -24
- ccxt/blofin.py +37 -37
- ccxt/btcalpha.py +19 -19
- ccxt/btcbox.py +11 -11
- ccxt/btcmarkets.py +22 -22
- ccxt/btcturk.py +13 -13
- ccxt/bybit.py +96 -96
- ccxt/cex.py +21 -21
- ccxt/coinbase.py +53 -53
- ccxt/coinbaseexchange.py +29 -29
- ccxt/coinbaseinternational.py +32 -32
- ccxt/coincheck.py +14 -14
- ccxt/coinex.py +208 -175
- ccxt/coinlist.py +35 -35
- ccxt/coinmate.py +22 -22
- ccxt/coinmetro.py +22 -22
- ccxt/coinone.py +18 -18
- ccxt/coinsph.py +32 -32
- ccxt/coinspot.py +8 -8
- ccxt/cryptocom.py +43 -43
- ccxt/currencycom.py +33 -33
- ccxt/delta.py +35 -35
- ccxt/deribit.py +54 -54
- ccxt/digifinex.py +56 -56
- ccxt/exmo.py +34 -34
- ccxt/gate.py +60 -60
- ccxt/gemini.py +24 -24
- ccxt/hitbtc.py +51 -51
- ccxt/hollaex.py +29 -29
- ccxt/htx.py +73 -73
- ccxt/huobijp.py +30 -30
- ccxt/hyperliquid.py +58 -58
- ccxt/idex.py +33 -33
- ccxt/independentreserve.py +12 -12
- ccxt/indodax.py +21 -21
- ccxt/kraken.py +46 -51
- ccxt/krakenfutures.py +29 -29
- ccxt/kucoin.py +51 -51
- ccxt/kucoinfutures.py +33 -33
- ccxt/kuna.py +27 -27
- ccxt/latoken.py +27 -27
- ccxt/lbank.py +35 -35
- ccxt/luno.py +19 -19
- ccxt/lykke.py +20 -20
- ccxt/mercado.py +17 -17
- ccxt/mexc.py +64 -64
- ccxt/ndax.py +38 -38
- ccxt/novadax.py +26 -26
- ccxt/oceanex.py +21 -21
- ccxt/okcoin.py +35 -35
- ccxt/okx.py +85 -85
- ccxt/onetrading.py +32 -32
- ccxt/p2b.py +14 -14
- ccxt/paymium.py +12 -12
- ccxt/phemex.py +50 -50
- ccxt/poloniex.py +35 -35
- ccxt/poloniexfutures.py +25 -21
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/alpaca.py +8 -8
- ccxt/pro/ascendex.py +4 -4
- ccxt/pro/binance.py +56 -56
- ccxt/pro/bingx.py +5 -5
- ccxt/pro/bitfinex.py +6 -6
- ccxt/pro/bitfinex2.py +10 -10
- ccxt/pro/bitget.py +17 -17
- ccxt/pro/bithumb.py +6 -6
- ccxt/pro/bitmart.py +8 -8
- ccxt/pro/bitmex.py +16 -16
- ccxt/pro/bitopro.py +4 -4
- ccxt/pro/bitrue.py +8 -8
- ccxt/pro/bitstamp.py +5 -5
- ccxt/pro/bitvavo.py +14 -14
- ccxt/pro/blockchaincom.py +7 -7
- ccxt/pro/bybit.py +12 -12
- ccxt/pro/cex.py +20 -20
- ccxt/pro/coinbase.py +32 -2
- ccxt/pro/coinbaseexchange.py +10 -10
- ccxt/pro/coinbaseinternational.py +4 -4
- ccxt/pro/coincheck.py +2 -2
- ccxt/pro/coinex.py +15 -15
- ccxt/pro/coinone.py +4 -4
- ccxt/pro/cryptocom.py +11 -11
- ccxt/pro/currencycom.py +4 -4
- ccxt/pro/deribit.py +9 -9
- ccxt/pro/exmo.py +9 -9
- ccxt/pro/gate.py +12 -12
- ccxt/pro/gemini.py +11 -11
- ccxt/pro/hitbtc.py +13 -13
- ccxt/pro/hollaex.py +6 -6
- ccxt/pro/htx.py +15 -15
- ccxt/pro/huobijp.py +16 -16
- ccxt/pro/hyperliquid.py +9 -9
- ccxt/pro/idex.py +12 -12
- ccxt/pro/independentreserve.py +2 -2
- ccxt/pro/kraken.py +14 -14
- ccxt/pro/krakenfutures.py +12 -12
- ccxt/pro/kucoin.py +12 -12
- ccxt/pro/kucoinfutures.py +16 -16
- ccxt/pro/lbank.py +12 -12
- ccxt/pro/luno.py +4 -4
- ccxt/pro/mexc.py +14 -14
- ccxt/pro/ndax.py +12 -12
- ccxt/pro/okcoin.py +6 -6
- ccxt/pro/okx.py +30 -30
- ccxt/pro/onetrading.py +13 -13
- ccxt/pro/p2b.py +2 -2
- ccxt/pro/phemex.py +9 -9
- ccxt/pro/poloniex.py +9 -9
- ccxt/pro/poloniexfutures.py +10 -10
- ccxt/pro/probit.py +8 -8
- ccxt/pro/upbit.py +1 -1
- ccxt/pro/wazirx.py +10 -10
- ccxt/pro/whitebit.py +8 -8
- ccxt/pro/woo.py +14 -14
- ccxt/pro/woofipro.py +14 -14
- ccxt/probit.py +30 -30
- ccxt/test/base/test_shared_methods.py +1 -0
- ccxt/test/test_async.py +1 -1
- ccxt/test/test_sync.py +1 -1
- ccxt/timex.py +22 -22
- ccxt/tokocrypto.py +26 -26
- ccxt/tradeogre.py +12 -12
- ccxt/upbit.py +28 -28
- ccxt/wavesexchange.py +33 -33
- ccxt/wazirx.py +21 -21
- ccxt/whitebit.py +37 -37
- ccxt/woo.py +51 -51
- ccxt/woofipro.py +46 -46
- ccxt/yobit.py +20 -20
- ccxt/zaif.py +12 -12
- ccxt/zonda.py +22 -22
- {ccxt-4.3.30.dist-info → ccxt-4.3.32.dist-info}/METADATA +4 -4
- {ccxt-4.3.30.dist-info → ccxt-4.3.32.dist-info}/RECORD +260 -260
- {ccxt-4.3.30.dist-info → ccxt-4.3.32.dist-info}/WHEEL +0 -0
- {ccxt-4.3.30.dist-info → ccxt-4.3.32.dist-info}/top_level.txt +0 -0
ccxt/bitfinex2.py
CHANGED
@@ -649,7 +649,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
649
649
|
'pub:map:tx:method', # maps withdrawal/deposit methods to their API symbols
|
650
650
|
]
|
651
651
|
config = ','.join(labels)
|
652
|
-
request = {
|
652
|
+
request: dict = {
|
653
653
|
'config': config,
|
654
654
|
}
|
655
655
|
response = self.publicGetConfConfig(self.extend(request, params))
|
@@ -731,7 +731,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
731
731
|
# ],
|
732
732
|
# ]
|
733
733
|
#
|
734
|
-
indexed = {
|
734
|
+
indexed: dict = {
|
735
735
|
'sym': self.index_by(self.safe_value(response, 1, []), 0),
|
736
736
|
'label': self.index_by(self.safe_value(response, 2, []), 0),
|
737
737
|
'unit': self.index_by(self.safe_value(response, 3, []), 0),
|
@@ -741,7 +741,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
741
741
|
'fees': self.index_by(self.safe_value(response, 7, []), 0),
|
742
742
|
}
|
743
743
|
ids = self.safe_value(response, 0, [])
|
744
|
-
result = {}
|
744
|
+
result: dict = {}
|
745
745
|
for i in range(0, len(ids)):
|
746
746
|
id = ids[i]
|
747
747
|
if id.find('F0') >= 0:
|
@@ -783,7 +783,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
783
783
|
},
|
784
784
|
'networks': {},
|
785
785
|
}
|
786
|
-
networks = {}
|
786
|
+
networks: dict = {}
|
787
787
|
currencyNetworks = self.safe_value(response, 8, [])
|
788
788
|
cleanId = id.replace('F0', '')
|
789
789
|
for j in range(0, len(currencyNetworks)):
|
@@ -815,7 +815,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
815
815
|
return result
|
816
816
|
|
817
817
|
def safe_network(self, networkId):
|
818
|
-
networksById = {
|
818
|
+
networksById: dict = {
|
819
819
|
'BITCOIN': 'BTC',
|
820
820
|
'LITECOIN': 'LTC',
|
821
821
|
'ETHEREUM': 'ERC20',
|
@@ -853,7 +853,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
853
853
|
isDerivative = requestedType == 'derivatives'
|
854
854
|
query = self.omit(params, 'type')
|
855
855
|
response = self.privatePostAuthRWallets(query)
|
856
|
-
result = {'info': response}
|
856
|
+
result: dict = {'info': response}
|
857
857
|
for i in range(0, len(response)):
|
858
858
|
balance = response[i]
|
859
859
|
account = self.account()
|
@@ -901,7 +901,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
901
901
|
toCurrencyId = self.convert_derivatives_id(currency, toAccount)
|
902
902
|
requestedAmount = self.currency_to_precision(code, amount)
|
903
903
|
# self request is slightly different from v1 fromAccount -> from
|
904
|
-
request = {
|
904
|
+
request: dict = {
|
905
905
|
'amount': requestedAmount,
|
906
906
|
'currency': fromCurrencyId,
|
907
907
|
'currency_to': toCurrencyId,
|
@@ -982,7 +982,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
982
982
|
}
|
983
983
|
|
984
984
|
def parse_transfer_status(self, status: Str) -> Str:
|
985
|
-
statuses = {
|
985
|
+
statuses: dict = {
|
986
986
|
'SUCCESS': 'ok',
|
987
987
|
'ERROR': 'failed',
|
988
988
|
'FAILURE': 'failed',
|
@@ -1023,7 +1023,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1023
1023
|
self.load_markets()
|
1024
1024
|
precision = self.safe_value(self.options, 'precision', 'R0')
|
1025
1025
|
market = self.market(symbol)
|
1026
|
-
request = {
|
1026
|
+
request: dict = {
|
1027
1027
|
'symbol': market['id'],
|
1028
1028
|
'precision': precision,
|
1029
1029
|
}
|
@@ -1032,7 +1032,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1032
1032
|
fullRequest = self.extend(request, params)
|
1033
1033
|
orderbook = self.publicGetBookSymbolPrecision(fullRequest)
|
1034
1034
|
timestamp = self.milliseconds()
|
1035
|
-
result = {
|
1035
|
+
result: dict = {
|
1036
1036
|
'symbol': market['symbol'],
|
1037
1037
|
'bids': [],
|
1038
1038
|
'asks': [],
|
@@ -1135,7 +1135,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1135
1135
|
"""
|
1136
1136
|
self.load_markets()
|
1137
1137
|
symbols = self.market_symbols(symbols)
|
1138
|
-
request = {}
|
1138
|
+
request: dict = {}
|
1139
1139
|
if symbols is not None:
|
1140
1140
|
ids = self.market_ids(symbols)
|
1141
1141
|
request['symbols'] = ','.join(ids)
|
@@ -1181,7 +1181,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1181
1181
|
# ...
|
1182
1182
|
# ]
|
1183
1183
|
#
|
1184
|
-
result = {}
|
1184
|
+
result: dict = {}
|
1185
1185
|
for i in range(0, len(tickers)):
|
1186
1186
|
ticker = tickers[i]
|
1187
1187
|
marketId = self.safe_string(ticker, 0)
|
@@ -1200,14 +1200,14 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1200
1200
|
"""
|
1201
1201
|
self.load_markets()
|
1202
1202
|
market = self.market(symbol)
|
1203
|
-
request = {
|
1203
|
+
request: dict = {
|
1204
1204
|
'symbol': market['id'],
|
1205
1205
|
}
|
1206
1206
|
ticker = self.publicGetTickerSymbol(self.extend(request, params))
|
1207
|
-
result = {'result': ticker}
|
1207
|
+
result: dict = {'result': ticker}
|
1208
1208
|
return self.parse_ticker(result, market)
|
1209
1209
|
|
1210
|
-
def parse_trade(self, trade, market: Market = None) -> Trade:
|
1210
|
+
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
1211
1211
|
#
|
1212
1212
|
# fetchTrades(public)
|
1213
1213
|
#
|
@@ -1235,14 +1235,15 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1235
1235
|
# ...
|
1236
1236
|
# ]
|
1237
1237
|
#
|
1238
|
-
|
1238
|
+
tradeList = self.safe_list(trade, 'result', [])
|
1239
|
+
tradeLength = len(tradeList)
|
1239
1240
|
isPrivate = (tradeLength > 5)
|
1240
|
-
id = self.safe_string(
|
1241
|
+
id = self.safe_string(tradeList, 0)
|
1241
1242
|
amountIndex = 4 if isPrivate else 2
|
1242
1243
|
side = None
|
1243
|
-
amountString = self.safe_string(
|
1244
|
+
amountString = self.safe_string(tradeList, amountIndex)
|
1244
1245
|
priceIndex = 5 if isPrivate else 3
|
1245
|
-
priceString = self.safe_string(
|
1246
|
+
priceString = self.safe_string(tradeList, priceIndex)
|
1246
1247
|
if amountString[0] == '-':
|
1247
1248
|
side = 'sell'
|
1248
1249
|
amountString = Precise.string_abs(amountString)
|
@@ -1254,22 +1255,22 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1254
1255
|
fee = None
|
1255
1256
|
symbol = self.safe_symbol(None, market)
|
1256
1257
|
timestampIndex = 2 if isPrivate else 1
|
1257
|
-
timestamp = self.safe_integer(
|
1258
|
+
timestamp = self.safe_integer(tradeList, timestampIndex)
|
1258
1259
|
if isPrivate:
|
1259
|
-
marketId =
|
1260
|
+
marketId = tradeList[1]
|
1260
1261
|
symbol = self.safe_symbol(marketId)
|
1261
|
-
orderId = self.safe_string(
|
1262
|
-
maker = self.safe_integer(
|
1262
|
+
orderId = self.safe_string(tradeList, 3)
|
1263
|
+
maker = self.safe_integer(tradeList, 8)
|
1263
1264
|
takerOrMaker = 'maker' if (maker == 1) else 'taker'
|
1264
|
-
feeCostString = self.safe_string(
|
1265
|
+
feeCostString = self.safe_string(tradeList, 9)
|
1265
1266
|
feeCostString = Precise.string_neg(feeCostString)
|
1266
|
-
feeCurrencyId = self.safe_string(
|
1267
|
+
feeCurrencyId = self.safe_string(tradeList, 10)
|
1267
1268
|
feeCurrency = self.safe_currency_code(feeCurrencyId)
|
1268
1269
|
fee = {
|
1269
1270
|
'cost': feeCostString,
|
1270
1271
|
'currency': feeCurrency,
|
1271
1272
|
}
|
1272
|
-
orderType =
|
1273
|
+
orderType = tradeList[6]
|
1273
1274
|
type = self.safe_string(self.options['exchangeTypes'], orderType)
|
1274
1275
|
return self.safe_trade({
|
1275
1276
|
'id': id,
|
@@ -1284,7 +1285,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1284
1285
|
'amount': amountString,
|
1285
1286
|
'cost': None,
|
1286
1287
|
'fee': fee,
|
1287
|
-
'info':
|
1288
|
+
'info': tradeList,
|
1288
1289
|
}, market)
|
1289
1290
|
|
1290
1291
|
def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
@@ -1306,7 +1307,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1306
1307
|
return self.fetch_paginated_call_dynamic('fetchTrades', symbol, since, limit, params, 10000)
|
1307
1308
|
market = self.market(symbol)
|
1308
1309
|
sort = '-1'
|
1309
|
-
request = {
|
1310
|
+
request: dict = {
|
1310
1311
|
'symbol': market['id'],
|
1311
1312
|
}
|
1312
1313
|
if since is not None:
|
@@ -1328,7 +1329,10 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1328
1329
|
# ]
|
1329
1330
|
#
|
1330
1331
|
trades = self.sort_by(response, 1)
|
1331
|
-
|
1332
|
+
tradesList = []
|
1333
|
+
for i in range(0, len(trades)):
|
1334
|
+
tradesList.append({'result': trades[i]}) # convert to array of dicts to match parseOrder signature
|
1335
|
+
return self.parse_trades(tradesList, market, None, limit)
|
1332
1336
|
|
1333
1337
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = 100, params={}) -> List[list]:
|
1334
1338
|
"""
|
@@ -1353,7 +1357,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1353
1357
|
limit = 10000
|
1354
1358
|
else:
|
1355
1359
|
limit = min(limit, 10000)
|
1356
|
-
request = {
|
1360
|
+
request: dict = {
|
1357
1361
|
'symbol': market['id'],
|
1358
1362
|
'timeframe': self.safe_string(self.timeframes, timeframe, timeframe),
|
1359
1363
|
'sort': 1,
|
@@ -1392,12 +1396,12 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1392
1396
|
self.safe_number(ohlcv, 5),
|
1393
1397
|
]
|
1394
1398
|
|
1395
|
-
def parse_order_status(self, status):
|
1399
|
+
def parse_order_status(self, status: Str):
|
1396
1400
|
if status is None:
|
1397
1401
|
return status
|
1398
1402
|
parts = status.split(' ')
|
1399
1403
|
state = self.safe_string(parts, 0)
|
1400
|
-
statuses = {
|
1404
|
+
statuses: dict = {
|
1401
1405
|
'ACTIVE': 'open',
|
1402
1406
|
'PARTIALLY': 'open',
|
1403
1407
|
'EXECUTED': 'closed',
|
@@ -1413,7 +1417,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1413
1417
|
|
1414
1418
|
def parse_order_flags(self, flags):
|
1415
1419
|
# flags can be added to each other...
|
1416
|
-
flagValues = {
|
1420
|
+
flagValues: dict = {
|
1417
1421
|
'1024': ['reduceOnly'],
|
1418
1422
|
'4096': ['postOnly'],
|
1419
1423
|
'5120': ['reduceOnly', 'postOnly'],
|
@@ -1425,7 +1429,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1425
1429
|
return self.safe_value(flagValues, flags, None)
|
1426
1430
|
|
1427
1431
|
def parse_time_in_force(self, orderType):
|
1428
|
-
orderTypes = {
|
1432
|
+
orderTypes: dict = {
|
1429
1433
|
'EXCHANGE IOC': 'IOC',
|
1430
1434
|
'EXCHANGE FOK': 'FOK',
|
1431
1435
|
'IOC': 'IOC', # Margin
|
@@ -1433,43 +1437,44 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1433
1437
|
}
|
1434
1438
|
return self.safe_string(orderTypes, orderType, 'GTC')
|
1435
1439
|
|
1436
|
-
def parse_order(self, order, market: Market = None) -> Order:
|
1437
|
-
|
1438
|
-
|
1440
|
+
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1441
|
+
orderList = self.safe_list(order, 'result')
|
1442
|
+
id = self.safe_string(orderList, 0)
|
1443
|
+
marketId = self.safe_string(orderList, 3)
|
1439
1444
|
symbol = self.safe_symbol(marketId)
|
1440
1445
|
# https://github.com/ccxt/ccxt/issues/6686
|
1441
|
-
# timestamp = self.safe_timestamp(
|
1442
|
-
timestamp = self.safe_integer(
|
1443
|
-
remaining = Precise.string_abs(self.safe_string(
|
1444
|
-
signedAmount = self.safe_string(
|
1446
|
+
# timestamp = self.safe_timestamp(orderObject, 5)
|
1447
|
+
timestamp = self.safe_integer(orderList, 5)
|
1448
|
+
remaining = Precise.string_abs(self.safe_string(orderList, 6))
|
1449
|
+
signedAmount = self.safe_string(orderList, 7)
|
1445
1450
|
amount = Precise.string_abs(signedAmount)
|
1446
1451
|
side = 'sell' if Precise.string_lt(signedAmount, '0') else 'buy'
|
1447
|
-
orderType = self.safe_string(
|
1452
|
+
orderType = self.safe_string(orderList, 8)
|
1448
1453
|
type = self.safe_string(self.safe_value(self.options, 'exchangeTypes'), orderType)
|
1449
1454
|
timeInForce = self.parse_time_in_force(orderType)
|
1450
|
-
rawFlags = self.safe_string(
|
1455
|
+
rawFlags = self.safe_string(orderList, 12)
|
1451
1456
|
flags = self.parse_order_flags(rawFlags)
|
1452
1457
|
postOnly = False
|
1453
1458
|
if flags is not None:
|
1454
1459
|
for i in range(0, len(flags)):
|
1455
1460
|
if flags[i] == 'postOnly':
|
1456
1461
|
postOnly = True
|
1457
|
-
price = self.safe_string(
|
1462
|
+
price = self.safe_string(orderList, 16)
|
1458
1463
|
stopPrice = None
|
1459
1464
|
if (orderType == 'EXCHANGE STOP') or (orderType == 'EXCHANGE STOP LIMIT'):
|
1460
1465
|
price = None
|
1461
|
-
stopPrice = self.safe_string(
|
1466
|
+
stopPrice = self.safe_string(orderList, 16)
|
1462
1467
|
if orderType == 'EXCHANGE STOP LIMIT':
|
1463
|
-
price = self.safe_string(
|
1468
|
+
price = self.safe_string(orderList, 19)
|
1464
1469
|
status = None
|
1465
|
-
statusString = self.safe_string(
|
1470
|
+
statusString = self.safe_string(orderList, 13)
|
1466
1471
|
if statusString is not None:
|
1467
1472
|
parts = statusString.split(' @ ')
|
1468
1473
|
status = self.parse_order_status(self.safe_string(parts, 0))
|
1469
|
-
average = self.safe_string(
|
1470
|
-
clientOrderId = self.safe_string(
|
1474
|
+
average = self.safe_string(orderList, 17)
|
1475
|
+
clientOrderId = self.safe_string(orderList, 2)
|
1471
1476
|
return self.safe_order({
|
1472
|
-
'info':
|
1477
|
+
'info': orderList,
|
1473
1478
|
'id': id,
|
1474
1479
|
'clientOrderId': clientOrderId,
|
1475
1480
|
'timestamp': timestamp,
|
@@ -1517,7 +1522,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1517
1522
|
market = self.market(symbol)
|
1518
1523
|
amountString = self.amount_to_precision(symbol, amount)
|
1519
1524
|
amountString = amountString if (side == 'buy') else Precise.string_neg(amountString)
|
1520
|
-
request = {
|
1525
|
+
request: dict = {
|
1521
1526
|
'symbol': market['id'],
|
1522
1527
|
'amount': amountString,
|
1523
1528
|
}
|
@@ -1672,7 +1677,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1672
1677
|
orderParams = self.safe_dict(rawOrder, 'params', {})
|
1673
1678
|
orderRequest = self.create_order_request(symbol, type, side, amount, price, orderParams)
|
1674
1679
|
ordersRequests.append(['on', orderRequest])
|
1675
|
-
request = {
|
1680
|
+
request: dict = {
|
1676
1681
|
'ops': ordersRequests,
|
1677
1682
|
}
|
1678
1683
|
response = self.privatePostAuthWOrderMulti(request)
|
@@ -1706,7 +1711,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1706
1711
|
for i in range(0, len(data)):
|
1707
1712
|
entry = data[i]
|
1708
1713
|
individualOrder = entry[4]
|
1709
|
-
results.append(individualOrder[0])
|
1714
|
+
results.append({'result': individualOrder[0]})
|
1710
1715
|
return self.parse_orders(results)
|
1711
1716
|
|
1712
1717
|
def cancel_all_orders(self, symbol: Str = None, params={}):
|
@@ -1718,12 +1723,15 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1718
1723
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1719
1724
|
"""
|
1720
1725
|
self.load_markets()
|
1721
|
-
request = {
|
1726
|
+
request: dict = {
|
1722
1727
|
'all': 1,
|
1723
1728
|
}
|
1724
1729
|
response = self.privatePostAuthWOrderCancelMulti(self.extend(request, params))
|
1725
1730
|
orders = self.safe_list(response, 4, [])
|
1726
|
-
|
1731
|
+
ordersList = []
|
1732
|
+
for i in range(0, len(orders)):
|
1733
|
+
ordersList.append({'result': orders[i]})
|
1734
|
+
return self.parse_orders(ordersList)
|
1727
1735
|
|
1728
1736
|
def cancel_order(self, id: str, symbol: Str = None, params={}):
|
1729
1737
|
"""
|
@@ -1752,7 +1760,8 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1752
1760
|
}
|
1753
1761
|
response = self.privatePostAuthWOrderCancel(self.extend(request, params))
|
1754
1762
|
order = self.safe_value(response, 4)
|
1755
|
-
|
1763
|
+
orderObject = {'result': order}
|
1764
|
+
return self.parse_order(orderObject)
|
1756
1765
|
|
1757
1766
|
def cancel_orders(self, ids, symbol: Str = None, params={}):
|
1758
1767
|
"""
|
@@ -1766,7 +1775,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1766
1775
|
self.load_markets()
|
1767
1776
|
for i in range(0, len(ids)):
|
1768
1777
|
ids[i] = self.parse_to_numeric(ids[i])
|
1769
|
-
request = {
|
1778
|
+
request: dict = {
|
1770
1779
|
'id': ids,
|
1771
1780
|
}
|
1772
1781
|
market = None
|
@@ -1824,7 +1833,10 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1824
1833
|
# ]
|
1825
1834
|
#
|
1826
1835
|
orders = self.safe_list(response, 4, [])
|
1827
|
-
|
1836
|
+
ordersList = []
|
1837
|
+
for i in range(0, len(orders)):
|
1838
|
+
ordersList.append({'result': orders[i]})
|
1839
|
+
return self.parse_orders(ordersList, market)
|
1828
1840
|
|
1829
1841
|
def fetch_open_order(self, id: str, symbol: Str = None, params={}):
|
1830
1842
|
"""
|
@@ -1836,7 +1848,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1836
1848
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1837
1849
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1838
1850
|
"""
|
1839
|
-
request = {
|
1851
|
+
request: dict = {
|
1840
1852
|
'id': [int(id)],
|
1841
1853
|
}
|
1842
1854
|
orders = self.fetch_open_orders(symbol, None, None, self.extend(request, params))
|
@@ -1855,7 +1867,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1855
1867
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1856
1868
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1857
1869
|
"""
|
1858
|
-
request = {
|
1870
|
+
request: dict = {
|
1859
1871
|
'id': [int(id)],
|
1860
1872
|
}
|
1861
1873
|
orders = self.fetch_closed_orders(symbol, None, None, self.extend(request, params))
|
@@ -1876,7 +1888,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1876
1888
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1877
1889
|
"""
|
1878
1890
|
self.load_markets()
|
1879
|
-
request = {}
|
1891
|
+
request: dict = {}
|
1880
1892
|
market = None
|
1881
1893
|
response = None
|
1882
1894
|
if symbol is None:
|
@@ -1923,7 +1935,10 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1923
1935
|
# ],
|
1924
1936
|
# ]
|
1925
1937
|
#
|
1926
|
-
|
1938
|
+
ordersList = []
|
1939
|
+
for i in range(0, len(response)):
|
1940
|
+
ordersList.append({'result': response[i]})
|
1941
|
+
return self.parse_orders(ordersList, market, since, limit)
|
1927
1942
|
|
1928
1943
|
def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1929
1944
|
"""
|
@@ -1944,7 +1959,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1944
1959
|
paginate, params = self.handle_option_and_params(params, 'fetchClosedOrders', 'paginate')
|
1945
1960
|
if paginate:
|
1946
1961
|
return self.fetch_paginated_call_dynamic('fetchClosedOrders', symbol, since, limit, params)
|
1947
|
-
request = {}
|
1962
|
+
request: dict = {}
|
1948
1963
|
if since is not None:
|
1949
1964
|
request['start'] = since
|
1950
1965
|
if limit is not None:
|
@@ -1996,7 +2011,10 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
1996
2011
|
# ]
|
1997
2012
|
# ]
|
1998
2013
|
#
|
1999
|
-
|
2014
|
+
ordersList = []
|
2015
|
+
for i in range(0, len(response)):
|
2016
|
+
ordersList.append({'result': response[i]})
|
2017
|
+
return self.parse_orders(ordersList, market, since, limit)
|
2000
2018
|
|
2001
2019
|
def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2002
2020
|
"""
|
@@ -2014,13 +2032,16 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2014
2032
|
self.load_markets()
|
2015
2033
|
market = self.market(symbol)
|
2016
2034
|
orderId = int(id)
|
2017
|
-
request = {
|
2035
|
+
request: dict = {
|
2018
2036
|
'id': orderId,
|
2019
2037
|
'symbol': market['id'],
|
2020
2038
|
}
|
2021
2039
|
# valid for trades upto 10 days old
|
2022
2040
|
response = self.privatePostAuthROrderSymbolIdTrades(self.extend(request, params))
|
2023
|
-
|
2041
|
+
tradesList = []
|
2042
|
+
for i in range(0, len(response)):
|
2043
|
+
tradesList.append({'result': response[i]}) # convert to array of dicts to match parseOrder signature
|
2044
|
+
return self.parse_trades(tradesList, market, since, limit)
|
2024
2045
|
|
2025
2046
|
def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2026
2047
|
"""
|
@@ -2035,7 +2056,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2035
2056
|
"""
|
2036
2057
|
self.load_markets()
|
2037
2058
|
market = None
|
2038
|
-
request = {
|
2059
|
+
request: dict = {
|
2039
2060
|
'end': self.milliseconds(),
|
2040
2061
|
}
|
2041
2062
|
if since is not None:
|
@@ -2049,7 +2070,10 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2049
2070
|
response = self.privatePostAuthRTradesSymbolHist(self.extend(request, params))
|
2050
2071
|
else:
|
2051
2072
|
response = self.privatePostAuthRTradesHist(self.extend(request, params))
|
2052
|
-
|
2073
|
+
tradesList = []
|
2074
|
+
for i in range(0, len(response)):
|
2075
|
+
tradesList.append({'result': response[i]}) # convert to array of dicts to match parseOrder signature
|
2076
|
+
return self.parse_trades(tradesList, market, since, limit)
|
2053
2077
|
|
2054
2078
|
def create_deposit_address(self, code: str, params={}):
|
2055
2079
|
"""
|
@@ -2060,7 +2084,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2060
2084
|
:returns dict: an `address structure <https://docs.ccxt.com/#/?id=address-structure>`
|
2061
2085
|
"""
|
2062
2086
|
self.load_markets()
|
2063
|
-
request = {
|
2087
|
+
request: dict = {
|
2064
2088
|
'op_renew': 1,
|
2065
2089
|
}
|
2066
2090
|
return self.fetch_deposit_address(code, self.extend(request, params))
|
@@ -2084,7 +2108,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2084
2108
|
raise ArgumentsRequired(self.id + " fetchDepositAddress() could not find a network for '" + code + "'. You can specify it by providing the 'network' value inside params")
|
2085
2109
|
wallet = self.safe_string(params, 'wallet', 'exchange') # 'exchange', 'margin', 'funding' and also old labels 'exchange', 'trading', 'deposit', respectively
|
2086
2110
|
params = self.omit(params, 'network', 'wallet')
|
2087
|
-
request = {
|
2111
|
+
request: dict = {
|
2088
2112
|
'method': networkId,
|
2089
2113
|
'wallet': wallet,
|
2090
2114
|
'op_renew': 0, # a value of 1 will generate a new address
|
@@ -2123,7 +2147,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2123
2147
|
}
|
2124
2148
|
|
2125
2149
|
def parse_transaction_status(self, status):
|
2126
|
-
statuses = {
|
2150
|
+
statuses: dict = {
|
2127
2151
|
'SUCCESS': 'ok',
|
2128
2152
|
'COMPLETED': 'ok',
|
2129
2153
|
'ERROR': 'failed',
|
@@ -2138,7 +2162,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2138
2162
|
}
|
2139
2163
|
return self.safe_string(statuses, status, status)
|
2140
2164
|
|
2141
|
-
def parse_transaction(self, transaction, currency: Currency = None) -> Transaction:
|
2165
|
+
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2142
2166
|
#
|
2143
2167
|
# withdraw
|
2144
2168
|
#
|
@@ -2345,7 +2369,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2345
2369
|
# {leo_lev: "0", leo_amount_avg: "0"}
|
2346
2370
|
# ]
|
2347
2371
|
#
|
2348
|
-
result = {}
|
2372
|
+
result: dict = {}
|
2349
2373
|
fiat = self.safe_value(self.options, 'fiat', {})
|
2350
2374
|
feeData = self.safe_value(response, 4, [])
|
2351
2375
|
makerData = self.safe_value(feeData, 0, [])
|
@@ -2390,7 +2414,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2390
2414
|
"""
|
2391
2415
|
self.load_markets()
|
2392
2416
|
currency = None
|
2393
|
-
request = {}
|
2417
|
+
request: dict = {}
|
2394
2418
|
if since is not None:
|
2395
2419
|
request['start'] = since
|
2396
2420
|
if limit is not None:
|
@@ -2456,7 +2480,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2456
2480
|
raise ArgumentsRequired(self.id + " withdraw() could not find a network for '" + code + "'. You can specify it by providing the 'network' value inside params")
|
2457
2481
|
wallet = self.safe_string(params, 'wallet', 'exchange') # 'exchange', 'margin', 'funding' and also old labels 'exchange', 'trading', 'deposit', respectively
|
2458
2482
|
params = self.omit(params, 'network', 'wallet')
|
2459
|
-
request = {
|
2483
|
+
request: dict = {
|
2460
2484
|
'method': networkId,
|
2461
2485
|
'wallet': wallet,
|
2462
2486
|
'amount': self.number_to_string(amount),
|
@@ -2560,9 +2584,12 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2560
2584
|
# ]
|
2561
2585
|
# ]
|
2562
2586
|
#
|
2563
|
-
|
2587
|
+
positionsList = []
|
2588
|
+
for i in range(0, len(response)):
|
2589
|
+
positionsList.append({'result': response[i]})
|
2590
|
+
return self.parse_positions(positionsList, symbols)
|
2564
2591
|
|
2565
|
-
def parse_position(self, position, market: Market = None):
|
2592
|
+
def parse_position(self, position: dict, market: Market = None):
|
2566
2593
|
#
|
2567
2594
|
# [
|
2568
2595
|
# "tBTCUSD", # SYMBOL
|
@@ -2595,22 +2622,23 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2595
2622
|
# }
|
2596
2623
|
# ]
|
2597
2624
|
#
|
2598
|
-
|
2599
|
-
|
2600
|
-
|
2601
|
-
|
2625
|
+
positionList = self.safe_list(position, 'result')
|
2626
|
+
marketId = self.safe_string(positionList, 0)
|
2627
|
+
amount = self.safe_string(positionList, 2)
|
2628
|
+
timestamp = self.safe_integer(positionList, 12)
|
2629
|
+
meta = self.safe_string(positionList, 19)
|
2602
2630
|
tradePrice = self.safe_string(meta, 'trade_price')
|
2603
2631
|
tradeAmount = self.safe_string(meta, 'trade_amount')
|
2604
2632
|
return self.safe_position({
|
2605
|
-
'info':
|
2606
|
-
'id': self.safe_string(
|
2633
|
+
'info': positionList,
|
2634
|
+
'id': self.safe_string(positionList, 11),
|
2607
2635
|
'symbol': self.safe_symbol(marketId, market),
|
2608
2636
|
'notional': self.parse_number(amount),
|
2609
2637
|
'marginMode': 'isolated', # derivatives use isolated, margin uses cross, https://support.bitfinex.com/hc/en-us/articles/360035475374-Derivatives-Trading-on-Bitfinex
|
2610
|
-
'liquidationPrice': self.safe_number(
|
2611
|
-
'entryPrice': self.safe_number(
|
2612
|
-
'unrealizedPnl': self.safe_number(
|
2613
|
-
'percentage': self.safe_number(
|
2638
|
+
'liquidationPrice': self.safe_number(positionList, 8),
|
2639
|
+
'entryPrice': self.safe_number(positionList, 3),
|
2640
|
+
'unrealizedPnl': self.safe_number(positionList, 6),
|
2641
|
+
'percentage': self.safe_number(positionList, 7),
|
2614
2642
|
'contracts': None,
|
2615
2643
|
'contractSize': None,
|
2616
2644
|
'markPrice': None,
|
@@ -2619,13 +2647,13 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2619
2647
|
'hedged': None,
|
2620
2648
|
'timestamp': timestamp,
|
2621
2649
|
'datetime': self.iso8601(timestamp),
|
2622
|
-
'lastUpdateTimestamp': self.safe_integer(
|
2623
|
-
'maintenanceMargin': self.safe_number(
|
2650
|
+
'lastUpdateTimestamp': self.safe_integer(positionList, 13),
|
2651
|
+
'maintenanceMargin': self.safe_number(positionList, 18),
|
2624
2652
|
'maintenanceMarginPercentage': None,
|
2625
|
-
'collateral': self.safe_number(
|
2653
|
+
'collateral': self.safe_number(positionList, 17),
|
2626
2654
|
'initialMargin': self.parse_number(Precise.string_mul(tradeAmount, tradePrice)),
|
2627
2655
|
'initialMarginPercentage': None,
|
2628
|
-
'leverage': self.safe_number(
|
2656
|
+
'leverage': self.safe_number(positionList, 9),
|
2629
2657
|
'marginRatio': None,
|
2630
2658
|
'stopLossPrice': None,
|
2631
2659
|
'takeProfitPrice': None,
|
@@ -2683,7 +2711,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2683
2711
|
raise ExchangeError(self.id + ' ' + errorText + '(#' + errorCode + ')')
|
2684
2712
|
return response
|
2685
2713
|
|
2686
|
-
def parse_ledger_entry_type(self, type):
|
2714
|
+
def parse_ledger_entry_type(self, type: Str):
|
2687
2715
|
if type is None:
|
2688
2716
|
return None
|
2689
2717
|
elif type.find('fee') >= 0 or type.find('charged') >= 0:
|
@@ -2701,7 +2729,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2701
2729
|
else:
|
2702
2730
|
return type
|
2703
2731
|
|
2704
|
-
def parse_ledger_entry(self, item, currency: Currency = None):
|
2732
|
+
def parse_ledger_entry(self, item: dict, currency: Currency = None):
|
2705
2733
|
#
|
2706
2734
|
# [
|
2707
2735
|
# [
|
@@ -2717,14 +2745,15 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2717
2745
|
# ]
|
2718
2746
|
# ]
|
2719
2747
|
#
|
2748
|
+
itemList = self.safe_list(item, 'result', [])
|
2720
2749
|
type = None
|
2721
|
-
id = self.safe_string(
|
2722
|
-
currencyId = self.safe_string(
|
2750
|
+
id = self.safe_string(itemList, 0)
|
2751
|
+
currencyId = self.safe_string(itemList, 1)
|
2723
2752
|
code = self.safe_currency_code(currencyId, currency)
|
2724
|
-
timestamp = self.safe_integer(
|
2725
|
-
amount = self.safe_number(
|
2726
|
-
after = self.safe_number(
|
2727
|
-
description = self.safe_string(
|
2753
|
+
timestamp = self.safe_integer(itemList, 3)
|
2754
|
+
amount = self.safe_number(itemList, 5)
|
2755
|
+
after = self.safe_number(itemList, 6)
|
2756
|
+
description = self.safe_string(itemList, 8)
|
2728
2757
|
if description is not None:
|
2729
2758
|
parts = description.split(' @ ')
|
2730
2759
|
first = self.safe_string_lower(parts, 0)
|
@@ -2765,7 +2794,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2765
2794
|
if paginate:
|
2766
2795
|
return self.fetch_paginated_call_dynamic('fetchLedger', code, since, limit, params, 2500)
|
2767
2796
|
currency = None
|
2768
|
-
request = {}
|
2797
|
+
request: dict = {}
|
2769
2798
|
if since is not None:
|
2770
2799
|
request['start'] = since
|
2771
2800
|
if limit is not None:
|
@@ -2793,7 +2822,11 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2793
2822
|
# ]
|
2794
2823
|
# ]
|
2795
2824
|
#
|
2796
|
-
|
2825
|
+
ledgerObjects = []
|
2826
|
+
for i in range(0, len(response)):
|
2827
|
+
item = response[i]
|
2828
|
+
ledgerObjects.append({'result': item})
|
2829
|
+
return self.parse_ledger(ledgerObjects, currency, since, limit)
|
2797
2830
|
|
2798
2831
|
def fetch_funding_rate(self, symbol: str, params={}):
|
2799
2832
|
"""
|
@@ -2817,7 +2850,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2817
2850
|
raise ArgumentsRequired(self.id + ' fetchFundingRates() requires a symbols argument')
|
2818
2851
|
self.load_markets()
|
2819
2852
|
marketIds = self.market_ids(symbols)
|
2820
|
-
request = {
|
2853
|
+
request: dict = {
|
2821
2854
|
'keys': ','.join(marketIds),
|
2822
2855
|
}
|
2823
2856
|
response = self.publicGetStatusDeriv(self.extend(request, params))
|
@@ -2873,7 +2906,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2873
2906
|
if paginate:
|
2874
2907
|
return self.fetch_paginated_call_deterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 5000)
|
2875
2908
|
market = self.market(symbol)
|
2876
|
-
request = {
|
2909
|
+
request: dict = {
|
2877
2910
|
'symbol': market['id'],
|
2878
2911
|
}
|
2879
2912
|
if since is not None:
|
@@ -3036,7 +3069,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3036
3069
|
"""
|
3037
3070
|
self.load_markets()
|
3038
3071
|
market = self.market(symbol)
|
3039
|
-
request = {
|
3072
|
+
request: dict = {
|
3040
3073
|
'keys': market['id'],
|
3041
3074
|
}
|
3042
3075
|
response = self.publicGetStatusDeriv(self.extend(request, params))
|
@@ -3092,7 +3125,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3092
3125
|
if paginate:
|
3093
3126
|
return self.fetch_paginated_call_deterministic('fetchOpenInterestHistory', symbol, since, limit, '8h', params, 5000)
|
3094
3127
|
market = self.market(symbol)
|
3095
|
-
request = {
|
3128
|
+
request: dict = {
|
3096
3129
|
'symbol': market['id'],
|
3097
3130
|
}
|
3098
3131
|
if since is not None:
|
@@ -3222,7 +3255,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3222
3255
|
if paginate:
|
3223
3256
|
return self.fetch_paginated_call_deterministic('fetchLiquidations', symbol, since, limit, '8h', params, 500)
|
3224
3257
|
market = self.market(symbol)
|
3225
|
-
request = {}
|
3258
|
+
request: dict = {}
|
3226
3259
|
if since is not None:
|
3227
3260
|
request['start'] = since
|
3228
3261
|
if limit is not None:
|
@@ -3302,7 +3335,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3302
3335
|
market = self.market(symbol)
|
3303
3336
|
if not market['swap']:
|
3304
3337
|
raise NotSupported(self.id + ' setMargin() only support swap markets')
|
3305
|
-
request = {
|
3338
|
+
request: dict = {
|
3306
3339
|
'symbol': market['id'],
|
3307
3340
|
'collateral': self.parse_to_numeric(amount),
|
3308
3341
|
}
|
@@ -3353,7 +3386,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3353
3386
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
3354
3387
|
"""
|
3355
3388
|
self.load_markets()
|
3356
|
-
request = {
|
3389
|
+
request: dict = {
|
3357
3390
|
'id': [self.parse_to_numeric(id)],
|
3358
3391
|
}
|
3359
3392
|
market = None
|
@@ -3427,7 +3460,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3427
3460
|
"""
|
3428
3461
|
self.load_markets()
|
3429
3462
|
market = self.market(symbol)
|
3430
|
-
request = {
|
3463
|
+
request: dict = {
|
3431
3464
|
'id': self.parse_to_numeric(id),
|
3432
3465
|
}
|
3433
3466
|
if amount is not None:
|