Redesign roll calculator with auto first entry and chained add legs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -834,16 +834,20 @@ class TrendCalculatorBody(BaseModel):
|
||||
contract_size: float = Field(default=1.0, gt=0)
|
||||
|
||||
|
||||
class RollAddLegBody(BaseModel):
|
||||
add_price: float = Field(gt=0)
|
||||
new_stop_loss: float = Field(gt=0)
|
||||
|
||||
|
||||
class RollCalculatorBody(BaseModel):
|
||||
direction: str = "long"
|
||||
capital_usdt: float = Field(gt=0)
|
||||
risk_percent: float = Field(gt=0, le=100)
|
||||
qty_existing: float = Field(gt=0)
|
||||
entry_existing: float = Field(gt=0)
|
||||
entry_price: float = Field(gt=0)
|
||||
stop_loss: float = Field(gt=0)
|
||||
take_profit: float = Field(gt=0)
|
||||
add_price: float = Field(gt=0)
|
||||
new_stop_loss: float = Field(gt=0)
|
||||
legs_done: int = Field(default=0, ge=0, le=10)
|
||||
add_legs: list[RollAddLegBody] = Field(default_factory=list, max_length=3)
|
||||
legs_done: int = Field(default=0, ge=0, le=3)
|
||||
|
||||
|
||||
@app.post("/api/calculator/trend")
|
||||
@@ -875,11 +879,10 @@ def api_calculator_roll(body: RollCalculatorBody):
|
||||
direction=body.direction,
|
||||
capital_usdt=body.capital_usdt,
|
||||
risk_percent=body.risk_percent,
|
||||
qty_existing=body.qty_existing,
|
||||
entry_existing=body.entry_existing,
|
||||
entry_price=body.entry_price,
|
||||
stop_loss=body.stop_loss,
|
||||
take_profit=body.take_profit,
|
||||
add_price=body.add_price,
|
||||
new_stop_loss=body.new_stop_loss,
|
||||
add_legs=[leg.model_dump() for leg in body.add_legs],
|
||||
legs_done=body.legs_done,
|
||||
)
|
||||
if err:
|
||||
|
||||
Reference in New Issue
Block a user