ccxt 4.4.9__py2.py3-none-any.whl → 4.4.10__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/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 +8 -11
- ccxt/async_support/bingx.py +20 -21
- ccxt/async_support/bitfinex2.py +7 -16
- ccxt/async_support/bitget.py +8 -7
- 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 +23 -6
- ccxt/async_support/hyperliquid.py +6 -1
- ccxt/async_support/krakenfutures.py +6 -5
- ccxt/async_support/kucoinfutures.py +13 -2
- ccxt/async_support/mexc.py +4 -3
- ccxt/async_support/oceanex.py +80 -4
- ccxt/async_support/okx.py +17 -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 +8 -11
- ccxt/bingx.py +20 -21
- ccxt/bitfinex2.py +7 -16
- ccxt/bitget.py +8 -7
- 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 +23 -6
- ccxt/hyperliquid.py +6 -1
- ccxt/krakenfutures.py +6 -5
- ccxt/kucoinfutures.py +13 -2
- ccxt/mexc.py +4 -3
- ccxt/oceanex.py +80 -4
- ccxt/okx.py +17 -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 +39 -2
- ccxt/pro/gate.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.10.dist-info/METADATA +636 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/RECORD +76 -76
- ccxt-4.4.9.dist-info/METADATA +0 -636
- {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/WHEEL +0 -0
- {ccxt-4.4.9.dist-info → ccxt-4.4.10.dist-info}/top_level.txt +0 -0
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
|
ccxt/gate.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.gate import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, 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, Currencies, Currency, FundingHistory, Greeks, Int, LedgerEntry, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, 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
|
@@ -1645,7 +1645,7 @@ class gate(Exchange, ImplicitAPI):
|
|
1645
1645
|
result[code]['withdraw'] = withdrawAvailable
|
1646
1646
|
return result
|
1647
1647
|
|
1648
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
1648
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
1649
1649
|
"""
|
1650
1650
|
fetch the current funding rate
|
1651
1651
|
:see: https://www.gate.io/docs/developers/apiv4/en/#get-a-single-contract
|
@@ -1705,13 +1705,13 @@ class gate(Exchange, ImplicitAPI):
|
|
1705
1705
|
#
|
1706
1706
|
return self.parse_funding_rate(response)
|
1707
1707
|
|
1708
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
1708
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
1709
1709
|
"""
|
1710
1710
|
fetch the funding rate for multiple markets
|
1711
1711
|
:see: https://www.gate.io/docs/developers/apiv4/en/#list-all-futures-contracts
|
1712
1712
|
:param str[]|None symbols: list of unified market symbols
|
1713
1713
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1714
|
-
:returns dict: a
|
1714
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
1715
1715
|
"""
|
1716
1716
|
self.load_markets()
|
1717
1717
|
symbols = self.market_symbols(symbols)
|
@@ -1764,7 +1764,7 @@ class gate(Exchange, ImplicitAPI):
|
|
1764
1764
|
result = self.parse_funding_rates(response)
|
1765
1765
|
return self.filter_by_array(result, 'symbol', symbols)
|
1766
1766
|
|
1767
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
1767
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
1768
1768
|
#
|
1769
1769
|
# {
|
1770
1770
|
# "name": "BTC_USDT",
|
@@ -1815,6 +1815,7 @@ class gate(Exchange, ImplicitAPI):
|
|
1815
1815
|
fundingRate = self.safe_number(contract, 'funding_rate')
|
1816
1816
|
fundingTime = self.safe_timestamp(contract, 'funding_next_apply')
|
1817
1817
|
fundingRateIndicative = self.safe_number(contract, 'funding_rate_indicative')
|
1818
|
+
fundingInterval = Precise.string_mul('1000', self.safe_string(contract, 'funding_interval'))
|
1818
1819
|
return {
|
1819
1820
|
'info': contract,
|
1820
1821
|
'symbol': symbol,
|
@@ -1833,8 +1834,19 @@ class gate(Exchange, ImplicitAPI):
|
|
1833
1834
|
'previousFundingRate': None,
|
1834
1835
|
'previousFundingTimestamp': None,
|
1835
1836
|
'previousFundingDatetime': None,
|
1837
|
+
'interval': self.parse_funding_interval(fundingInterval),
|
1836
1838
|
}
|
1837
1839
|
|
1840
|
+
def parse_funding_interval(self, interval):
|
1841
|
+
intervals: dict = {
|
1842
|
+
'3600000': '1h',
|
1843
|
+
'14400000': '4h',
|
1844
|
+
'28800000': '8h',
|
1845
|
+
'57600000': '16h',
|
1846
|
+
'86400000': '24h',
|
1847
|
+
}
|
1848
|
+
return self.safe_string(intervals, interval, interval)
|
1849
|
+
|
1838
1850
|
def fetch_network_deposit_address(self, code: str, params={}):
|
1839
1851
|
self.load_markets()
|
1840
1852
|
currency = self.currency(code)
|
@@ -4410,7 +4422,6 @@ class gate(Exchange, ImplicitAPI):
|
|
4410
4422
|
"""
|
4411
4423
|
self.load_markets()
|
4412
4424
|
until = self.safe_integer(params, 'until')
|
4413
|
-
params = self.omit(params, 'until')
|
4414
4425
|
market = None
|
4415
4426
|
if symbol is not None:
|
4416
4427
|
market = self.market(symbol)
|
@@ -4427,30 +4438,38 @@ class gate(Exchange, ImplicitAPI):
|
|
4427
4438
|
if since is not None:
|
4428
4439
|
request['from'] = self.parse_to_int(since / 1000)
|
4429
4440
|
if until is not None:
|
4441
|
+
params = self.omit(params, 'until')
|
4430
4442
|
request['to'] = self.parse_to_int(until / 1000)
|
4431
4443
|
if limit is not None:
|
4432
4444
|
request['limit'] = limit
|
4433
4445
|
response = self.privateFuturesGetSettleOrdersTimerange(self.extend(request, params))
|
4434
4446
|
return self.parse_orders(response, market, since, limit)
|
4435
4447
|
|
4436
|
-
def
|
4448
|
+
def prepare_orders_by_status_request(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
4437
4449
|
market = None
|
4438
4450
|
if symbol is not None:
|
4439
4451
|
market = self.market(symbol)
|
4440
4452
|
symbol = market['symbol']
|
4441
4453
|
stop = self.safe_bool_2(params, 'stop', 'trigger')
|
4442
4454
|
params = self.omit(params, ['stop', 'trigger'])
|
4443
|
-
type
|
4455
|
+
type: Str = None
|
4456
|
+
type, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
|
4444
4457
|
spot = (type == 'spot') or (type == 'margin')
|
4445
|
-
request
|
4458
|
+
request: dict = {}
|
4459
|
+
request, params = self.multi_order_spot_prepare_request(market, stop, params) if spot else self.prepare_request(market, type, params)
|
4446
4460
|
if status == 'closed':
|
4447
4461
|
status = 'finished'
|
4448
4462
|
request['status'] = status
|
4449
4463
|
if limit is not None:
|
4450
4464
|
request['limit'] = limit
|
4451
|
-
if
|
4452
|
-
|
4453
|
-
|
4465
|
+
if spot:
|
4466
|
+
if since is not None:
|
4467
|
+
request['from'] = self.parse_to_int(since / 1000)
|
4468
|
+
until = self.safe_integer(params, 'until')
|
4469
|
+
if until is not None:
|
4470
|
+
params = self.omit(params, 'until')
|
4471
|
+
request['to'] = self.parse_to_int(until / 1000)
|
4472
|
+
lastId, finalParams = self.handle_param_string_2(params, 'lastId', 'last_id')
|
4454
4473
|
if lastId is not None:
|
4455
4474
|
request['last_id'] = lastId
|
4456
4475
|
return [request, finalParams]
|
@@ -4466,7 +4485,7 @@ class gate(Exchange, ImplicitAPI):
|
|
4466
4485
|
res = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
|
4467
4486
|
type = self.safe_string(res, 0)
|
4468
4487
|
params['type'] = type
|
4469
|
-
request, requestParams = self.
|
4488
|
+
request, requestParams = self.prepare_orders_by_status_request(status, symbol, since, limit, params)
|
4470
4489
|
spot = (type == 'spot') or (type == 'margin')
|
4471
4490
|
openSpotOrders = spot and (status == 'open') and not stop
|
4472
4491
|
response = None
|
ccxt/hashkey.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.hashkey import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Account, Balances, Bool, Currencies, Currency, Int, LastPrice, LastPrices, LedgerEntry, Leverage, LeverageTier, LeverageTiers, Market, Num, Order, OrderBook, OrderRequest, 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
|
@@ -3491,7 +3491,7 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3491
3491
|
}
|
3492
3492
|
return self.safe_string(types, type, type)
|
3493
3493
|
|
3494
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
3494
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
3495
3495
|
"""
|
3496
3496
|
fetch the current funding rate
|
3497
3497
|
:see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
|
@@ -3514,13 +3514,13 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3514
3514
|
rate = self.safe_dict(response, 0, {})
|
3515
3515
|
return self.parse_funding_rate(rate, market)
|
3516
3516
|
|
3517
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
3517
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
3518
3518
|
"""
|
3519
3519
|
fetch the funding rate for multiple markets
|
3520
3520
|
:see: https://hashkeyglobal-apidoc.readme.io/reference/get-futures-funding-rate
|
3521
3521
|
:param str[]|None symbols: list of unified market symbols
|
3522
3522
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3523
|
-
:returns dict: a
|
3523
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rates-structure>`, indexed by market symbols
|
3524
3524
|
"""
|
3525
3525
|
self.load_markets()
|
3526
3526
|
symbols = self.market_symbols(symbols)
|
@@ -3537,9 +3537,8 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3537
3537
|
fundingRates = self.parse_funding_rates(response)
|
3538
3538
|
return self.filter_by_array(fundingRates, 'symbol', symbols)
|
3539
3539
|
|
3540
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
3540
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
3541
3541
|
#
|
3542
|
-
# fetchFundingRates
|
3543
3542
|
# {
|
3544
3543
|
# "symbol": "ETHUSDT-PERPETUAL",
|
3545
3544
|
# "rate": "0.0001",
|
@@ -3568,6 +3567,7 @@ class hashkey(Exchange, ImplicitAPI):
|
|
3568
3567
|
'previousFundingRate': None,
|
3569
3568
|
'previousFundingTimestamp': None,
|
3570
3569
|
'previousFundingDatetime': None,
|
3570
|
+
'interval': None,
|
3571
3571
|
}
|
3572
3572
|
|
3573
3573
|
def fetch_funding_rate_history(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
ccxt/hitbtc.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.hitbtc import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, MarginMode, MarginModes, MarginModification, Market, Num, Order, OrderBook, OrderSide, OrderType, 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
|
@@ -2536,13 +2536,13 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2536
2536
|
#
|
2537
2537
|
return self.parse_transaction(response, currency)
|
2538
2538
|
|
2539
|
-
def fetch_funding_rates(self, symbols: Strings = None, params={}):
|
2539
|
+
def fetch_funding_rates(self, symbols: Strings = None, params={}) -> FundingRates:
|
2540
2540
|
"""
|
2541
2541
|
fetches funding rates for multiple markets
|
2542
2542
|
:see: https://api.hitbtc.com/#futures-info
|
2543
2543
|
:param str[] symbols: unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
|
2544
2544
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2545
|
-
:returns dict:
|
2545
|
+
:returns dict[]: a list of `funding rate structures <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2546
2546
|
"""
|
2547
2547
|
self.load_markets()
|
2548
2548
|
market = None
|
@@ -2934,7 +2934,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2934
2934
|
#
|
2935
2935
|
return self.parse_open_interest(response, market)
|
2936
2936
|
|
2937
|
-
def fetch_funding_rate(self, symbol: str, params={}):
|
2937
|
+
def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2938
2938
|
"""
|
2939
2939
|
fetch the current funding rate
|
2940
2940
|
:see: https://api.hitbtc.com/#futures-info
|
@@ -2967,7 +2967,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
2967
2967
|
#
|
2968
2968
|
return self.parse_funding_rate(response, market)
|
2969
2969
|
|
2970
|
-
def parse_funding_rate(self, contract, market: Market = None):
|
2970
|
+
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2971
2971
|
#
|
2972
2972
|
# {
|
2973
2973
|
# "contract_type": "perpetual",
|
@@ -3003,6 +3003,7 @@ class hitbtc(Exchange, ImplicitAPI):
|
|
3003
3003
|
'previousFundingRate': None,
|
3004
3004
|
'previousFundingTimestamp': None,
|
3005
3005
|
'previousFundingDatetime': None,
|
3006
|
+
'interval': None,
|
3006
3007
|
}
|
3007
3008
|
|
3008
3009
|
def modify_margin_helper(self, symbol: str, amount, type, params={}) -> MarginModification:
|