mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Simplify trade_model serializations
This commit is contained in:
parent
c6d1c1a980
commit
0f85ef0997
|
@ -23,7 +23,7 @@ from freqtrade.exchange import (ROUND_DOWN, ROUND_UP, amount_to_contract_precisi
|
|||
from freqtrade.leverage import interest
|
||||
from freqtrade.misc import safe_value_fallback
|
||||
from freqtrade.persistence.base import ModelBase, SessionType
|
||||
from freqtrade.util import FtPrecise, dt_from_ts, dt_now, dt_ts
|
||||
from freqtrade.util import FtPrecise, dt_from_ts, dt_now, dt_ts, dt_ts_none
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -224,8 +224,7 @@ class Order(ModelBase):
|
|||
'amount': self.safe_amount,
|
||||
'safe_price': self.safe_price,
|
||||
'ft_order_side': self.ft_order_side,
|
||||
'order_filled_timestamp': int(self.order_filled_date.replace(
|
||||
tzinfo=timezone.utc).timestamp() * 1000) if self.order_filled_date else None,
|
||||
'order_filled_timestamp': dt_ts_none(self.order_filled_utc),
|
||||
'ft_is_entry': self.ft_order_side == entry_side,
|
||||
'ft_order_tag': self.ft_order_tag,
|
||||
}
|
||||
|
@ -625,15 +624,14 @@ class LocalTrade:
|
|||
'fee_close_currency': self.fee_close_currency,
|
||||
|
||||
'open_date': self.open_date.strftime(DATETIME_PRINT_FORMAT),
|
||||
'open_timestamp': int(self.open_date.replace(tzinfo=timezone.utc).timestamp() * 1000),
|
||||
'open_timestamp': dt_ts_none(self.open_date_utc),
|
||||
'open_rate': self.open_rate,
|
||||
'open_rate_requested': self.open_rate_requested,
|
||||
'open_trade_value': round(self.open_trade_value, 8),
|
||||
|
||||
'close_date': (self.close_date.strftime(DATETIME_PRINT_FORMAT)
|
||||
if self.close_date else None),
|
||||
'close_timestamp': int(self.close_date.replace(
|
||||
tzinfo=timezone.utc).timestamp() * 1000) if self.close_date else None,
|
||||
'close_timestamp': dt_ts_none(self.close_date_utc),
|
||||
'realized_profit': self.realized_profit or 0.0,
|
||||
# Close-profit corresponds to relative realized_profit ratio
|
||||
'realized_profit_ratio': self.close_profit or None,
|
||||
|
@ -659,8 +657,7 @@ class LocalTrade:
|
|||
'stop_loss_pct': (self.stop_loss_pct * 100) if self.stop_loss_pct else None,
|
||||
'stoploss_last_update': (self.stoploss_last_update_utc.strftime(DATETIME_PRINT_FORMAT)
|
||||
if self.stoploss_last_update_utc else None),
|
||||
'stoploss_last_update_timestamp': int(self.stoploss_last_update_utc.timestamp() * 1000
|
||||
) if self.stoploss_last_update_utc else None,
|
||||
'stoploss_last_update_timestamp': dt_ts_none(self.stoploss_last_update_utc),
|
||||
'initial_stop_loss_abs': self.initial_stop_loss,
|
||||
'initial_stop_loss_ratio': (self.initial_stop_loss_pct
|
||||
if self.initial_stop_loss_pct else None),
|
||||
|
|
Loading…
Reference in New Issue
Block a user