test(plugin): extend runtime smoke to assert advanced backtest features (#1985)

Adds 6 new gates (11-16) that exercise the features wired in
neural-trader 2.8.x:

  11. .metrics.kellyFraction       (real Kelly from win/loss stats)
  12. .walkForward.windowsRun       (rolling 6m/1m validation)
  13. .monteCarlo.distribution      (Gaussian-resampled p5/p50/p95)
  14. .optimization.best.sharpeRatio (parameter sweep result)
  15. .signalsCount                  (live indicator scan)
  16. .aggregate.bestSymbol          (multi-symbol aggregate)

Also bumps NT_PIN default to 2.8.9. Current result: 17 / 17.

Co-authored-by: Reuven <cohen@ruv-mac-mini.local>
This commit is contained in:
rUvandReuven authored and GitHub committed 2026-05-14 14:05:38 -04:00
1 parent cad471be2f
commit b92716b322
1 file changed
+23 -1
@@ -22,7 +22,7 @@ FAILURES=()
# Lock to the version this plugin is pinned against so a global
# npx cache doesn't shadow a stale local install.
NT_PIN="${NT_PIN:-2.8.1}"
NT_PIN="${NT_PIN:-2.8.9}"
WORKDIR="$(mktemp -d)"
trap 'rm -rf "$WORKDIR"' EXIT
@@ -88,6 +88,28 @@ else
bad "version mismatch"
fi
# Helper: run a command and assert a jq path is non-null.
assert_field() {
local label="$1" field="$2"
shift 2
step "$label"
local out value
out=$(npx neural-trader "$@" 2>&1)
value=$(echo "$out" | jq -r "$field" 2>/dev/null)
if [[ -n "$value" && "$value" != "null" && "$value" != "false" ]]; then
ok
else
bad "field $field missing/null/false — head: $(echo "$out" | head -3 | tr '\n' '|')"
fi
}
assert_field "11. backtest exposes Kelly fraction" '.metrics.kellyFraction' --backtest --symbol AAPL
assert_field "12. --walk-forward returns windows" '.walkForward.windowsRun' --backtest --symbol AAPL --walk-forward --period 2023-01-01..2024-12-31
assert_field "13. --monte-carlo returns distribution" '.monteCarlo.distribution.median' --backtest --symbol AAPL --monte-carlo --mc-runs 100
assert_field "14. --optimize returns best Sharpe" '.optimization.best.sharpeRatio' --backtest --symbol AAPL --optimize --param fast_ma:10:20:5
assert_field "15. --signal scan returns ≥1 signal" '.signalsCount' --signal scan --symbols AAPL,MSFT
assert_field "16. multi-symbol aggregate" '.aggregate.bestSymbol' --backtest --symbols AAPL,MSFT,GOOGL
echo ""
echo "$PASS passed, $FAIL failed"
[[ $FAIL -eq 0 ]] || { printf 'failed steps: %s\n' "${FAILURES[@]}"; exit 1; }