use filled time calculate duration
This commit is contained in:
parent
82e0eca128
commit
1c86e69c34
@ -534,7 +534,7 @@ class Backtesting:
|
|||||||
if sell.sell_flag:
|
if sell.sell_flag:
|
||||||
trade.close_date = sell_candle_time
|
trade.close_date = sell_candle_time
|
||||||
|
|
||||||
trade_dur = int((trade.close_date_utc - trade.open_date_utc).total_seconds() // 60)
|
trade_dur = int((trade.close_date_utc - trade.filled_date_utc).total_seconds() // 60)
|
||||||
try:
|
try:
|
||||||
closerate = self._get_close_rate(sell_row, trade, sell, trade_dur)
|
closerate = self._get_close_rate(sell_row, trade, sell, trade_dur)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -366,6 +366,10 @@ class LocalTrade():
|
|||||||
else:
|
else:
|
||||||
return self.amount
|
return self.amount
|
||||||
|
|
||||||
|
@property
|
||||||
|
def filled_date_utc(self):
|
||||||
|
return self.select_order('buy', is_open=False).order_filled_date.replace(tzinfo=timezone.utc)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def open_date_utc(self):
|
def open_date_utc(self):
|
||||||
return self.open_date.replace(tzinfo=timezone.utc)
|
return self.open_date.replace(tzinfo=timezone.utc)
|
||||||
|
Loading…
Reference in New Issue
Block a user