Merge branch 'feat/short' into funding-fee-dry-run

This commit is contained in:
Sam Germain 2021-11-09 14:45:10 -06:00
commit 45e4354906
7 changed files with 41 additions and 41 deletions

View File

@ -3,9 +3,9 @@ from enum import Enum
class Collateral(Enum):
"""
Enum to distinguish between
cross margin/futures collateral and
isolated margin/futures collateral
Enum to distinguish between
cross margin/futures collateral and
isolated margin/futures collateral
"""
CROSS = "cross"
ISOLATED = "isolated"

View File

@ -3,8 +3,8 @@ from enum import Enum
class TradingMode(Enum):
"""
Enum to distinguish between
spot, margin, futures or any other trading method
Enum to distinguish between
spot, margin, futures or any other trading method
"""
SPOT = "spot"
MARGIN = "margin"

View File

@ -140,8 +140,8 @@ class Binance(Exchange):
@retrier
def fill_leverage_brackets(self):
"""
Assigns property _leverage_brackets to a dictionary of information about the leverage
allowed on each pair
Assigns property _leverage_brackets to a dictionary of information about the leverage
allowed on each pair
"""
if self.trading_mode == TradingMode.FUTURES:
try:
@ -175,9 +175,9 @@ class Binance(Exchange):
def get_max_leverage(self, pair: Optional[str], nominal_value: Optional[float]) -> float:
"""
Returns the maximum leverage that a pair can be traded at
:param pair: The base/quote currency pair being traded
:nominal_value: The total value of the trade in quote currency (collateral + debt)
Returns the maximum leverage that a pair can be traded at
:param pair: The base/quote currency pair being traded
:nominal_value: The total value of the trade in quote currency (collateral + debt)
"""
pair_brackets = self._leverage_brackets[pair]
max_lev = 1.0
@ -194,8 +194,8 @@ class Binance(Exchange):
trading_mode: Optional[TradingMode] = None
):
"""
Set's the leverage before making a trade, in order to not
have the same leverage on every trade
Set's the leverage before making a trade, in order to not
have the same leverage on every trade
"""
trading_mode = trading_mode or self.trading_mode

View File

@ -516,10 +516,10 @@ class Exchange:
collateral: Optional[Collateral] # Only None when trading_mode = TradingMode.SPOT
):
"""
Checks if freqtrade can perform trades using the configured
trading mode(Margin, Futures) and Collateral(Cross, Isolated)
Throws OperationalException:
If the trading_mode/collateral type are not supported by freqtrade on this exchange
Checks if freqtrade can perform trades using the configured
trading mode(Margin, Futures) and Collateral(Cross, Isolated)
Throws OperationalException:
If the trading_mode/collateral type are not supported by freqtrade on this exchange
"""
if trading_mode != TradingMode.SPOT and (
(trading_mode, collateral) not in self._supported_trading_mode_collateral_pairs
@ -1648,7 +1648,7 @@ class Exchange:
"""
Returns the maximum leverage that a pair can be traded at
:param pair: The base/quote currency pair being traded
:nominal_value: The total value of the trade in quote currency (collateral + debt)
:param nominal_value: The total value of the trade in quote currency (collateral + debt)
"""
market = self.markets[pair]
if (
@ -1728,10 +1728,10 @@ class Exchange:
@retrier
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
:param pair: base/quote currency pair (e.g. "ADA/USDT")
'''
"""
if self._config['dry_run'] or not self.exchange_has("setMarginMode"):
# Some exchanges only support one collateral type
return

View File

@ -146,8 +146,8 @@ class Kraken(Exchange):
trading_mode: Optional[TradingMode] = None
):
"""
Kraken set's the leverage as an option in the order object, so we need to
add it to params
Kraken set's the leverage as an option in the order object, so we need to
add it to params
"""
return

View File

@ -16,18 +16,18 @@ def interest(
hours: Decimal
) -> Decimal:
"""
Equation to calculate interest on margin trades
Equation to calculate interest on margin trades
:param exchange_name: The exchanged being trading on
:param borrowed: The amount of currency being borrowed
:param rate: The rate of interest (i.e daily interest rate)
:param hours: The time in hours that the currency has been borrowed for
:param exchange_name: The exchanged being trading on
:param borrowed: The amount of currency being borrowed
:param rate: The rate of interest (i.e daily interest rate)
:param hours: The time in hours that the currency has been borrowed for
Raises:
OperationalException: Raised if freqtrade does
not support margin trading for this exchange
Raises:
OperationalException: Raised if freqtrade does
not support margin trading for this exchange
Returns: The amount of interest owed (currency matches borrowed)
Returns: The amount of interest owed (currency matches borrowed)
"""
exchange_name = exchange_name.lower()
if exchange_name == "binance":

View File

@ -30,13 +30,13 @@ _SQL_DOCS_URL = 'http://docs.sqlalchemy.org/en/latest/core/engines.html#database
def init_db(db_url: str, clean_open_orders: bool = False) -> None:
"""
Initializes this module with the given config,
registers all known command handlers
and starts polling for message updates
:param db_url: Database to use
:param clean_open_orders: Remove open orders from the database.
Useful for dry-run or if all orders have been reset on the exchange.
:return: None
Initializes this module with the given config,
registers all known command handlers
and starts polling for message updates
:param db_url: Database to use
:param clean_open_orders: Remove open orders from the database.
Useful for dry-run or if all orders have been reset on the exchange.
:return: None
"""
kwargs = {}
@ -329,8 +329,8 @@ class LocalTrade():
def _set_stop_loss(self, stop_loss: float, percent: float):
"""
Method you should use to set self.stop_loss.
Assures stop_loss is not passed the liquidation price
Method you should use to set self.stop_loss.
Assures stop_loss is not passed the liquidation price
"""
if self.isolated_liq is not None:
if self.is_short:
@ -352,8 +352,8 @@ class LocalTrade():
def set_isolated_liq(self, isolated_liq: float):
"""
Method you should use to set self.liquidation price.
Assures stop_loss is not passed the liquidation price
Method you should use to set self.liquidation price.
Assures stop_loss is not passed the liquidation price
"""
if self.stop_loss is not None:
if self.is_short: