From 94274e4823b5782e15e1e0584c665e1fb81a0488 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 31 Mar 2022 06:57:16 +0200 Subject: [PATCH] Remove order.leverage column --- freqtrade/persistence/migrations.py | 7 ++----- freqtrade/persistence/models.py | 7 ------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/freqtrade/persistence/migrations.py b/freqtrade/persistence/migrations.py index 7ef8eab94..a84503c74 100644 --- a/freqtrade/persistence/migrations.py +++ b/freqtrade/persistence/migrations.py @@ -197,18 +197,15 @@ def migrate_orders_table(engine, table_back_name: str, cols_order: List): ft_fee_base = get_column_def(cols_order, 'ft_fee_base', 'null') average = get_column_def(cols_order, 'average', 'null') - # let SQLAlchemy create the schema as required - leverage = get_column_def(cols_order, 'leverage', '1.0') # sqlite does not support literals for booleans 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, status, symbol, order_type, side, price, amount, filled, average, remaining, cost, - order_date, order_filled_date, order_update_date, ft_fee_base, leverage) + order_date, order_filled_date, order_update_date, ft_fee_base) select id, ft_trade_id, ft_order_side, ft_pair, ft_is_open, order_id, status, symbol, order_type, side, price, amount, filled, {average} average, remaining, - cost, order_date, order_filled_date, order_update_date, {ft_fee_base} ft_fee_base, - {leverage} leverage + cost, order_date, order_filled_date, order_update_date, {ft_fee_base} ft_fee_base from {table_back_name} """)) diff --git a/freqtrade/persistence/models.py b/freqtrade/persistence/models.py index f5dd5f1f2..a23c8e43e 100644 --- a/freqtrade/persistence/models.py +++ b/freqtrade/persistence/models.py @@ -135,7 +135,6 @@ class Order(_DECL_BASE): order_date = Column(DateTime, nullable=True, default=datetime.utcnow) order_filled_date = Column(DateTime, nullable=True) order_update_date = Column(DateTime, nullable=True) - leverage = Column(Float, nullable=True, default=1.0) ft_fee_base = Column(Float, nullable=True) @@ -183,9 +182,6 @@ class Order(_DECL_BASE): self.average = order.get('average', self.average) self.remaining = order.get('remaining', self.remaining) self.cost = order.get('cost', self.cost) - # TODO-lev: ccxt order objects don't contain leverage. - # Therefore the below will always be 1.0 - which is wrong. - self.leverage = order.get('leverage', self.leverage) if 'timestamp' in order and order['timestamp'] is not None: self.order_date = datetime.fromtimestamp(order['timestamp'] / 1000, tz=timezone.utc) @@ -608,9 +604,6 @@ class LocalTrade(): # Update open rate and actual amount self.open_rate = order.safe_price self.amount = order.safe_amount_after_fee - # if 'leverage' in order: - # TODO-lev: order.leverage is not properly filled on the order object! - # self.leverage = order.leverage if self.is_open: payment = "SELL" if self.is_short else "BUY" logger.info(f'{order.order_type.upper()}_{payment} has been fulfilled for {self}.')