chart: anchor chain-link on successor funding value (keep first-day P&L visible)
Browse files
app.py
CHANGED
|
@@ -69,9 +69,9 @@ def _frozen_history():
|
|
| 69 |
try:
|
| 70 |
h = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "deepquant_live_history.json",
|
| 71 |
repo_type="dataset", token=os.environ.get("HF_TOKEN"), force_download=True)))
|
| 72 |
-
return [(dt.datetime.fromisoformat(d), float(v)) for d, v in h["daily_equity"]]
|
| 73 |
except Exception:
|
| 74 |
-
return []
|
| 75 |
|
| 76 |
|
| 77 |
def build_curve():
|
|
@@ -85,13 +85,16 @@ def build_curve():
|
|
| 85 |
# (Friday's close shows up under "Saturday"). Snap each point to its trading date.
|
| 86 |
daily = [(dt.datetime.combine(d.date(), dt.time.min), v) for d, v in daily]
|
| 87 |
note = ""
|
| 88 |
-
frozen = _frozen_history()
|
| 89 |
if frozen:
|
| 90 |
splice = frozen[-1][0]
|
| 91 |
new = [(d, v) for d, v in daily if d > splice]
|
| 92 |
# chain-link: the successor account restarts at its own funding value, so scale its
|
| 93 |
-
# curve so that
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
| 95 |
note = ("Chain-linked series: the brokerage account was re-provisioned in Oct 2026; "
|
| 96 |
"history is the predecessor account's actual record, and the successor's curve is "
|
| 97 |
"linked at the splice so fund performance is continuous. Account value shown may "
|
|
|
|
| 69 |
try:
|
| 70 |
h = json.load(open(hf_hub_download("s-ttp/marketfm-panel", "deepquant_live_history.json",
|
| 71 |
repo_type="dataset", token=os.environ.get("HF_TOKEN"), force_download=True)))
|
| 72 |
+
return [(dt.datetime.fromisoformat(d), float(v)) for d, v in h["daily_equity"]], h.get("successor_base")
|
| 73 |
except Exception:
|
| 74 |
+
return [], None
|
| 75 |
|
| 76 |
|
| 77 |
def build_curve():
|
|
|
|
| 85 |
# (Friday's close shows up under "Saturday"). Snap each point to its trading date.
|
| 86 |
daily = [(dt.datetime.combine(d.date(), dt.time.min), v) for d, v in daily]
|
| 87 |
note = ""
|
| 88 |
+
frozen, succ_base = _frozen_history()
|
| 89 |
if frozen:
|
| 90 |
splice = frozen[-1][0]
|
| 91 |
new = [(d, v) for d, v in daily if d > splice]
|
| 92 |
# chain-link: the successor account restarts at its own funding value, so scale its
|
| 93 |
+
# curve so that the funding value continues the frozen record's last close exactly.
|
| 94 |
+
# Anchoring on the recorded funding value (successor_base) rather than the first
|
| 95 |
+
# close keeps the successor's own first-day P&L visible instead of absorbing it.
|
| 96 |
+
anchor = succ_base or (new[0][1] if new else None)
|
| 97 |
+
daily = frozen + ([(d, v * frozen[-1][1] / anchor) for d, v in new] if new else [])
|
| 98 |
note = ("Chain-linked series: the brokerage account was re-provisioned in Oct 2026; "
|
| 99 |
"history is the predecessor account's actual record, and the successor's curve is "
|
| 100 |
"linked at the splice so fund performance is continuous. Account value shown may "
|