File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
investing_algorithm_framework/domain/models/trade Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ def __init__(
8888 self .last_reported_price_datetime = last_reported_price_datetime
8989 self .high_water_mark = high_water_mark
9090 self .high_water_mark_datetime = high_water_mark_datetime
91- self .status = status
91+ self .status = TradeStatus . from_value ( status ). value
9292 self .updated_at = updated_at
9393 self .stop_losses = stop_losses
9494 self .take_profits = take_profits
Original file line number Diff line number Diff line change 11from enum import Enum
2+ from investing_algorithm_framework .domain .exceptions import \
3+ OperationalException
24
35
46class TradeStatus (Enum ):
@@ -15,7 +17,9 @@ def from_string(value: str):
1517 if value .upper () == status .value :
1618 return status
1719
18- raise ValueError ("Could not convert value to TradeStatus" )
20+ raise OperationalException (
21+ f"Could not convert value: '{ value } ' to TradeStatus"
22+ )
1923
2024 @staticmethod
2125 def from_value (value ):
@@ -28,7 +32,9 @@ def from_value(value):
2832 elif isinstance (value , str ):
2933 return TradeStatus .from_string (value )
3034
31- raise ValueError ("Could not convert value to TradeStatus" )
35+ raise OperationalException (
36+ f"Could not convert value: { value } to TradeStatus"
37+ )
3238
3339 def equals (self , other ):
3440 return TradeStatus .from_value (other ) == self
You can’t perform that action at this time.
0 commit comments