fix: Gate hub close sync and trade record open stop-loss snapshot
Sync order monitors from Gate position history after hub flat close. Store and display initial_stop_loss in trade records instead of post-amend exchange stops. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,13 +13,27 @@ def _positive_float(value: Any) -> Optional[float]:
|
||||
|
||||
|
||||
def snapshot_stop_loss(initial_stop_loss: Any, stop_loss: Any) -> Optional[float]:
|
||||
"""展示盈亏比时优先用开仓时止损快照。"""
|
||||
"""展示盈亏比 / 交易记录时优先用开仓时止损快照,不用后续改单后的止损。"""
|
||||
sl = _positive_float(initial_stop_loss)
|
||||
if sl is not None:
|
||||
return sl
|
||||
return _positive_float(stop_loss)
|
||||
|
||||
|
||||
def monitor_open_stop_loss(row: Any) -> Optional[float]:
|
||||
"""从 order_monitors 行取开仓止损快照。"""
|
||||
try:
|
||||
keys = row.keys() if hasattr(row, "keys") else ()
|
||||
except Exception:
|
||||
keys = ()
|
||||
init = row["initial_stop_loss"] if "initial_stop_loss" in keys else None
|
||||
cur = row["stop_loss"] if "stop_loss" in keys else None
|
||||
if init is None and isinstance(row, dict):
|
||||
init = row.get("initial_stop_loss")
|
||||
cur = row.get("stop_loss")
|
||||
return snapshot_stop_loss(init, cur)
|
||||
|
||||
|
||||
def snapshot_rr(
|
||||
calc_rr_ratio_fn: Callable[..., Optional[float]],
|
||||
direction: str,
|
||||
|
||||
Reference in New Issue
Block a user