feat: trend pullback preview TP per DCA leg with unified stop loss across exchanges
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+18
-4
@@ -594,12 +594,26 @@ def _fetch_preview(pid):
|
||||
now_ms = int(time.time() * 1000)
|
||||
d["expires_in_sec"] = max(0, int((int(d.get("expires_at_ms") or 0) - now_ms) / 1000))
|
||||
try:
|
||||
grid = json.loads(d.get("grid_prices_json") or "[]")
|
||||
legs = json.loads(d.get("leg_amounts_json") or "[]")
|
||||
from strategy_trend_lib import build_trend_preview_level_rows
|
||||
|
||||
enriched, level_rows = build_trend_preview_level_rows(d)
|
||||
for key in ("preview_target_rr", "preview_first_take_profit", "preview_unified_stop_loss"):
|
||||
if key in enriched:
|
||||
d[key] = enriched[key]
|
||||
d["preview_level_rows"] = level_rows
|
||||
d["grid_levels"] = [
|
||||
{"i": i + 1, "price": grid[i], "contracts": legs[i] if i < len(legs) else None}
|
||||
for i in range(len(grid))
|
||||
{
|
||||
"i": row.get("i"),
|
||||
"label": row.get("label"),
|
||||
"price": row.get("price"),
|
||||
"contracts": row.get("contracts"),
|
||||
"avg_entry": row.get("avg_entry"),
|
||||
"take_profit": row.get("take_profit"),
|
||||
"stop_loss": row.get("stop_loss"),
|
||||
}
|
||||
for row in level_rows
|
||||
]
|
||||
except Exception:
|
||||
d["grid_levels"] = []
|
||||
d["preview_level_rows"] = []
|
||||
return d
|
||||
|
||||
Reference in New Issue
Block a user