Add sell-reason to sell-tree

This commit is contained in:
Matthias
2018-07-11 19:57:01 +02:00
parent 6bb7167b56
commit f991109b0a
4 changed files with 31 additions and 20 deletions

View File

@@ -88,6 +88,7 @@ def check_migrate(engine) -> None:
stop_loss = get_column_def(cols, 'stop_loss', '0.0')
initial_stop_loss = get_column_def(cols, 'initial_stop_loss', '0.0')
max_rate = get_column_def(cols, 'max_rate', '0.0')
sell_reason = get_column_def(cols, 'sell_reason', 'null')
# Schema migration necessary
engine.execute(f"alter table trades rename to {table_back_name}")
@@ -99,7 +100,7 @@ def check_migrate(engine) -> None:
(id, exchange, pair, is_open, fee_open, fee_close, open_rate,
open_rate_requested, close_rate, close_rate_requested, close_profit,
stake_amount, amount, open_date, close_date, open_order_id,
stop_loss, initial_stop_loss, max_rate
stop_loss, initial_stop_loss, max_rate, sell_reason
)
select id, lower(exchange),
case
@@ -114,7 +115,7 @@ def check_migrate(engine) -> None:
{close_rate_requested} close_rate_requested, close_profit,
stake_amount, amount, open_date, close_date, open_order_id,
{stop_loss} stop_loss, {initial_stop_loss} initial_stop_loss,
{max_rate} max_rate
{max_rate} max_rate, {sell_reason} sell_reason
from {table_back_name}
""")
@@ -170,6 +171,7 @@ class Trade(_DECL_BASE):
initial_stop_loss = Column(Float, nullable=True, default=0.0)
# absolute value of the highest reached price
max_rate = Column(Float, nullable=True, default=0.0)
sell_reason = Column(String, nullable=True)
def __repr__(self):
open_since = arrow.get(self.open_date).humanize() if self.is_open else 'closed'