Improve typesafety around trade object
This commit is contained in:
parent
8765e3a4d6
commit
c2c039151c
@ -1314,7 +1314,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
default_retval=order_obj.price)(
|
default_retval=order_obj.price)(
|
||||||
trade=trade, order=order_obj, pair=trade.pair,
|
trade=trade, order=order_obj, pair=trade.pair,
|
||||||
current_time=datetime.now(timezone.utc), proposed_rate=proposed_rate,
|
current_time=datetime.now(timezone.utc), proposed_rate=proposed_rate,
|
||||||
current_order_rate=order_obj.price, entry_tag=trade.enter_tag,
|
current_order_rate=order_obj.safe_price, entry_tag=trade.enter_tag,
|
||||||
side=trade.entry_side)
|
side=trade.entry_side)
|
||||||
|
|
||||||
replacing = True
|
replacing = True
|
||||||
@ -1345,6 +1345,8 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
for trade in Trade.get_open_order_trades():
|
for trade in Trade.get_open_order_trades():
|
||||||
|
if not trade.open_order_id:
|
||||||
|
continue
|
||||||
try:
|
try:
|
||||||
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
order = self.exchange.fetch_order(trade.open_order_id, trade.pair)
|
||||||
except (ExchangeError):
|
except (ExchangeError):
|
||||||
@ -1369,6 +1371,9 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
"""
|
"""
|
||||||
was_trade_fully_canceled = False
|
was_trade_fully_canceled = False
|
||||||
side = trade.entry_side.capitalize()
|
side = trade.entry_side.capitalize()
|
||||||
|
if not trade.open_order_id:
|
||||||
|
logger.warning(f"No open order for {trade}.")
|
||||||
|
return False
|
||||||
|
|
||||||
# Cancelled orders may have the status of 'canceled' or 'closed'
|
# Cancelled orders may have the status of 'canceled' or 'closed'
|
||||||
if order['status'] not in constants.NON_OPEN_EXCHANGE_STATES:
|
if order['status'] not in constants.NON_OPEN_EXCHANGE_STATES:
|
||||||
@ -1455,7 +1460,7 @@ class FreqtradeBot(LoggingMixin):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
co = self.exchange.cancel_order_with_result(trade.open_order_id, trade.pair,
|
co = self.exchange.cancel_order_with_result(order['id'], trade.pair,
|
||||||
trade.amount)
|
trade.amount)
|
||||||
except InvalidOrderException:
|
except InvalidOrderException:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
|
@ -410,7 +410,7 @@ class RPC:
|
|||||||
exit_reasons[trade.exit_reason][trade_win_loss(trade)] += 1
|
exit_reasons[trade.exit_reason][trade_win_loss(trade)] += 1
|
||||||
|
|
||||||
# Duration
|
# Duration
|
||||||
dur: Dict[str, List[int]] = {'wins': [], 'draws': [], 'losses': []}
|
dur: Dict[str, List[float]] = {'wins': [], 'draws': [], 'losses': []}
|
||||||
for trade in trades:
|
for trade in trades:
|
||||||
if trade.close_date is not None and trade.open_date is not None:
|
if trade.close_date is not None and trade.open_date is not None:
|
||||||
trade_dur = (trade.close_date - trade.open_date).total_seconds()
|
trade_dur = (trade.close_date - trade.open_date).total_seconds()
|
||||||
|
Loading…
Reference in New Issue
Block a user