handle stop loss on exchange added

This commit is contained in:
misagh
2018-11-23 15:17:36 +01:00
parent 1dde56790c
commit fea77824d0
4 changed files with 102 additions and 3 deletions

View File

@@ -178,7 +178,7 @@ class Trade(_DECL_BASE):
# absolute value of the initial stop loss
initial_stop_loss = Column(Float, nullable=True, default=0.0)
# absolute value of the highest reached price
stoploss_order_id = Column(Integer, nullable=True, index=True)
stoploss_order_id = Column(String, nullable=True, index=True)
max_rate = Column(Float, nullable=True, default=0.0)
sell_reason = Column(String, nullable=True)
strategy = Column(String, nullable=True)
@@ -250,6 +250,9 @@ class Trade(_DECL_BASE):
self.open_order_id = None
elif order_type == 'limit' and order['side'] == 'sell':
self.close(order['price'])
elif order_type == 'stop_loss_limit':
self.stoploss_order_id = None
self.close(order['price'])
else:
raise ValueError(f'Unknown order type: {order_type}')
cleanup()