mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Fix realized_profit for trade from_json
This commit is contained in:
parent
bdff34017a
commit
7f0e1c27c6
|
@ -1302,6 +1302,9 @@ class Trade(ModelBase, LocalTrade):
|
|||
super().__init__(**kwargs)
|
||||
self.realized_profit = 0
|
||||
self.recalc_open_trade_value()
|
||||
if 'realized_profit' in kwargs:
|
||||
# reset realized profit for from_json calls
|
||||
self.realized_profit = kwargs['realized_profit']
|
||||
|
||||
@validates('enter_tag', 'exit_reason')
|
||||
def validate_string_len(self, key, value):
|
||||
|
|
|
@ -179,6 +179,7 @@ def test_trade_fromjson():
|
|||
assert trade.open_date_utc == datetime(2022, 10, 18, 9, 12, 42, tzinfo=timezone.utc)
|
||||
assert isinstance(trade.open_date, datetime)
|
||||
assert trade.exit_reason == 'no longer good'
|
||||
assert trade.realized_profit == 2.76315361
|
||||
|
||||
assert len(trade.orders) == 5
|
||||
last_o = trade.orders[-1]
|
||||
|
|
Loading…
Reference in New Issue
Block a user