Skip to content

🎸 Projects in this repository cover various trading concepts, utilize multiple backtesting libraries, and employ several ways to validate testing.

License

Notifications You must be signed in to change notification settings

MoneyforNotn/Strategy-Backtest-Commentary

Repository files navigation

alt

Introduction

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 sets of data.

Vision

The vision for this repository is to store a comprehensive annotated collection of trading systems, backtesting frameworks, strategy assessments, market theories, and ideas coded in Python Jupyter Notebook. Chapters in this repository cover various concepts, utilize multiple backtesting methods/libraries, and employ several ways to validate testing. Most trading systems are devised only from price/volume data indicators which are quantifiable, replicable, and can be 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 profitability potentials, risks and constrains, and perfomance comparisons to 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.

Project list

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 optimization aimed to reduce drawdowns tested on 30-year SPX daily data
002-Random Entry______With robust risk-management and position sizing even random entries can be profitable (multi asset)
003-London Breakout___Designed to capitalize on the high liquidity and volatility of the FOREX market during the London session
004-

Strategy concepts & trading ideas

Concept Status Description, notes
Moving average optimization 001-MA Crossover 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; OR (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
Break Out Indicator Detect price break-outs by identifying trading range break-outs in combination with liquidity sweeps and n. of bars above/below MA

Backtesting libraries & tools

Backtestesting tool Documentation Example Description
NumPy (daily returns) NumPy guide 001-MA Crossover Storing data in arrays/matrices - calculating daily returns, benchmark drawdowns, strategy performance
backtesting.py kernc.github.io 001-MA Crossover 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 methods & approaches

Testing method Documentation? Example Description
Single-run automated 001-MA Crossover python arrays/matrices - calculating daily returns, benchmark drawdowns, strategy performance
Multi-run optimization 001-MA Crossover 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

Indicators, signals, TA

Indicator Example Description
Volume
Moving Average 001-MA Crossover Many traders use moving averages as the basis for a trend-following trading system as a confirmation signal to another indicator
RSI
(A)TR
Market Open
MACD
WVAP
Bollinger Bands
PSAR
Beta

EMH & Trading Philosophy

Market Efficiency Theory states that market prices tend to be perfectly reflective of all information in the market, implying that asset prices are always trading at their fair value. Thus, under a 'random walk' assumption, historical market and volume data have no value in predicting future stock prices. In other words, 'technical analysis' is useless and trying to time the market is a loser's game.

Adaptive Market view suggests market efficiency isn't fixed, but it evolves with competition, conditions, and who controls the volume.

Leading conclusions & assumtions:

The movement of market prices is not always completely random

Investor psychology, time-varying investor preferences, over-reaction, under-reaction, transaction costs, informational constraints, and even widespread use of similar trading systems contribute to this nonrandomness

Trading systems can be developed to effectively exploit deviations from the random walk. Mechanical trading systems can be profitable, in part, because they are immune to greed and fear

Over-reaction is more prevalent for some types assets and time frames (suitable for mean-reversion systems), and under-reaction is more prevalent in others (momentum systems)

There are different ways to characterize risk, including volatility measured by standard deviation and the probability of experiencing a drawdown of a given size


Contributing

Important

This repository is in early stage of production, contribution etc. to be added (open to improvement ideas, feedback, contributions)

Credits

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

Wholeness is not something you create, it is something you notice. It's the quiet realization that nothing is actually missing, now.

develop notes

add:
resources, learning tools references, credits
hide unecessary outputs in .ipynb strategies
revisit- Algotrading: Position size – devils game

credits/resrouces
Youtube - The art of trading
Youtube - Benjamin
Youtube - Quantconnect
Rapusa blog
Youtube - Moon Dev
Algotrading101 blog
Alpha Vantage
Youtube – CodeTrading
Youtube – Martin Bell
Youtube - Neuralnine
Youtube - Chad Thrackray
Youtube - Lit Nomad

About

🎸 Projects in this repository cover various trading concepts, utilize multiple backtesting libraries, and employ several ways to validate testing.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published