There is an ambiguous line between what can be confidently inferred from a backtest and what is simply a reflection of random market movements. The strength of a trend is best identified through various stress testing methods applied across broad data sets.
The vision for this repository is to store a comprehensive annotated collection of analyzed trading systems, backtesting frameworks, concepts, and ideas coded in Python Jupyter Notebook. Chapters in this repository cover various concepts, utilize multiple backtesting libraries, and employ several ways to validate testing. Most trading systems rely solely on price/volume indicators which can be quantifiable, replicable, and measured.
Backtesting
Backtesting is a technique used in trading and investing to assess the performance of a trading strategy or investment approach using historical market data. By applying specific predetermined rules and parameters, backtesting can offer traders valuable insights into potential profitability, risks, and comparisons with alternative strategies.
Why code it?
Algorithmic trading (and backtesting) offers speed, precision, and consistency beyond human capabilities. Code is an invaluable tool for defining and combining indicators into easily adjustable entry signals and creating live visualization comparison of performance metrics/benchmarks.
Tip
Find highlighted comments in every project for quick summary of concepts and analysis. Color scales indicate key findings, limitations, and improvements.
Strategy-Backtest-Commentary
001-MA Crossover_______Simple trend-following system aimed to reduce drawdowns tested on 30-year SPX daily data
002-
003-
| Concept | Status | Description, notes |
|---|---|---|
| Moving average optimization | Can we validate entry parameters by optimizing across every relevant performance metric-theory, limitations | |
| Mutli-asset backtest | Backtest trading a universe of assets, 1% of equity, sl - Idea; (if not taking signals but holding and rebalancing) rank strenght of signal and buy one or few top ranked | |
| Random Entry | Random entry & direction ... is it possible to beat the market with only good risk management (position sizing, atr sl) | |
| Quantitative Momentum | The Quantitative Momentum Investing Philosophy by Jack Vogel, Ph.D. - ranks stocks by momentum and trend strenght, rebalanced quaterly | |
| Year High or 100 Day High | Enter position (from a universe of assets) if price reaches yearly high (250/100/other period lookback), sell at 10% gain | |
| Backtestesting tool | Documentation | Example | Description |
|---|---|---|---|
| NumPy (daily returns) | NumPy guide | tryyy | Storing data in arrays/matrices - calculating daily returns, benchmark drawdowns, strategy performance |
| backtesting.py | kernc.github.io | Popular Python framework for inferring viability of trading strategies on historical data | |
| Backtrader | backtrader.com | Write and reusable trading strategies, indicators, performance visualization | |
| VectorBT | vectorbt.pro | Ability to combine multiple strategy instances into a single multi-dimensional array, enabling highly efficient data processing | |
| zipline | zipline-trader | Backtesting/trading program compatible with Interactive Brokers and Alpaca | |
| build your own? | Reliability, control, scale, independence, Possible starting point;algotrading101blog | ||
| Testing method | Documentation? | Example | Description |
|---|---|---|---|
| Single-run automated | python arrays/matrices - calculating daily returns, benchmark drawdowns, strategy performance | ||
| Multi-run optimization | Cross-parameter backtesting - allows for many tests with many entry signal combinations | ||
| Walk-forward | Finding optimal in-sample trading parameters and checking the performance in the following time period for out-of-sample results | ||
| Monte Carlo simulations | Helps assess strategy's robustness by randomizing simulation parameters & inputs (trade sequence, skip n trades) | ||
| combination ? | Examine how the performance/robustness of a strategy changes across assets |
| Indicator | Example | Description | |
|---|---|---|---|
| Volume | |||
| Moving Average | |||
| RSI | |||
| (A)TR | |||
| Market Open | |||
| MACD | |||
| WVAP | |||
| Bollinger Bands | |||
| PSAR | |||
Important
This repository is in early stage of production, contribution etc. to be added (open to improvement ideas, feedback, contributions)
Though most work is authentic, some studies employ open-source code by online traders (all scripts are credited and accompanied by author's original license)
*create seperate file/folder to be designated for resources, learning paths, tools, references
"Absorb what is useful, discard what is not, add what is uniquely your own"
Bruce Lee
"As far as we can discern, the sole purpose of human existence is to kindle a light in the darkness of mere being"
Carl Jung
add:
resources, learning tools references, credits


