GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Kali-Uga/trend-following-futures: Quant research: volatility-scaled trend-following on futures — parameter robustness, multi-timeframe decay, EWMAC/MACD/Bollinger comparison, purged walk-forward optimization, and a multi-asset (NQ/JY/BTC) portfolio

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
notebooks
notebooks
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

Trend-Following Strategy Research on Futures

A quantitative research project that builds a volatility-scaled trend-following strategy on continuous futures and stress-tests it across parameters, timeframes, indicator families, walk-forward windows, and a multi-asset portfolio. The emphasis is on honest evaluation and overfitting risk rather than curve-fitted performance.

Python pandas NumPy Domain Reporting License


The strategy

A continuous, volatility-normalized trend-following position:

position = EMA(log returns) / (signal_vol * asset_vol) * scale     (capped at +/- pos_limit)
  • EMA of log returns — the trend signal over a look-back period; positive => long, negative => short.
  • signal_vol — volatility of the signal (EMA of absolute log returns).
  • asset_vol — instrument volatility (double-smoothed EMA of absolute log returns).
  • scale — scales the influence of volatility on the final target position.

Dividing by volatility gives dynamic position sizing: exposure shrinks in turbulent regimes and grows in calm trends.

Backtesting methodology

  • No look-ahead — all features are computed on shifted data, so a bar's position only uses information available before it.
  • Costs — per-trade slippage applied on position changes.
  • Calendar-day annualization — zero returns inserted on non-trading days (instead of the usual 252-day convention), so strategies across instruments, exchanges and timezones stay comparable.
  • In-sample / out-of-sample split — parameters optimized on 2018 to mid-2022, then evaluated on the held-out test period.
  • Tear sheets — full performance/risk reporting via pyfolio.

Research studies

The base notebook is extended with five self-contained studies:

# Study Question Key finding
1 Parameter robustness How sensitive is the strategy near its optimum? period sits on a plateau (best ~263): moving to neighbouring grid values costs only ~4–4.5% Sharpe => robust, low overfitting risk on this axis.
2 Multi-timeframe Does edge survive from 5-min to daily? Clear monotonic decay: Sharpe > 1.40 at 5-min, > 1.22 at 15-min, falling to ~0.38 daily. The optimal look-back (in bars) scales down with the timeframe.
3 Indicator families Do EWMAC / MACD / Bollinger beat the base signal? None beat the benchmark or the original signal; MACD was the most respectable of the alternatives.
4 Walk-forward optimization Are the optimal parameters stable through time? With 2-year train / 3-month test windows and purging, the best period jumps erratically (~200 to ~3400) with no stable optimum — a caution against trusting a single in-sample fit.
5 Multi-asset portfolio Does diversification help? Equal-weighted WFO portfolio over NQ, JY, BTC produces a visibly smoother equity curve, but near-zero total return — NQ's gains are offset by JY/BTC losses.

The honest negative results (Studies 3–5) are the point: they demonstrate walk-forward discipline, purging against leakage, and skepticism toward in-sample Sharpe.

Quickstart

pip install -r requirements.txt
jupyter notebook notebooks/01_trend_following_research.ipynb

Data

The notebook works on intraday logarithmic returns of continuous (back-adjusted) futures — one CSV per instrument named {ticker}.csv. Each file is indexed by a date timestamp column (YYYY-MM-DD HH:MM:SS, ~5-minute bars) holding the log-return series; coarser timeframes are produced by resampling inside the notebook.

Instruments used in this study:

Ticker Instrument Asset class
NQ E-mini Nasdaq-100 index futures (CME) Equity index
JY Japanese Yen FX futures (CME) Currency
BTC Bitcoin Crypto

Data is not bundled (see .gitignore). To reproduce, supply your own {ticker}.csv files next to the notebook. Continuous-futures return series like these are typically obtained from:

  • commercial historical-data vendors that publish ready-made back-adjusted continuous-futures series, or
  • a broker / exchange market-data API (e.g. CME-listed contracts via a broker; crypto such as BTC directly from an exchange API), or
  • built yourself by stitching and back-adjusting consecutive contract expiries into a single continuous series.

Any source works as long as the CSV matches the date + log-return format above.

Project structure

trend-following-futures/
├── notebooks/
│   └── 01_trend_following_research.ipynb   strategy + 5 research studies
├── requirements.txt
├── LICENSE
└── README.md

Tech stack

pandas · numpy · matplotlib · pyfolio (tear sheets) · tqdm · grid search · walk-forward optimization with purging

Disclaimer

Educational / research project on historical data. Not investment advice. Backtested results do not guarantee future performance.

License

MIT

About

Quant research: volatility-scaled trend-following on futures — parameter robustness, multi-timeframe decay, EWMAC/MACD/Bollinger comparison, purged walk-forward optimization, and a multi-asset (NQ/JY/BTC) portfolio

Topics

algorithmic-tradingbacktestingfuturespandaspyfolioquantquantitative-financesharpe-ratiosystematic-tradingtrading-strategiestrend-followingwalk-forward-optimization

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402605 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.