mirror of
https://github.com/lucasmos/GoldRegime_X.git
synced 2026-11-02 06:26:15 +00:00
Fix out-of-sample states alignment in backtesting
Updated the out-of-sample (OOS) backtesting process to ensure that the states used are aligned with the OOS data frame index. This change addresses potential mismatches by applying a mask to the states based on the aligned index, improving the accuracy of the backtest results.
This commit is contained in:
File diff suppressed because one or more lines are too long
+5
-1
@@ -702,9 +702,13 @@ def _run_wfo(
|
||||
start += step_bars
|
||||
continue
|
||||
|
||||
# Align states to df_oos_aligned index (prepare_features drops first/last row)
|
||||
oos_mask = df_oos_slice.index.isin(df_oos_aligned.index)
|
||||
states_oos_al = states_oos[oos_mask]
|
||||
|
||||
try:
|
||||
oos_result = vectorized_backtest(
|
||||
df_oos_aligned, probs_oos, states_oos,
|
||||
df_oos_aligned, probs_oos, states_oos_al,
|
||||
split_idx=None, account_size=balance, broker=broker, tf=tf,
|
||||
hmm_transmat=model_is.transmat_,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user