@@ -56,7 +56,7 @@ class PMMisterConfig(ControllerConfigBase):
5656 leverage : int = Field (default = 20 , json_schema_extra = {"is_updatable" : True })
5757 position_mode : PositionMode = Field (default = PositionMode .ONEWAY )
5858 # LONG: buys accumulate, sells reduce. SHORT: sells accumulate, buys reduce.
59- position_side : TradeType = Field (default = TradeType . BUY )
59+ position_side : TradeType = Field (default = " BUY" )
6060 take_profit : Optional [Decimal ] = Field (default = Decimal ("0.0001" ), gt = 0 , json_schema_extra = {"is_updatable" : True })
6161 take_profit_order_type : Optional [OrderType ] = Field (default = OrderType .LIMIT_MAKER , json_schema_extra = {"is_updatable" : True })
6262 open_order_type : Optional [OrderType ] = Field (default = OrderType .LIMIT_MAKER , json_schema_extra = {"is_updatable" : True })
@@ -128,6 +128,12 @@ def validate_position_mode(cls, v) -> PositionMode:
128128 def validate_position_side (cls , v ) -> TradeType :
129129 if isinstance (v , TradeType ):
130130 return v
131+ # Accept the enum's integer value (e.g. from a serialized/reloaded config)
132+ if isinstance (v , int ) or (isinstance (v , str ) and v .isdigit ()):
133+ try :
134+ return TradeType (int (v ))
135+ except ValueError :
136+ raise ValueError (f"position_side must be BUY/LONG or SELL/SHORT, got { v } " )
131137 mapping = {"BUY" : TradeType .BUY , "SELL" : TradeType .SELL , "LONG" : TradeType .BUY , "SHORT" : TradeType .SELL }
132138 upper = str (v ).upper ()
133139 if upper in mapping :
0 commit comments