Commit 47e9829
committed
fix(security): latch finer-than-chart request.security history reads to calling-bar boundary
request.security(sym, tf, ta.<fn>(...)[k], lookahead=barmerge.lookahead_on)
where tf is FINER than the script/chart TF (e.g. so2TF="5" read from a 15m
chart) fed the read-before-push history-offset machinery (added for #30/#31)
one native-security-period value late instead of one CALLING-bar late: the
security's own aggregator completes R = script_seconds/requested_seconds
times per calling bar, and hist.push() fired (unconditionally on
is_complete) on every one of those completions, so hist[0] silently drifted
to "one security-period behind the LAST completion of THIS calling bar"
instead of "the last completion of the PREVIOUS calling bar".
Add SecurityEvalState::publish_gate_tf_seconds (validate_security_timeframes):
nonzero only for a plain (non-security_lower_tf) request.security whose
target TF is strictly finer than script_tf and evenly divides it. In
feed_security_eval_state's aggregator branch, gate the is_complete flag
passed to evaluate_security() on wall-clock bucket-end alignment with the
script_tf boundary, instead of passing the raw completion flag through
unconditionally. The underlying TA state (compute/recompute dispatch) is
driven by current_sub_bar_count, independent of this flag, so intermediate
completions still advance the indicator correctly -- only the exposed
history buffer's publish cadence changes. No-op (field stays 0) for every
coarser-or-equal-TF security and every request.security_lower_tf call.
3commas-3commas-triple-rsi-dca-long-risk-adjusted-averaging-strategy
(so2Rsi = request.security(sym, "5", ta.rsi(close,7)[1], lookahead=
barmerge.lookahead_on) on a 15m chart): 50.5% -> 100.0% match vs
TradingView (108/108 trades, 100% exact price). Full corpus
(252 strategies) + ctest (77) unchanged: excellent=251/anomaly=1,
tier-for-tier identical to baseline. Spot-checked every other
lookahead_on + history-offset request.security call site in the standard
corpus (6 other slugs, all coarser-than-chart target TFs, e.g. "D"/"W"/
240/60) -- byte-identical engine_trades.csv/engine_verify.json output,
confirming zero blast radius outside this one finer-than-chart case.1 parent 8d5bad8 commit 47e9829
2 files changed
Lines changed: 68 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1076 | 1076 | | |
1077 | 1077 | | |
1078 | 1078 | | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1079 | 1112 | | |
1080 | 1113 | | |
1081 | 1114 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
222 | 223 | | |
223 | 224 | | |
224 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
225 | 239 | | |
226 | 240 | | |
227 | 241 | | |
| |||
405 | 419 | | |
406 | 420 | | |
407 | 421 | | |
408 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
409 | 443 | | |
410 | 444 | | |
411 | 445 | | |
| |||
0 commit comments