Skip to content

Repository files navigation

This project is now part of quant research & backtesting. Use the combined workbench. This repository preserves the earlier standalone source.

Run a real historical experiment

Open the combined research workbench

The browser loads 5,351 historical SPY closes from the existing research cache. It selects a moving-average rule within each training window, freezes that choice for the next test window, lags positions and subtracts trading costs. Change the windows and fees, rerun, inspect each choice and export the out-of-sample returns.

A separate archive presents all 50 original strategy results from quantihack_alt_data_50_results.csv, including full-period and stress-window statistics and paper references. These recorded research runs are not silently relabelled as the browser experiment.

Historical walk-forward research workbench

python -m http.server 8000 --bind 127.0.0.1 --directory examples/portfolio
node --test examples/portfolio/model.test.mjs

Open http://127.0.0.1:8000/legacy.html for the preserved standalone workbench. The local root redirects to the current combined app. The standalone HTML and its original stylesheet live in legacy.html and legacy.css; they share the retained model and datasets.

The price cache's corporate-action adjustment provenance has not been independently reverified. Treat the browser results as a reproducible research exercise, not audited investment performance. The old Pages URL redirects to the combined workbench. Model checks explicitly perturb future data and verify that earlier choices and returns do not change.

Markets Backtesting status readout: 50 signals, two evaluation windows, 11 positive in both

Markets Backtesting

A fixed-rule evaluation harness that runs 50 literature-inspired market signals through one data, execution-cost, and metrics pipeline. It downloads daily price history, replays fixed rules across a full-history window and a focused stress window, then ranks every completed run without hiding the failures.

The hard part is comparability. Calendar effects, cross-asset regimes, price-range estimators, sentiment proxies, and volatility rules all produce different shapes of data. This project gives each one the same lagged execution model, cost accounting, evaluation windows, and result schema.

Evaluation status

The committed run contains 50 completed signals and 22 fields per result. The split is useful: the stress window rejects far more ideas than the full-history measure does.

Readout Result
Registered and completed 50 / 50
Positive full-history Sharpe 39
Non-positive full-history Sharpe 11
Positive stress-window return 12
Non-positive stress-window return 38
Positive on both measures 11

These counts are calculated from the committed result set. A positive measure is strictly greater than zero. No non-positive row is removed from the leaderboard.

Leading combined ranks

The ranking is the mean of two ordinal ranks: full-history Sharpe and stress-window return.

Signal Literature reference Full-history Sharpe Stress return Combined rank
Conditional Risk Parity Asness et al. (2012), SSRN 2050064 0.758 1.957% 4.0
Parkinson Regime Switch Parkinson (1980) 0.642 4.374% 6.5
Holiday Effect Ariel (1990); Lakonishok and Smidt (1988) 0.595 4.803% 7.0
Round Number Avoidance Bhattacharya et al. (2012), SSRN 1364960 0.694 1.096% 7.0
Volume-Weighted RSI(2) Lerman et al. (2008), SSRN 1121475 0.605 2.459% 7.5

Displayed values are truncated from the stored precision in the CSV output. The complete chart is committed alongside it.

Top ten equity curves across the full-history and stress windows

How the run works

flowchart LR
    A["Yahoo Finance daily bars"] --> C["Normalized OHLCV frames"]
    B["Optional local CSV bars"] --> C
    C --> D["50-signal registry"]
    D --> E["Lagged single and multi-asset engines"]
    E --> F["Full history<br/>2010-01-01 to 2026-04-06"]
    E --> G["Stress slice<br/>2026-02-01 to 2026-04-06"]
    F --> H["Metrics and rank aggregation"]
    G --> H
    H --> I["CSV leaderboard"]
    H --> J["Top-ten chart"]
Loading

The engines apply positions one bar after the signal. Single-asset runs charge 1 basis point when the position changes. Multi-asset runs charge 5 basis points on total weight turnover. The output includes CAGR, Sharpe, Sortino, maximum drawdown, Calmar, volatility, win rate, profit factor, skew, tail ratio, and beta.

