Show option net P/L from bid recycle minus premium.
Rename floating P/L to net P/L, align ROI, and display bid depth as price/liquidity for only the levels needed to close. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -70,6 +70,7 @@ def estimate_close_by_bids(
|
||||
"total_received": 0.0,
|
||||
"avg_px": None,
|
||||
"estimated_pnl": None,
|
||||
"estimated_pnl_ratio_pct": None,
|
||||
}
|
||||
for i, level in enumerate(bids or [], start=1):
|
||||
if remaining <= 0:
|
||||
@@ -98,10 +99,14 @@ def estimate_close_by_bids(
|
||||
remaining -= take
|
||||
covered = target - remaining
|
||||
avg_px = (total_received / eth_amount_from_sheets(covered, ct_mult)) if covered > 0 else None
|
||||
# 净盈亏 = 按买盘可回收 − 全部权利金(与「可落袋」口径一致;买一不够会展开更多档)
|
||||
estimated_pnl = None
|
||||
estimated_pnl_ratio_pct = None
|
||||
if premium_paid is not None and covered > 0:
|
||||
paid_basis = float(premium_paid) * (covered / target)
|
||||
estimated_pnl = round(total_received - paid_basis, 4)
|
||||
paid = float(premium_paid)
|
||||
estimated_pnl = round(total_received - paid, 4)
|
||||
if paid > 0:
|
||||
estimated_pnl_ratio_pct = round(estimated_pnl / paid * 100.0, 2)
|
||||
return {
|
||||
"levels": levels,
|
||||
"covered_sheets": covered,
|
||||
@@ -109,6 +114,7 @@ def estimate_close_by_bids(
|
||||
"total_received": round(total_received, 4),
|
||||
"avg_px": round(avg_px, 4) if avg_px is not None else None,
|
||||
"estimated_pnl": estimated_pnl,
|
||||
"estimated_pnl_ratio_pct": estimated_pnl_ratio_pct,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user