Set default leverage to 1.0
This commit is contained in:
parent
78708b27f2
commit
0ffc85fed9
@ -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')
|
sell_reason = get_column_def(cols, 'sell_reason', 'null')
|
||||||
strategy = get_column_def(cols, 'strategy', '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')
|
interest_rate = get_column_def(cols, 'interest_rate', '0.0')
|
||||||
liquidation_price = get_column_def(cols, 'liquidation_price', 'null')
|
liquidation_price = get_column_def(cols, 'liquidation_price', 'null')
|
||||||
is_short = get_column_def(cols, 'is_short', 'False')
|
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
|
# let SQLAlchemy create the schema as required
|
||||||
decl_base.metadata.create_all(engine)
|
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')
|
is_short = get_column_def(cols, 'is_short', 'False')
|
||||||
with engine.begin() as connection:
|
with engine.begin() as connection:
|
||||||
connection.execute(text(f"""
|
connection.execute(text(f"""
|
||||||
|
@ -132,7 +132,7 @@ class Order(_DECL_BASE):
|
|||||||
order_filled_date = Column(DateTime, nullable=True)
|
order_filled_date = Column(DateTime, nullable=True)
|
||||||
order_update_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)
|
is_short = Column(Boolean, nullable=True, default=False)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -267,7 +267,7 @@ class LocalTrade():
|
|||||||
interest_rate: float = 0.0
|
interest_rate: float = 0.0
|
||||||
liquidation_price: float = None
|
liquidation_price: float = None
|
||||||
is_short: bool = False
|
is_short: bool = False
|
||||||
leverage: float = None
|
leverage: float = 1.0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def has_no_leverage(self) -> bool:
|
def has_no_leverage(self) -> bool:
|
||||||
@ -583,7 +583,7 @@ class LocalTrade():
|
|||||||
|
|
||||||
zero = Decimal(0.0)
|
zero = Decimal(0.0)
|
||||||
# If nothing was borrowed
|
# 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
|
return zero
|
||||||
|
|
||||||
open_date = self.open_date.replace(tzinfo=None)
|
open_date = self.open_date.replace(tzinfo=None)
|
||||||
@ -853,7 +853,7 @@ class Trade(_DECL_BASE, LocalTrade):
|
|||||||
timeframe = Column(Integer, nullable=True)
|
timeframe = Column(Integer, nullable=True)
|
||||||
|
|
||||||
# Margin trading properties
|
# 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)
|
interest_rate = Column(Float, nullable=False, default=0.0)
|
||||||
liquidation_price = Column(Float, nullable=True)
|
liquidation_price = Column(Float, nullable=True)
|
||||||
is_short = Column(Boolean, nullable=False, default=False)
|
is_short = Column(Boolean, nullable=False, default=False)
|
||||||
|
@ -305,9 +305,6 @@ def mock_trade_6(fee):
|
|||||||
return trade
|
return trade
|
||||||
|
|
||||||
|
|
||||||
#! TODO Currently the following short_trade test and leverage_trade test will fail
|
|
||||||
|
|
||||||
|
|
||||||
def short_order():
|
def short_order():
|
||||||
return {
|
return {
|
||||||
'id': '1236',
|
'id': '1236',
|
||||||
|
@ -107,8 +107,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'stoploss_entry_dist_ratio': -0.10448878,
|
'stoploss_entry_dist_ratio': -0.10448878,
|
||||||
'open_order': None,
|
'open_order': None,
|
||||||
'exchange': 'binance',
|
'exchange': 'binance',
|
||||||
|
'leverage': 1.0,
|
||||||
'leverage': None,
|
|
||||||
'interest_rate': 0.0,
|
'interest_rate': 0.0,
|
||||||
'liquidation_price': None,
|
'liquidation_price': None,
|
||||||
'is_short': False,
|
'is_short': False,
|
||||||
@ -178,8 +177,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'stoploss_entry_dist_ratio': -0.10448878,
|
'stoploss_entry_dist_ratio': -0.10448878,
|
||||||
'open_order': None,
|
'open_order': None,
|
||||||
'exchange': 'binance',
|
'exchange': 'binance',
|
||||||
|
'leverage': 1.0,
|
||||||
'leverage': None,
|
|
||||||
'interest_rate': 0.0,
|
'interest_rate': 0.0,
|
||||||
'liquidation_price': None,
|
'liquidation_price': None,
|
||||||
'is_short': False,
|
'is_short': False,
|
||||||
|
Loading…
Reference in New Issue
Block a user