ccxt 4.4.9__py2.py3-none-any.whl → 4.4.11__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 +1 -0
- ccxt/abstract/binancecoinm.py +1 -0
- ccxt/abstract/binanceus.py +1 -0
- ccxt/abstract/binanceusdm.py +1 -0
- ccxt/abstract/oceanex.py +5 -0
- ccxt/ascendex.py +5 -4
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/ascendex.py +5 -4
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +9 -11
- ccxt/async_support/bingx.py +20 -21
- ccxt/async_support/bitfinex2.py +7 -16
- ccxt/async_support/bitget.py +9 -8
- ccxt/async_support/bitmart.py +4 -3
- ccxt/async_support/bitmex.py +7 -6
- ccxt/async_support/blofin.py +7 -16
- ccxt/async_support/bybit.py +18 -16
- ccxt/async_support/coinex.py +19 -5
- ccxt/async_support/delta.py +6 -5
- ccxt/async_support/deribit.py +4 -3
- ccxt/async_support/digifinex.py +18 -4
- ccxt/async_support/gate.py +32 -13
- ccxt/async_support/hashkey.py +6 -6
- ccxt/async_support/hitbtc.py +6 -5
- ccxt/async_support/htx.py +29 -6
- ccxt/async_support/hyperliquid.py +6 -1
- ccxt/async_support/kraken.py +35 -13
- ccxt/async_support/krakenfutures.py +6 -5
- ccxt/async_support/kucoinfutures.py +13 -2
- ccxt/async_support/mexc.py +14 -7
- ccxt/async_support/oceanex.py +80 -4
- ccxt/async_support/okx.py +19 -3
- ccxt/async_support/oxfun.py +7 -7
- ccxt/async_support/phemex.py +4 -3
- ccxt/async_support/poloniexfutures.py +13 -2
- ccxt/async_support/vertex.py +6 -5
- ccxt/async_support/whitebit.py +14 -13
- ccxt/async_support/woo.py +42 -21
- ccxt/async_support/woofipro.py +19 -6
- ccxt/async_support/xt.py +5 -3
- ccxt/base/exchange.py +1 -1
- ccxt/base/types.py +1 -0
- ccxt/binance.py +9 -11
- ccxt/bingx.py +20 -21
- ccxt/bitfinex2.py +7 -16
- ccxt/bitget.py +9 -8
- ccxt/bitmart.py +4 -3
- ccxt/bitmex.py +7 -6
- ccxt/blofin.py +7 -16
- ccxt/bybit.py +18 -16
- ccxt/coinex.py +19 -5
- ccxt/delta.py +6 -5
- ccxt/deribit.py +4 -3
- ccxt/digifinex.py +18 -4
- ccxt/gate.py +32 -13
- ccxt/hashkey.py +6 -6
- ccxt/hitbtc.py +6 -5
- ccxt/htx.py +29 -6
- ccxt/hyperliquid.py +6 -1
- ccxt/kraken.py +35 -13
- ccxt/krakenfutures.py +6 -5
- ccxt/kucoinfutures.py +13 -2
- ccxt/mexc.py +14 -7
- ccxt/oceanex.py +80 -4
- ccxt/okx.py +19 -3
- ccxt/oxfun.py +7 -7
- ccxt/phemex.py +4 -3
- ccxt/poloniexfutures.py +13 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/deribit.py +114 -2
- ccxt/pro/exmo.py +29 -2
- ccxt/pro/gate.py +1 -1
- ccxt/pro/okx.py +1 -1
- ccxt/vertex.py +6 -5
- ccxt/whitebit.py +14 -13
- ccxt/woo.py +42 -21
- ccxt/woofipro.py +19 -6
- ccxt/xt.py +5 -3
- ccxt-4.4.11.dist-info/METADATA +636 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.11.dist-info}/RECORD +84 -84
- ccxt-4.4.9.dist-info/METADATA +0 -636
- {ccxt-4.4.9.dist-info → ccxt-4.4.11.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.11.dist-info}/WHEEL +0 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.11.dist-info}/top_level.txt +0 -0
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, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -82,7 +82,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
82
82
|
'fetchDepositAddress': True,
|
83
83
|
'fetchDepositsWithdrawals': True,
|
84
84
|
'fetchFundingHistory': False,
|
85
|
-
'fetchFundingRate':
|
85
|
+
'fetchFundingRate': 'emulated', # emulated in exchange
|
86
86
|
'fetchFundingRateHistory': True,
|
87
87
|
'fetchFundingRates': True,
|
88
88
|
'fetchIndexOHLCV': False,
|
@@ -2829,23 +2829,13 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2829
2829
|
ledgerObjects.append({'result': item})
|
2830
2830
|
return self.parse_ledger(ledgerObjects, currency, since, limit)
|
2831
2831
|
|
2832
|
-
def
|
2832
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2833
2833
|
"""
|
2834
|
-
fetch the current funding rate
|
2835
|
-
:see: https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
2836
|
-
:param str symbol: unified market symbol
|
2837
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2838
|
-
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2839
|
-
"""
|
2840
|
-
return self.fetch_funding_rates([symbol], params)
|
2841
|
-
|
2842
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2843
|
-
"""
|
2844
|
-
fetch the current funding rate
|
2834
|
+
fetch the current funding rate for multiple symbols
|
2845
2835
|
:see: https://docs.bitfinex.com/reference/rest-public-derivatives-status
|
2846
2836
|
:param str[] symbols: list of unified market symbols
|
2847
2837
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2848
|
-
:returns dict: a `funding rate
|
2838
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2849
2839
|
"""
|
2850
2840
|
if symbols is None:
|
2851
2841
|
raise ArgumentsRequired(self.id + ' fetchFundingRates() requires a symbols argument')
|
@@ -2958,7 +2948,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
2958
2948
|
reversedArray.append(valueAtIndex)
|
2959
2949
|
return reversedArray
|
2960
2950
|
|
2961
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2951
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2962
2952
|
#
|
2963
2953
|
# [
|
2964
2954
|
# "tBTCF0:USTF0",
|
@@ -3008,6 +2998,7 @@ class bitfinex2(Exchange, ImplicitAPI):
|
|
3008
2998
|
'previousFundingRate': None,
|
3009
2999
|
'previousFundingTimestamp': None,
|
3010
3000
|
'previousFundingDatetime': None,
|
3001
|
+
'interval': None,
|
3011
3002
|
}
|
3012
3003
|
|
3013
3004
|
def parse_funding_rate_history(self, contract, market: Market = 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, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, FundingHistory, Int, IsolatedBorrowRate, LedgerEntry, Leverage, LeverageTier, Liquidation, MarginMode, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -1434,16 +1434,16 @@ class bitget(Exchange, ImplicitAPI):
|
|
1434
1434
|
},
|
1435
1435
|
'sandboxMode': False,
|
1436
1436
|
'networks': {
|
1437
|
-
'
|
1438
|
-
'
|
1437
|
+
'TRC20': 'TRC20',
|
1438
|
+
'ERC20': 'ERC20',
|
1439
1439
|
'BEP20': 'BSC',
|
1440
|
+
'ARB': 'ArbitrumOne',
|
1440
1441
|
'ZKSYNC': 'zkSyncEra',
|
1441
1442
|
'STARKNET': 'Starknet',
|
1442
|
-
'OPTIMISM': 'Optimism',
|
1443
|
-
'ARBITRUM': 'Arbitrum',
|
1444
1443
|
'APT': 'APTOS',
|
1445
|
-
'MATIC': '
|
1444
|
+
'MATIC': 'Polygon',
|
1446
1445
|
'VIC': 'VICTION',
|
1446
|
+
'AVAXC': 'C-Chain',
|
1447
1447
|
},
|
1448
1448
|
'networksById': {
|
1449
1449
|
},
|
@@ -6259,7 +6259,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6259
6259
|
sorted = self.sort_by(rates, 'timestamp')
|
6260
6260
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
6261
6261
|
|
6262
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
6262
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
6263
6263
|
"""
|
6264
6264
|
fetch the current funding rate
|
6265
6265
|
:see: https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
|
@@ -6300,7 +6300,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6300
6300
|
data = self.safe_value(response, 'data', [])
|
6301
6301
|
return self.parse_funding_rate(data[0], market)
|
6302
6302
|
|
6303
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
6303
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
6304
6304
|
#
|
6305
6305
|
# {
|
6306
6306
|
# "symbol": "BTCUSDT",
|
@@ -6327,6 +6327,7 @@ class bitget(Exchange, ImplicitAPI):
|
|
6327
6327
|
'previousFundingRate': None,
|
6328
6328
|
'previousFundingTimestamp': None,
|
6329
6329
|
'previousFundingDatetime': None,
|
6330
|
+
'interval': None,
|
6330
6331
|
}
|
6331
6332
|
|
6332
6333
|
def fetch_funding_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[FundingHistory]:
|
ccxt/bitmart.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitmart import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -4138,7 +4138,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4138
4138
|
}
|
4139
4139
|
return self.privatePostContractPrivateSubmitLeverage(self.extend(request, params))
|
4140
4140
|
|
4141
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
4141
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
4142
4142
|
"""
|
4143
4143
|
fetch the current funding rate
|
4144
4144
|
:see: https://developer-pro.bitmart.com/en/futuresv2/#get-current-funding-rate
|
@@ -4170,7 +4170,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4170
4170
|
data = self.safe_value(response, 'data', {})
|
4171
4171
|
return self.parse_funding_rate(data, market)
|
4172
4172
|
|
4173
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
4173
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
4174
4174
|
#
|
4175
4175
|
# {
|
4176
4176
|
# "timestamp": 1695184410697,
|
@@ -4199,6 +4199,7 @@ class bitmart(Exchange, ImplicitAPI):
|
|
4199
4199
|
'previousFundingRate': self.safe_number(contract, 'rate_value'),
|
4200
4200
|
'previousFundingTimestamp': None,
|
4201
4201
|
'previousFundingDatetime': None,
|
4202
|
+
'interval': None,
|
4202
4203
|
}
|
4203
4204
|
|
4204
4205
|
def fetch_position(self, symbol: str, params={}):
|
ccxt/bitmex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bitmex import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, LedgerEntry, Leverage, Leverages, Market, MarketType, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, Transaction
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -67,7 +67,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
67
67
|
'fetchDepositWithdrawFee': 'emulated',
|
68
68
|
'fetchDepositWithdrawFees': True,
|
69
69
|
'fetchFundingHistory': False,
|
70
|
-
'fetchFundingRate':
|
70
|
+
'fetchFundingRate': 'emulated', # emulated in exchange
|
71
71
|
'fetchFundingRateHistory': True,
|
72
72
|
'fetchFundingRates': True,
|
73
73
|
'fetchIndexOHLCV': False,
|
@@ -2331,13 +2331,13 @@ class bitmex(Exchange, ImplicitAPI):
|
|
2331
2331
|
#
|
2332
2332
|
return self.parse_transaction(response, currency)
|
2333
2333
|
|
2334
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2334
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2335
2335
|
"""
|
2336
2336
|
fetch the funding rate for multiple markets
|
2337
2337
|
:see: https://www.bitmex.com/api/explorer/#not /Instrument/Instrument_getActiveAndIndices
|
2338
2338
|
:param str[]|None symbols: list of unified market symbols
|
2339
2339
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2340
|
-
:returns dict: a
|
2340
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
2341
2341
|
"""
|
2342
2342
|
self.load_markets()
|
2343
2343
|
response = self.publicGetInstrumentActiveAndIndices(params)
|
@@ -2354,7 +2354,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
2354
2354
|
result = self.parse_funding_rates(filteredResponse)
|
2355
2355
|
return self.filter_by_array(result, 'symbol', symbols)
|
2356
2356
|
|
2357
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2357
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2358
2358
|
# see response sample under "fetchMarkets" because same endpoint is being used here
|
2359
2359
|
datetime = self.safe_string(contract, 'timestamp')
|
2360
2360
|
marketId = self.safe_string(contract, 'symbol')
|
@@ -2369,7 +2369,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
2369
2369
|
'timestamp': self.parse8601(datetime),
|
2370
2370
|
'datetime': datetime,
|
2371
2371
|
'fundingRate': self.safe_number(contract, 'fundingRate'),
|
2372
|
-
'fundingTimestamp': self.iso8601(fundingDatetime),
|
2372
|
+
'fundingTimestamp': self.parse_to_numeric(self.iso8601(fundingDatetime)),
|
2373
2373
|
'fundingDatetime': fundingDatetime,
|
2374
2374
|
'nextFundingRate': self.safe_number(contract, 'indicativeFundingRate'),
|
2375
2375
|
'nextFundingTimestamp': None,
|
@@ -2377,6 +2377,7 @@ class bitmex(Exchange, ImplicitAPI):
|
|
2377
2377
|
'previousFundingRate': None,
|
2378
2378
|
'previousFundingTimestamp': None,
|
2379
2379
|
'previousFundingDatetime': None,
|
2380
|
+
'interval': None,
|
2380
2381
|
}
|
2381
2382
|
|
2382
2383
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
ccxt/blofin.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.blofin import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currency, Int, LedgerEntry, Leverage, Leverages, MarginMode, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -768,23 +768,16 @@ class blofin(Exchange, ImplicitAPI):
|
|
768
768
|
sorted = self.sort_by(rates, 'timestamp')
|
769
769
|
return self.filter_by_symbol_since_limit(sorted, market['symbol'], since, limit)
|
770
770
|
|
771
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
771
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
772
772
|
#
|
773
773
|
# {
|
774
774
|
# "fundingRate": "0.00027815",
|
775
775
|
# "fundingTime": "1634256000000",
|
776
776
|
# "instId": "BTC-USD-SWAP",
|
777
|
-
# "instType": "SWAP",
|
778
|
-
# "nextFundingRate": "0.00017",
|
779
|
-
# "nextFundingTime": "1634284800000"
|
780
777
|
# }
|
781
778
|
#
|
782
|
-
# in the response above nextFundingRate is actually two funding rates from now
|
783
|
-
#
|
784
|
-
nextFundingRateTimestamp = self.safe_integer(contract, 'nextFundingTime')
|
785
779
|
marketId = self.safe_string(contract, 'instId')
|
786
780
|
symbol = self.safe_symbol(marketId, market)
|
787
|
-
nextFundingRate = self.safe_number(contract, 'nextFundingRate')
|
788
781
|
fundingTime = self.safe_integer(contract, 'fundingTime')
|
789
782
|
# > The current interest is 0.
|
790
783
|
return {
|
@@ -799,15 +792,16 @@ class blofin(Exchange, ImplicitAPI):
|
|
799
792
|
'fundingRate': self.safe_number(contract, 'fundingRate'),
|
800
793
|
'fundingTimestamp': fundingTime,
|
801
794
|
'fundingDatetime': self.iso8601(fundingTime),
|
802
|
-
'nextFundingRate':
|
803
|
-
'nextFundingTimestamp':
|
804
|
-
'nextFundingDatetime':
|
795
|
+
'nextFundingRate': None,
|
796
|
+
'nextFundingTimestamp': None,
|
797
|
+
'nextFundingDatetime': None,
|
805
798
|
'previousFundingRate': None,
|
806
799
|
'previousFundingTimestamp': None,
|
807
800
|
'previousFundingDatetime': None,
|
801
|
+
'interval': None,
|
808
802
|
}
|
809
803
|
|
810
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
804
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
811
805
|
"""
|
812
806
|
fetch the current funding rate
|
813
807
|
:see: https://blofin.com/docs#get-funding-rate
|
@@ -831,9 +825,6 @@ class blofin(Exchange, ImplicitAPI):
|
|
831
825
|
# "fundingRate": "0.00027815",
|
832
826
|
# "fundingTime": "1634256000000",
|
833
827
|
# "instId": "BTC-USD-SWAP",
|
834
|
-
# "instType": "SWAP",
|
835
|
-
# "nextFundingRate": "0.00017",
|
836
|
-
# "nextFundingTime": "1634284800000"
|
837
828
|
# }
|
838
829
|
# ],
|
839
830
|
# "msg": ""
|
ccxt/bybit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.bybit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Conversion, CrossBorrowRate, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -95,7 +95,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
95
95
|
'fetchDepositWithdrawFee': 'emulated',
|
96
96
|
'fetchDepositWithdrawFees': True,
|
97
97
|
'fetchFundingHistory': True,
|
98
|
-
'fetchFundingRate':
|
98
|
+
'fetchFundingRate': 'emulated', # emulated in exchange
|
99
99
|
'fetchFundingRateHistory': True,
|
100
100
|
'fetchFundingRates': True,
|
101
101
|
'fetchGreeks': True,
|
@@ -2344,7 +2344,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
2344
2344
|
ohlcvs = self.safe_list(result, 'list', [])
|
2345
2345
|
return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
|
2346
2346
|
|
2347
|
-
def parse_funding_rate(self, ticker, market: Market = None):
|
2347
|
+
def parse_funding_rate(self, ticker, market: Market = None) -> FundingRate:
|
2348
|
+
#
|
2348
2349
|
# {
|
2349
2350
|
# "symbol": "BTCUSDT",
|
2350
2351
|
# "bidPrice": "19255",
|
@@ -2395,15 +2396,16 @@ class bybit(Exchange, ImplicitAPI):
|
|
2395
2396
|
'previousFundingRate': None,
|
2396
2397
|
'previousFundingTimestamp': None,
|
2397
2398
|
'previousFundingDatetime': None,
|
2399
|
+
'interval': None,
|
2398
2400
|
}
|
2399
2401
|
|
2400
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2402
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2401
2403
|
"""
|
2402
2404
|
fetches funding rates for multiple markets
|
2403
2405
|
:see: https://bybit-exchange.github.io/docs/v5/market/tickers
|
2404
2406
|
:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
|
2405
2407
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2406
|
-
:returns dict:
|
2408
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2407
2409
|
"""
|
2408
2410
|
self.load_markets()
|
2409
2411
|
market = None
|
@@ -2459,17 +2461,10 @@ class bybit(Exchange, ImplicitAPI):
|
|
2459
2461
|
# "time": 1663670053454
|
2460
2462
|
# }
|
2461
2463
|
#
|
2462
|
-
|
2463
|
-
|
2464
|
-
|
2465
|
-
|
2466
|
-
for i in range(0, len(tickerList)):
|
2467
|
-
rawTicker = tickerList[i]
|
2468
|
-
rawTicker['timestamp'] = timestamp # will be removed inside the parser
|
2469
|
-
ticker = self.parse_funding_rate(tickerList[i], None)
|
2470
|
-
symbol = ticker['symbol']
|
2471
|
-
fundingRates[symbol] = ticker
|
2472
|
-
return self.filter_by_array(fundingRates, 'symbol', symbols)
|
2464
|
+
data = self.safe_dict(response, 'result', {})
|
2465
|
+
tickerList = self.safe_list(data, 'list', [])
|
2466
|
+
result = self.parse_funding_rates(tickerList)
|
2467
|
+
return self.filter_by_array(result, 'symbol', symbols)
|
2473
2468
|
|
2474
2469
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
2475
2470
|
"""
|
@@ -3517,6 +3512,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
3517
3512
|
# 'orderIv': '0', # Implied volatility; parameters are passed according to the real value; for example, for 10%, 0.1 is passed
|
3518
3513
|
}
|
3519
3514
|
hedged = self.safe_bool(params, 'hedged', False)
|
3515
|
+
reduceOnly = self.safe_bool(params, 'reduceOnly')
|
3520
3516
|
triggerPrice = self.safe_value_2(params, 'triggerPrice', 'stopPrice')
|
3521
3517
|
stopLossTriggerPrice = self.safe_value(params, 'stopLossPrice')
|
3522
3518
|
takeProfitTriggerPrice = self.safe_value(params, 'takeProfitPrice')
|
@@ -3667,6 +3663,9 @@ class bybit(Exchange, ImplicitAPI):
|
|
3667
3663
|
request['tpOrderType'] = 'Limit'
|
3668
3664
|
request['tpLimitPrice'] = self.get_price(symbol, tpLimitPrice)
|
3669
3665
|
if not market['spot'] and hedged:
|
3666
|
+
if reduceOnly:
|
3667
|
+
params = self.omit(params, 'reduceOnly')
|
3668
|
+
side = 'sell' if (side == 'buy') else 'buy'
|
3670
3669
|
request['positionIdx'] = 1 if (side == 'buy') else 2
|
3671
3670
|
params = self.omit(params, ['stopPrice', 'timeInForce', 'stopLossPrice', 'takeProfitPrice', 'postOnly', 'clientOrderId', 'triggerPrice', 'stopLoss', 'takeProfit', 'trailingAmount', 'trailingTriggerPrice', 'hedged'])
|
3672
3671
|
return self.extend(request, params)
|
@@ -6344,6 +6343,8 @@ class bybit(Exchange, ImplicitAPI):
|
|
6344
6343
|
initialMarginString = Precise.string_div(size, Precise.string_mul(entryPrice, leverage))
|
6345
6344
|
maintenanceMarginPercentage = Precise.string_div(maintenanceMarginString, notional)
|
6346
6345
|
marginRatio = Precise.string_div(maintenanceMarginString, collateralString, 4)
|
6346
|
+
positionIdx = self.safe_string(position, 'positionIdx')
|
6347
|
+
hedged = (positionIdx is not None) and (positionIdx != '0')
|
6347
6348
|
return self.safe_position({
|
6348
6349
|
'info': position,
|
6349
6350
|
'id': None,
|
@@ -6372,6 +6373,7 @@ class bybit(Exchange, ImplicitAPI):
|
|
6372
6373
|
'percentage': None,
|
6373
6374
|
'stopLossPrice': self.safe_number_2(position, 'stop_loss', 'stopLoss'),
|
6374
6375
|
'takeProfitPrice': self.safe_number_2(position, 'take_profit', 'takeProfit'),
|
6376
|
+
'hedged': hedged,
|
6375
6377
|
})
|
6376
6378
|
|
6377
6379
|
def fetch_leverage(self, symbol: str, params={}) -> Leverage:
|
ccxt/coinex.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinex import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, Leverage, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import ExchangeError
|
11
11
|
from ccxt.base.errors import AuthenticationError
|
@@ -4253,7 +4253,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4253
4253
|
})
|
4254
4254
|
return result
|
4255
4255
|
|
4256
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
4256
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
4257
4257
|
"""
|
4258
4258
|
fetch the current funding rate
|
4259
4259
|
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
@@ -4291,7 +4291,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
4291
4291
|
first = self.safe_dict(data, 0, {})
|
4292
4292
|
return self.parse_funding_rate(first, market)
|
4293
4293
|
|
4294
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
4294
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
4295
4295
|
#
|
4296
4296
|
# fetchFundingRate, fetchFundingRates
|
4297
4297
|
#
|
@@ -4308,6 +4308,9 @@ class coinex(Exchange, ImplicitAPI):
|
|
4308
4308
|
#
|
4309
4309
|
currentFundingTimestamp = self.safe_integer(contract, 'latest_funding_time')
|
4310
4310
|
futureFundingTimestamp = self.safe_integer(contract, 'next_funding_time')
|
4311
|
+
fundingTimeString = self.safe_string(contract, 'latest_funding_time')
|
4312
|
+
nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
|
4313
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
4311
4314
|
marketId = self.safe_string(contract, 'market')
|
4312
4315
|
return {
|
4313
4316
|
'info': contract,
|
@@ -4327,11 +4330,22 @@ class coinex(Exchange, ImplicitAPI):
|
|
4327
4330
|
'previousFundingRate': None,
|
4328
4331
|
'previousFundingTimestamp': None,
|
4329
4332
|
'previousFundingDatetime': None,
|
4333
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
4330
4334
|
}
|
4331
4335
|
|
4332
|
-
def
|
4336
|
+
def parse_funding_interval(self, interval):
|
4337
|
+
intervals: dict = {
|
4338
|
+
'3600000': '1h',
|
4339
|
+
'14400000': '4h',
|
4340
|
+
'28800000': '8h',
|
4341
|
+
'57600000': '16h',
|
4342
|
+
'86400000': '24h',
|
4343
|
+
}
|
4344
|
+
return self.safe_string(intervals, interval, interval)
|
4345
|
+
|
4346
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
4333
4347
|
"""
|
4334
|
-
fetch the current funding rates
|
4348
|
+
fetch the current funding rates for multiple markets
|
4335
4349
|
:see: https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
4336
4350
|
:param str[] symbols: unified market symbols
|
4337
4351
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
ccxt/delta.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.delta import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, MarginMode, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Greeks, Int, LedgerEntry, Leverage, MarginMode, MarginModification, Market, MarketInterface, Num, Option, Order, OrderBook, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, FundingRate, FundingRates, Trade
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2288,7 +2288,7 @@ class delta(Exchange, ImplicitAPI):
|
|
2288
2288
|
'info': depositAddress,
|
2289
2289
|
}
|
2290
2290
|
|
2291
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
2291
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2292
2292
|
"""
|
2293
2293
|
fetch the current funding rate
|
2294
2294
|
:see: https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
|
@@ -2352,13 +2352,13 @@ class delta(Exchange, ImplicitAPI):
|
|
2352
2352
|
result = self.safe_dict(response, 'result', {})
|
2353
2353
|
return self.parse_funding_rate(result, market)
|
2354
2354
|
|
2355
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2355
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2356
2356
|
"""
|
2357
2357
|
fetch the funding rate for multiple markets
|
2358
2358
|
:see: https://docs.delta.exchange/#get-tickers-for-products
|
2359
2359
|
:param str[]|None symbols: list of unified market symbols
|
2360
2360
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2361
|
-
:returns dict: a
|
2361
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
2362
2362
|
"""
|
2363
2363
|
self.load_markets()
|
2364
2364
|
symbols = self.market_symbols(symbols)
|
@@ -2417,7 +2417,7 @@ class delta(Exchange, ImplicitAPI):
|
|
2417
2417
|
result = self.parse_funding_rates(rates)
|
2418
2418
|
return self.filter_by_array(result, 'symbol', symbols)
|
2419
2419
|
|
2420
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2420
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2421
2421
|
#
|
2422
2422
|
# {
|
2423
2423
|
# "close": 30600.5,
|
@@ -2482,6 +2482,7 @@ class delta(Exchange, ImplicitAPI):
|
|
2482
2482
|
'previousFundingRate': None,
|
2483
2483
|
'previousFundingTimestamp': None,
|
2484
2484
|
'previousFundingDatetime': None,
|
2485
|
+
'interval': None,
|
2485
2486
|
}
|
2486
2487
|
|
2487
2488
|
def add_margin(self, symbol: str, amount: float, params={}) -> MarginModification:
|
ccxt/deribit.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.deribit import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Currencies, Currency, Greeks, Int, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Currencies, Currency, Greeks, Int, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -2852,7 +2852,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2852
2852
|
data = self.safe_list(response, 'result', [])
|
2853
2853
|
return self.parse_deposit_withdraw_fees(data, codes, 'currency')
|
2854
2854
|
|
2855
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
2855
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2856
2856
|
"""
|
2857
2857
|
fetch the current funding rate
|
2858
2858
|
:see: https://docs.deribit.com/#public-get_funding_rate_value
|
@@ -2932,7 +2932,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2932
2932
|
rates.append(rate)
|
2933
2933
|
return self.filter_by_symbol_since_limit(rates, symbol, since, limit)
|
2934
2934
|
|
2935
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2935
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2936
2936
|
#
|
2937
2937
|
# {
|
2938
2938
|
# "jsonrpc":"2.0",
|
@@ -2972,6 +2972,7 @@ class deribit(Exchange, ImplicitAPI):
|
|
2972
2972
|
'previousFundingRate': None,
|
2973
2973
|
'previousFundingTimestamp': None,
|
2974
2974
|
'previousFundingDatetime': None,
|
2975
|
+
'interval': '8h',
|
2975
2976
|
}
|
2976
2977
|
|
2977
2978
|
def fetch_liquidations(self, symbol: str, since: Int = None, limit: Int = None, params={}):
|
ccxt/digifinex.py
CHANGED
@@ -7,7 +7,7 @@ from ccxt.base.exchange import Exchange
|
|
7
7
|
from ccxt.abstract.digifinex import ImplicitAPI
|
8
8
|
import hashlib
|
9
9
|
import json
|
10
|
-
from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
10
|
+
from ccxt.base.types import Balances, CrossBorrowRate, CrossBorrowRates, Currencies, Currency, Int, LedgerEntry, LeverageTier, LeverageTiers, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFeeInterface, Transaction, TransferEntry
|
11
11
|
from typing import List
|
12
12
|
from ccxt.base.errors import ExchangeError
|
13
13
|
from ccxt.base.errors import AuthenticationError
|
@@ -2980,7 +2980,7 @@ class digifinex(Exchange, ImplicitAPI):
|
|
2980
2980
|
result[code] = borrowRate
|
2981
2981
|
return result
|
2982
2982
|
|
2983
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
2983
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2984
2984
|
"""
|
2985
2985
|
fetch the current funding rate
|
2986
2986
|
:see: https://docs.digifinex.com/en-ww/swap/v2/rest.html#currentfundingrate
|
@@ -3011,7 +3011,7 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3011
3011
|
data = self.safe_value(response, 'data', {})
|
3012
3012
|
return self.parse_funding_rate(data, market)
|
3013
3013
|
|
3014
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3014
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3015
3015
|
#
|
3016
3016
|
# {
|
3017
3017
|
# "instrument_id": "BTCUSDTPERP",
|
@@ -3024,6 +3024,9 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3024
3024
|
marketId = self.safe_string(contract, 'instrument_id')
|
3025
3025
|
timestamp = self.safe_integer(contract, 'funding_time')
|
3026
3026
|
nextTimestamp = self.safe_integer(contract, 'next_funding_time')
|
3027
|
+
fundingTimeString = self.safe_string(contract, 'funding_time')
|
3028
|
+
nextFundingTimeString = self.safe_string(contract, 'next_funding_time')
|
3029
|
+
millisecondsInterval = Precise.string_sub(nextFundingTimeString, fundingTimeString)
|
3027
3030
|
return {
|
3028
3031
|
'info': contract,
|
3029
3032
|
'symbol': self.safe_symbol(marketId, market),
|
@@ -3036,14 +3039,25 @@ class digifinex(Exchange, ImplicitAPI):
|
|
3036
3039
|
'fundingRate': self.safe_number(contract, 'funding_rate'),
|
3037
3040
|
'fundingTimestamp': timestamp,
|
3038
3041
|
'fundingDatetime': self.iso8601(timestamp),
|
3039
|
-
'nextFundingRate': self.
|
3042
|
+
'nextFundingRate': self.safe_number(contract, 'next_funding_rate'),
|
3040
3043
|
'nextFundingTimestamp': nextTimestamp,
|
3041
3044
|
'nextFundingDatetime': self.iso8601(nextTimestamp),
|
3042
3045
|
'previousFundingRate': None,
|
3043
3046
|
'previousFundingTimestamp': None,
|
3044
3047
|
'previousFundingDatetime': None,
|
3048
|
+
'interval': self.parse_funding_interval(millisecondsInterval),
|
3045
3049
|
}
|
3046
3050
|
|
3051
|
+
def parse_funding_interval(self, interval):
|
3052
|
+
intervals: dict = {
|
3053
|
+
'3600000': '1h',
|
3054
|
+
'14400000': '4h',
|
3055
|
+
'28800000': '8h',
|
3056
|
+
'57600000': '16h',
|
3057
|
+
'86400000': '24h',
|
3058
|
+
}
|
3059
|
+
return self.safe_string(intervals, interval, interval)
|
3060
|
+
|
3047
3061
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3048
3062
|
"""
|
3049
3063
|
fetches historical funding rate prices
|