From dd6cc1153bd52e0f7c9d5885f609cb43c091dff0 Mon Sep 17 00:00:00 2001 From: Sam Germain Date: Tue, 6 Jul 2021 00:43:01 -0600 Subject: [PATCH] Tried to add liquidation price to order object, caused a test to fail --- freqtrade/persistence/migrations.py | 3 ++- freqtrade/persistence/models.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/freqtrade/persistence/migrations.py b/freqtrade/persistence/migrations.py index 69ffc544e..be503c42b 100644 --- a/freqtrade/persistence/migrations.py +++ b/freqtrade/persistence/migrations.py @@ -148,6 +148,7 @@ def migrate_orders_table(decl_base, inspector, engine, table_back_name: str, col decl_base.metadata.create_all(engine) leverage = get_column_def(cols, 'leverage', '1.0') is_short = get_column_def(cols, 'is_short', 'False') + liquidation_price = get_column_def(cols, 'liquidation_price', 'False') with engine.begin() as connection: connection.execute(text(f""" insert into orders ( id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id, @@ -156,7 +157,7 @@ def migrate_orders_table(decl_base, inspector, engine, table_back_name: str, col select id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id, status, symbol, order_type, side, price, amount, filled, null average, remaining, cost, order_date, order_filled_date, order_update_date, - {leverage} leverage, {is_short} is_short + {leverage} leverage, {is_short} is_short, {liquidation_price} liquidation_price from {table_back_name} """)) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index 5254b7f4b..76a5bf34e 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -134,6 +134,7 @@ class Order(_DECL_BASE): leverage = Column(Float, nullable=True, default=1.0) is_short = Column(Boolean, nullable=True, default=False) + # liquidation_price = Column(Float, nullable=True) def __repr__(self): @@ -159,6 +160,7 @@ class Order(_DECL_BASE): self.remaining = order.get('remaining', self.remaining) self.cost = order.get('cost', self.cost) self.leverage = order.get('leverage', self.leverage) + # TODO-mg: liquidation price? is_short? if 'timestamp' in order and order['timestamp'] is not None: self.order_date = datetime.fromtimestamp(order['timestamp'] / 1000, tz=timezone.utc)