The stress period is a date slice from each generated equity curve. It is a consistent regime check, but it is not a separately trained holdout. The Sharpe calculation uses daily returns and does not subtract a risk-free rate.

Run the original Python harness

The verified run used Python 3.11.9. The command needs network access for Yahoo Finance unless the optional local daily-bar CSVs are present.

git clone https://github.com/LolStar123/markets-backtesting.git
cd markets-backtesting
python -m pip install -r requirements.txt
python quantihack_alt_data_50.py

The command writes:

  • quantihack_alt_data_50_results.csv: all completed runs, metrics, and ranks.
  • quantihack_alt_data_50.png: full-history and stress-window curves for the top ten ranks.

Local data can be placed under ibkr_data/ using the filenames declared in IBKR_MAP. If a local file is missing, the loader requests the same symbol from Yahoo Finance.

Verify without a provider

python -m unittest discover -s tests -v
node --test examples/portfolio/model.test.mjs
python tools/browser_audit.py

Python checks use synthetic bars to verify execution lag, costs and engine behavior without downloading prices. They also re-count the committed result table. Node checks exercise the bundled historical SPY cache, including changing future prices to prove that earlier training choices and returns stay unchanged. The browser audit checks the redirect and preserved workbench using isolated headless Chrome; it requires the Python Playwright package and Chrome.

These checks do not recreate the original 50-strategy market-data run. Yahoo Finance access and complete daily-bar coverage remain requirements for that run. Optional CSVs need date, open, high, low, close and volume columns; files shorter than 101 rows fall back to download. The listed local filenames cover only eight symbols, so they do not make the entire universe offline.

Repository map

Path Responsibility
quantihack_alt_data_50.py Data loading, indicators, 50-signal registry, evaluation, ranking, and outputs
quantihack_alt_data_50_results.csv Recorded historical result table used for the summary above
quantihack_alt_data_50.png Generated comparison chart
quantihack_algo_baseline.py Separate 16-symbol baseline used as a reference implementation
requirements.txt Runtime dependencies
examples/portfolio/legacy.html Preserved historical browser experiment
examples/portfolio/model.mjs Rolling training selection and out-of-sample browser calculations
tests/test_engines.py Offline Python execution checks and archived-count verification
DESIGN.md Current route, retained source and documentation structure

Baseline callback

quantihack_algo_baseline.py is a separate competition callback, not another standalone backtest command. A host calls on_tick(prices, positions, orders, history) and receives order dictionaries for its synthetic 16-symbol universe. It keeps tick/cooldown state in the module and checks exposure, spread and position limits before producing orders. Running the file directly only defines those functions; this repository does not include the original competition host.

Scope

This is research and evaluation code. It has no broker integration, order routing, or live execution. Several literature-inspired signals use price-derived proxies because their original datasets are unavailable here. Read the implementation comments before interpreting a result. Historical output is evidence about this fixed run, not a forecast. The original Python engine charges on signal changes and omits a first-row entry cost; it does not model spreads, funding, borrowing or market impact. The browser model is a separate implementation. Its training-window selection must not be inferred as a feature of every archived Python strategy.

Contributions should keep signal functions deterministic, preserve one-bar execution lag, and record any metric or cost-model change that would break comparability. See CONTRIBUTING.md for the short workflow. The project is available under the MIT License.

For the optional browser audit, install playwright with python -m pip install playwright. On Linux, also run python -m playwright install --with-deps chromium; on Windows the audit uses installed Chrome. python tools/browser_audit.py serves the actual archived files and checks the public-index redirect against a controlled destination, without claiming the current remote application was tested. Set AUDIT_URL to verify a deployed legacy redirect instead of the local index.

About

Preserved 50-signal Python research and historical walk-forward demo; current work lives in quant-research-scraper.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages