Use "since last order" approach for live as well.

This commit is contained in:
Matthias 2022-09-03 10:06:23 +02:00
parent 0c6a02687a
commit 0f483ee31f
2 changed files with 11 additions and 5 deletions

View File

@ -281,7 +281,7 @@ class FreqtradeBot(LoggingMixin):
pair=trade.pair,
amount=trade.amount,
is_short=trade.is_short,
open_date=trade.open_date_utc
open_date=trade.date_last_filled_utc
)
trade.funding_fees = funding_fees
else:
@ -1485,7 +1485,7 @@ class FreqtradeBot(LoggingMixin):
pair=trade.pair,
amount=trade.amount,
is_short=trade.is_short,
open_date=trade.open_date_utc,
open_date=trade.date_last_filled_utc,
)
exit_type = 'exit'
exit_reason = exit_tag or exit_check.exit_reason

View File

@ -128,6 +128,10 @@ class Order(_DECL_BASE):
self.ft_is_open = True
if self.status in NON_OPEN_EXCHANGE_STATES:
self.ft_is_open = False
if self.trade:
# Assign funding fee up to this point
# (represents the funding fee since the last order)
self.funding_fee = self.trade.funding_fees
if (order.get('filled', 0.0) or 0.0) > 0:
self.order_filled_date = datetime.now(timezone.utc)
self.order_update_date = datetime.now(timezone.utc)
@ -360,10 +364,12 @@ class LocalTrade():
return self.amount
@property
def date_last_filled_utc(self):
def date_last_filled_utc(self) -> datetime:
""" Date of the last filled order"""
return max([self.open_date_utc,
max(o.order_filled_utc for o in self.orders if o.filled and not o.ft_is_open)])
orders = self.select_filled_orders()
if not orders:
return self.open_date_utc
return max([self.open_date_utc, max(o.order_filled_utc for o in orders)])
@property
def open_date_utc(self):