fix: purge raw_next from portfolio_sim_kernel + update stale comments
portfolio_sim_kernel also used next_close_raw (future price) for mark-to-market and reward computation. Fixed: use current price only. Updated stale comments referencing per-bar reward in trade-level section. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1630,8 +1630,8 @@ extern "C" __global__ void experience_env_step(
|
||||
}
|
||||
|
||||
/* ── v10: Trade-level reward attribution ──────────────────────────────
|
||||
* Per-bar reward (next_close - close) has SNR ~0.01 — 99% random walk
|
||||
* noise. Trade-level P&L has SNR ~0.1-0.5 — the atomic unit of signal.
|
||||
* Rewards are PER-TRADE only. No per-bar P&L (was removed: used raw_next
|
||||
* which is future information, and per-bar noise has SNR ~0.01).
|
||||
*
|
||||
* When segment_complete fired above, reward already has the trade P&L
|
||||
* (vol-normalized, soft-clamped, with Layer 4-9 credits).
|
||||
@@ -2027,7 +2027,7 @@ extern "C" __global__ void portfolio_sim_kernel(
|
||||
float current_close = (targets[t_offset + 0]);
|
||||
float next_close = (targets[t_offset + 1]);
|
||||
float current_close_raw = (targets[t_offset + 2]);
|
||||
float next_close_raw = (targets[t_offset + 3]);
|
||||
(void)(targets[t_offset + 3]); /* next_close_raw: FUTURE — must NOT be used */
|
||||
|
||||
float price = (current_close_raw != 0.0f) ? current_close_raw : current_close;
|
||||
if (price <= 0.0f) price = 1.0f;
|
||||
@@ -2094,10 +2094,10 @@ extern "C" __global__ void portfolio_sim_kernel(
|
||||
|
||||
last_price = price;
|
||||
|
||||
float next_price = (next_close_raw != 0.0f) ? next_close_raw : next_close;
|
||||
if (next_price <= 0.0f) next_price = price;
|
||||
float next_value = cash + position * next_price;
|
||||
float next_norm = next_value / initial_cap;
|
||||
/* Use current price for mark-to-market — NOT next_close_raw (future info).
|
||||
* next_close_raw must NOT feed into reward/equity/P&L. */
|
||||
float mtm_value = cash + position * price;
|
||||
float next_norm = mtm_value / initial_cap;
|
||||
|
||||
float max_pos_norm = (price > 0.0f) ? initial_cap / price : 1.0f;
|
||||
float pos_norm = position / max_pos_norm;
|
||||
|
||||
Reference in New Issue
Block a user