diff --git a/freqtrade/persistence/migrations.py b/freqtrade/persistence/migrations.py index c4b2c8bbb..298b18775 100644 --- a/freqtrade/persistence/migrations.py +++ b/freqtrade/persistence/migrations.py @@ -51,6 +51,7 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col leverage = get_column_def(cols, 'leverage', '0.0') borrowed = get_column_def(cols, 'borrowed', '0.0') borrowed_currency = get_column_def(cols, 'borrowed_currency', 'null') + collateral_currency = get_column_def(cols, 'collateral_currency', 'null') 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') @@ -89,7 +90,7 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col stoploss_order_id, stoploss_last_update, max_rate, min_rate, sell_reason, close_order_status, strategy, timeframe, open_trade_value, close_profit_abs, - leverage, borrowed, borrowed_currency, interest_rate, liquidation_price, is_short + leverage, borrowed, borrowed_currency, collateral_currency, interest_rate, liquidation_price, is_short ) select id, lower(exchange), case @@ -114,7 +115,8 @@ def migrate_trades_table(decl_base, inspector, engine, table_back_name: str, col {strategy} strategy, {timeframe} timeframe, {open_trade_value} open_trade_value, {close_profit_abs} close_profit_abs, {leverage} leverage, {borrowed} borrowed, {borrowed_currency} borrowed_currency, - {interest_rate} interest_rate, {liquidation_price} liquidation_price, {is_short} is_short + {collateral_currency} collateral_currency, {interest_rate} interest_rate, + {liquidation_price} liquidation_price, {is_short} is_short from {table_back_name} """)) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 76836704c..cdc9a60b2 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -265,7 +265,8 @@ class LocalTrade(): # Margin trading properties leverage: Optional[float] = 0.0 borrowed: float = 0.0 - borrowed_currency: float = None + borrowed_currency: str = None + collateral_currency: str = None interest_rate: float = 0.0 liquidation_price: float = None is_short: bool = False @@ -367,6 +368,7 @@ class LocalTrade(): 'leverage': self.leverage, 'borrowed': self.borrowed, 'borrowed_currency': self.borrowed_currency, + 'collateral_currency': self.collateral_currency, 'interest_rate': self.interest_rate, 'liquidation_price': self.liquidation_price, 'leverage': self.leverage, @@ -775,6 +777,7 @@ class Trade(_DECL_BASE, LocalTrade): leverage = Column(Float, nullable=True, default=0.0) borrowed = Column(Float, nullable=False, default=0.0) borrowed_currency = Column(Float, nullable=True) + collateral_currency = Column(String(25), nullable=True) interest_rate = Column(Float, nullable=False, default=0.0) liquidation_price = Column(Float, nullable=True) is_short = Column(Boolean, nullable=False, default=False)