57 lines
1.3 KiB
Bash
Executable File
57 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(git rev-parse --show-toplevel)"
|
|
cd "$ROOT"
|
|
|
|
SNAPSHOT="${1:-backtest_snapshots/fundamentals-backtest.sqlite}"
|
|
PROTOCOL="${PROTOCOL:-split-safe}"
|
|
WORKERS="${WORKERS:-$(sysctl -n hw.logicalcpu 2>/dev/null || echo 8)}"
|
|
if [[ "$WORKERS" -gt 1 ]]; then
|
|
WORKERS=$((WORKERS - 1))
|
|
fi
|
|
|
|
if [[ -x .venv/bin/python ]]; then
|
|
PYTHON=.venv/bin/python
|
|
else
|
|
PYTHON="${PYTHON:-python3}"
|
|
fi
|
|
|
|
if [[ ! -f "$SNAPSHOT" ]]; then
|
|
echo "Snapshot not found: $SNAPSHOT" >&2
|
|
exit 1
|
|
fi
|
|
|
|
case "$PROTOCOL" in
|
|
split-safe)
|
|
PREFIX="fundamentals-splitsafe"
|
|
SCORE_CACHE="reports/.cache/fundamentals-splitsafe-scores.pkl"
|
|
;;
|
|
original)
|
|
PREFIX="fundamentals-overlay"
|
|
SCORE_CACHE="reports/.cache/fundamentals-scores.pkl"
|
|
;;
|
|
*)
|
|
echo "Unsupported PROTOCOL: $PROTOCOL (use split-safe or original)" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
STAMP="$(date -u +%Y%m%d-%H%M%S)"
|
|
OUT="reports/${PREFIX}-${STAMP}.json"
|
|
|
|
echo "Snapshot: $SNAPSHOT"
|
|
echo "Workers: $WORKERS"
|
|
echo "Protocol: $PROTOCOL"
|
|
echo "Output: $OUT"
|
|
|
|
"$PYTHON" scripts/run_fundamentals_research.py "$SNAPSHOT" \
|
|
--protocol "$PROTOCOL" \
|
|
--workers "$WORKERS" \
|
|
--candidate-cache reports/.cache/fundamentals-candidates.pkl \
|
|
--fundamentals-cache "$SCORE_CACHE" \
|
|
--out "$OUT"
|
|
|
|
echo
|
|
echo "Bring this file back for review: ${OUT%.json}.zip"
|