Removed docstring indents
This commit is contained in:
parent
d0b91b334e
commit
6c8501dadc
@ -231,8 +231,8 @@ class Binance(Exchange):
|
|||||||
|
|
||||||
def funding_fee_cutoff(self, d: datetime):
|
def funding_fee_cutoff(self, d: datetime):
|
||||||
'''
|
'''
|
||||||
# TODO-lev: Double check that gateio, ftx, and kraken don't also have this
|
# TODO-lev: Double check that gateio, ftx, and kraken don't also have this
|
||||||
:param d: The open date for a trade
|
:param d: The open date for a trade
|
||||||
:return: The cutoff open time for when a funding fee is charged
|
:return: The cutoff open time for when a funding fee is charged
|
||||||
'''
|
'''
|
||||||
return d.minute > 0 or (d.minute == 0 and d.second > 15)
|
return d.minute > 0 or (d.minute == 0 and d.second > 15)
|
||||||
|
@ -1608,10 +1608,10 @@ class Exchange:
|
|||||||
@retrier
|
@retrier
|
||||||
def _get_funding_fees_from_exchange(self, pair: str, since: Union[datetime, int]) -> float:
|
def _get_funding_fees_from_exchange(self, pair: str, since: Union[datetime, int]) -> float:
|
||||||
"""
|
"""
|
||||||
Returns the sum of all funding fees that were exchanged for a pair within a timeframe
|
Returns the sum of all funding fees that were exchanged for a pair within a timeframe
|
||||||
:param pair: (e.g. ADA/USDT)
|
:param pair: (e.g. ADA/USDT)
|
||||||
:param since: The earliest time of consideration for calculating funding fees,
|
:param since: The earliest time of consideration for calculating funding fees,
|
||||||
in unix time or as a datetime
|
in unix time or as a datetime
|
||||||
"""
|
"""
|
||||||
# TODO-lev: Add dry-run handling for this.
|
# TODO-lev: Add dry-run handling for this.
|
||||||
|
|
||||||
@ -1638,17 +1638,17 @@ class Exchange:
|
|||||||
|
|
||||||
def fill_leverage_brackets(self):
|
def fill_leverage_brackets(self):
|
||||||
"""
|
"""
|
||||||
Assigns property _leverage_brackets to a dictionary of information about the leverage
|
Assigns property _leverage_brackets to a dictionary of information about the leverage
|
||||||
allowed on each pair
|
allowed on each pair
|
||||||
Not used if the exchange has a static max leverage value for the account or each pair
|
Not used if the exchange has a static max leverage value for the account or each pair
|
||||||
"""
|
"""
|
||||||
return
|
return
|
||||||
|
|
||||||
def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float:
|
def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float:
|
||||||
"""
|
"""
|
||||||
Returns the maximum leverage that a pair can be traded at
|
Returns the maximum leverage that a pair can be traded at
|
||||||
:param pair: The base/quote currency pair being traded
|
:param pair: The base/quote currency pair being traded
|
||||||
:nominal_value: The total value of the trade in quote currency (collateral + debt)
|
:nominal_value: The total value of the trade in quote currency (collateral + debt)
|
||||||
"""
|
"""
|
||||||
market = self.markets[pair]
|
market = self.markets[pair]
|
||||||
if (
|
if (
|
||||||
@ -1668,13 +1668,13 @@ class Exchange:
|
|||||||
time_in_ratio: Optional[float] = None
|
time_in_ratio: Optional[float] = None
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
Calculates a single funding fee
|
Calculates a single funding fee
|
||||||
:param size: contract size * number of contracts
|
:param size: contract size * number of contracts
|
||||||
:param mark_price: The price of the asset that the contract is based off of
|
:param mark_price: The price of the asset that the contract is based off of
|
||||||
:param funding_rate: the interest rate and the premium
|
:param funding_rate: the interest rate and the premium
|
||||||
- interest rate:
|
- interest rate:
|
||||||
- premium: varies by price difference between the perpetual contract and mark price
|
- premium: varies by price difference between the perpetual contract and mark price
|
||||||
:param time_in_ratio: Not used by most exchange classes
|
:param time_in_ratio: Not used by most exchange classes
|
||||||
"""
|
"""
|
||||||
nominal_value = mark_price * size
|
nominal_value = mark_price * size
|
||||||
return nominal_value * funding_rate
|
return nominal_value * funding_rate
|
||||||
@ -1687,8 +1687,8 @@ class Exchange:
|
|||||||
trading_mode: Optional[TradingMode] = None
|
trading_mode: Optional[TradingMode] = None
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Set's the leverage before making a trade, in order to not
|
Set's the leverage before making a trade, in order to not
|
||||||
have the same leverage on every trade
|
have the same leverage on every trade
|
||||||
"""
|
"""
|
||||||
if self._config['dry_run'] or not self.exchange_has("setLeverage"):
|
if self._config['dry_run'] or not self.exchange_has("setLeverage"):
|
||||||
# Some exchanges only support one collateral type
|
# Some exchanges only support one collateral type
|
||||||
@ -1706,8 +1706,8 @@ class Exchange:
|
|||||||
|
|
||||||
def funding_fee_cutoff(self, d: datetime):
|
def funding_fee_cutoff(self, d: datetime):
|
||||||
'''
|
'''
|
||||||
:param d: The open date for a trade
|
:param d: The open date for a trade
|
||||||
:return: The cutoff open time for when a funding fee is charged
|
:return: The cutoff open time for when a funding fee is charged
|
||||||
'''
|
'''
|
||||||
return d.minute > 0 or d.second > 0
|
return d.minute > 0 or d.second > 0
|
||||||
|
|
||||||
@ -1729,8 +1729,8 @@ class Exchange:
|
|||||||
@retrier
|
@retrier
|
||||||
def set_margin_mode(self, pair: str, collateral: Collateral, params: dict = {}):
|
def set_margin_mode(self, pair: str, collateral: Collateral, params: dict = {}):
|
||||||
'''
|
'''
|
||||||
Set's the margin mode on the exchange to cross or isolated for a specific pair
|
Set's the margin mode on the exchange to cross or isolated for a specific pair
|
||||||
:param pair: base/quote currency pair (e.g. "ADA/USDT")
|
:param pair: base/quote currency pair (e.g. "ADA/USDT")
|
||||||
'''
|
'''
|
||||||
if self._config['dry_run'] or not self.exchange_has("setMarginMode"):
|
if self._config['dry_run'] or not self.exchange_has("setMarginMode"):
|
||||||
# Some exchanges only support one collateral type
|
# Some exchanges only support one collateral type
|
||||||
@ -1753,7 +1753,7 @@ class Exchange:
|
|||||||
since: int
|
since: int
|
||||||
) -> Dict:
|
) -> Dict:
|
||||||
"""
|
"""
|
||||||
Get's the mark price history for a pair
|
Get's the mark price history for a pair
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1802,11 +1802,11 @@ class Exchange:
|
|||||||
close_date: Optional[datetime] = None
|
close_date: Optional[datetime] = None
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
calculates the sum of all funding fees that occurred for a pair during a futures trade
|
calculates the sum of all funding fees that occurred for a pair during a futures trade
|
||||||
:param pair: The quote/base pair of the trade
|
:param pair: The quote/base pair of the trade
|
||||||
:param amount: The quantity of the trade
|
:param amount: The quantity of the trade
|
||||||
:param open_date: The date and time that the trade started
|
:param open_date: The date and time that the trade started
|
||||||
:param close_date: The date and time that the trade ended
|
:param close_date: The date and time that the trade ended
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fees: float = 0
|
fees: float = 0
|
||||||
@ -1869,9 +1869,9 @@ class Exchange:
|
|||||||
since: int,
|
since: int,
|
||||||
) -> Dict:
|
) -> Dict:
|
||||||
'''
|
'''
|
||||||
:param pair: quote/base currency pair
|
:param pair: quote/base currency pair
|
||||||
:param since: timestamp in ms of the beginning time
|
:param since: timestamp in ms of the beginning time
|
||||||
:param end: timestamp in ms of the end time
|
:param end: timestamp in ms of the end time
|
||||||
'''
|
'''
|
||||||
if not self.exchange_has("fetchFundingRateHistory"):
|
if not self.exchange_has("fetchFundingRateHistory"):
|
||||||
raise ExchangeError(
|
raise ExchangeError(
|
||||||
|
@ -165,17 +165,17 @@ class Kraken(Exchange):
|
|||||||
time_in_ratio: Optional[float] = None
|
time_in_ratio: Optional[float] = None
|
||||||
) -> float:
|
) -> float:
|
||||||
"""
|
"""
|
||||||
# ! This method will always error when run by Freqtrade because time_in_ratio is never
|
# ! This method will always error when run by Freqtrade because time_in_ratio is never
|
||||||
# ! passed to _get_funding_fee. For kraken futures to work in dry run and backtesting
|
# ! passed to _get_funding_fee. For kraken futures to work in dry run and backtesting
|
||||||
# ! functionality must be added that passes the parameter time_in_ratio to
|
# ! functionality must be added that passes the parameter time_in_ratio to
|
||||||
# ! _get_funding_fee when using Kraken
|
# ! _get_funding_fee when using Kraken
|
||||||
Calculates a single funding fee
|
Calculates a single funding fee
|
||||||
:param size: contract size * number of contracts
|
:param size: contract size * number of contracts
|
||||||
:param mark_price: The price of the asset that the contract is based off of
|
:param mark_price: The price of the asset that the contract is based off of
|
||||||
:param funding_rate: the interest rate and the premium
|
:param funding_rate: the interest rate and the premium
|
||||||
- interest rate:
|
- interest rate:
|
||||||
- premium: varies by price difference between the perpetual contract and mark price
|
- premium: varies by price difference between the perpetual contract and mark price
|
||||||
:param time_in_ratio: time elapsed within funding period without position alteration
|
:param time_in_ratio: time elapsed within funding period without position alteration
|
||||||
"""
|
"""
|
||||||
if not time_in_ratio:
|
if not time_in_ratio:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
|
@ -4718,21 +4718,21 @@ def test_update_funding_fees_schedule(mocker, default_conf, trading_mode, calls,
|
|||||||
@pytest.mark.parametrize('is_short', [True, False])
|
@pytest.mark.parametrize('is_short', [True, False])
|
||||||
def test_update_funding_fees(mocker, default_conf, time_machine, fee, is_short, limit_order_open):
|
def test_update_funding_fees(mocker, default_conf, time_machine, fee, is_short, limit_order_open):
|
||||||
'''
|
'''
|
||||||
nominal_value = mark_price * size
|
nominal_value = mark_price * size
|
||||||
funding_fee = nominal_value * funding_rate
|
funding_fee = nominal_value * funding_rate
|
||||||
size = 123
|
size = 123
|
||||||
"LTC/BTC"
|
"LTC/BTC"
|
||||||
time: 0, mark: 3.3, fundRate: 0.00032583, nominal_value: 405.9, fundFee: 0.132254397
|
time: 0, mark: 3.3, fundRate: 0.00032583, nominal_value: 405.9, fundFee: 0.132254397
|
||||||
time: 8, mark: 3.2, fundRate: 0.00024472, nominal_value: 393.6, fundFee: 0.096321792
|
time: 8, mark: 3.2, fundRate: 0.00024472, nominal_value: 393.6, fundFee: 0.096321792
|
||||||
"ETH/BTC"
|
"ETH/BTC"
|
||||||
time: 0, mark: 2.4, fundRate: 0.0001, nominal_value: 295.2, fundFee: 0.02952
|
time: 0, mark: 2.4, fundRate: 0.0001, nominal_value: 295.2, fundFee: 0.02952
|
||||||
time: 8, mark: 2.5, fundRate: 0.0001, nominal_value: 307.5, fundFee: 0.03075
|
time: 8, mark: 2.5, fundRate: 0.0001, nominal_value: 307.5, fundFee: 0.03075
|
||||||
"ETC/BTC"
|
"ETC/BTC"
|
||||||
time: 0, mark: 4.3, fundRate: 0.00031077, nominal_value: 528.9, fundFee: 0.164366253
|
time: 0, mark: 4.3, fundRate: 0.00031077, nominal_value: 528.9, fundFee: 0.164366253
|
||||||
time: 8, mark: 4.1, fundRate: 0.00022655, nominal_value: 504.3, fundFee: 0.114249165
|
time: 8, mark: 4.1, fundRate: 0.00022655, nominal_value: 504.3, fundFee: 0.114249165
|
||||||
"XRP/BTC"
|
"XRP/BTC"
|
||||||
time: 0, mark: 1.2, fundRate: 0.00049426, nominal_value: 147.6, fundFee: 0.072952776
|
time: 0, mark: 1.2, fundRate: 0.00049426, nominal_value: 147.6, fundFee: 0.072952776
|
||||||
time: 8, mark: 1.2, fundRate: 0.00032715, nominal_value: 147.6, fundFee: 0.04828734
|
time: 8, mark: 1.2, fundRate: 0.00032715, nominal_value: 147.6, fundFee: 0.04828734
|
||||||
'''
|
'''
|
||||||
# SETUP
|
# SETUP
|
||||||
time_machine.move_to("2021-09-01 00:00:00 +00:00")
|
time_machine.move_to("2021-09-01 00:00:00 +00:00")
|
||||||
|
Loading…
Reference in New Issue
Block a user