Set default leverage to 1.0

This commit is contained in:
Sam Germain 2021-07-04 23:12:07 -06:00
parent 9ddb6981dd
commit 0d5749c508
4 changed files with 8 additions and 13 deletions

View File

@ -48,7 +48,7 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col
sell_reason = get_column_def(cols, 'sell_reason', 'null')
strategy = get_column_def(cols, 'strategy', 'null')
leverage = get_column_def(cols, 'leverage', 'null')
leverage = get_column_def(cols, 'leverage', '1.0')
interest_rate = get_column_def(cols, 'interest_rate', '0.0')
liquidation_price = get_column_def(cols, 'liquidation_price', 'null')
is_short = get_column_def(cols, 'is_short', 'False')
@ -146,7 +146,7 @@ def migrate_orders_table(decl_base, inspector, engine, table_back_name: str, col
# let SQLAlchemy create the schema as required
decl_base.metadata.create_all(engine)
leverage = get_column_def(cols, 'leverage', 'null')
leverage = get_column_def(cols, 'leverage', '1.0')
is_short = get_column_def(cols, 'is_short', 'False')
with engine.begin() as connection:
connection.execute(text(f"""

View File

@ -132,7 +132,7 @@ class Order(_DECL_BASE):
order_filled_date = Column(DateTime, nullable=True)
order_update_date = Column(DateTime, nullable=True)
leverage = Column(Float, nullable=True, default=None)
leverage = Column(Float, nullable=True, default=1.0)
is_short = Column(Boolean, nullable=True, default=False)
def __repr__(self):
@ -267,7 +267,7 @@ class LocalTrade():
interest_rate: float = 0.0
liquidation_price: float = None
is_short: bool = False
leverage: float = None
leverage: float = 1.0
@property
def has_no_leverage(self) -> bool:
@ -583,7 +583,7 @@ class LocalTrade():
zero = Decimal(0.0)
# If nothing was borrowed
if (self.leverage == 1.0 and not self.is_short) or not self.leverage:
if self.has_no_leverage:
return zero
open_date = self.open_date.replace(tzinfo=None)
@ -853,7 +853,7 @@ class Trade(_DECL_BASE, LocalTrade):
timeframe = Column(Integer, nullable=True)
# Margin trading properties
leverage = Column(Float, nullable=True)
leverage = Column(Float, nullable=True, default=1.0)
interest_rate = Column(Float, nullable=False, default=0.0)
liquidation_price = Column(Float, nullable=True)
is_short = Column(Boolean, nullable=False, default=False)

View File

@ -305,9 +305,6 @@ def mock_trade_6(fee):
return trade
#! TODO Currently the following short_trade test and leverage_trade test will fail
def short_order():
return {
'id': '1236',

View File

@ -107,8 +107,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'stoploss_entry_dist_ratio': -0.10448878,
'open_order': None,
'exchange': 'binance',
'leverage': None,
'leverage': 1.0,
'interest_rate': 0.0,
'liquidation_price': None,
'is_short': False,
@ -178,8 +177,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'stoploss_entry_dist_ratio': -0.10448878,
'open_order': None,
'exchange': 'binance',
'leverage': None,
'leverage': 1.0,
'interest_rate': 0.0,
'liquidation_price': None,
'is_short': False,