2022-06-27
Trading Algorithms and Trading Strategies
This note contains a collection of trading algorithms or links to algorithms
- Momentum
- Mean-Reversion
- Dynamic Hedging
- Volume-Weighted Average Price (VWAP)
- Algorithm libraries
- Other links
Momentum
Prices are up and we think they’ll continue to go up = Buy (or vice versa). Statistically, most momentum strategies don’t win particularly often but when they do win their gains are fairly large. Win:lose rates of around 55% with gain:loss of around 70% are fairly common with profitable algo’s.
The simplest TSM we can implement would require us to purchase the stock if it was up yesterday, and sell if it was down (if we’re holding it, otherwise we just wait).
References:
- How to Get Started With Algorithmic Finance - KDnuggets)
- Article with Description and code: Algorithmic trading in less than 100 lines of Python code – O’Reilly
- Moskowitz, Tobias, Yao Hua Ooi, and Lasse Heje Pedersen (2012): “Time Series Momentum.” Journal of Financial Economics, Vol. 104, 228-250.
- See repo: trading-with-momentum
Mean-Reversion
This is based on the idea that high and low prices of an asset will revert back to its mean (average) value. Once its price is below the mean, it is seen as an opportunity to buy the asset in hopes of the price going above its average. The average value of an asset constantly changes, so it requires constant monitoring.
Prices are up but we think they’re due a pull-back = Sell (or vice versa). Conversely, most mean reversion strategies win more often than they lose however the gain to loss ratio is smaller. Win:lose rates of around 70% with gain:loss of around 55% are also pretty common with profitable algo’s.
Dynamic Hedging
from: How to Get Started With Algorithmic Finance - KDnuggets
One investment fund that makes some of its strategies public is Invictus Capital’s CRYPTO10 Hedged fund, through its litepaper. In a one-line summary, the fund offers a “dynamic asset allocation strategy that dampens volatility and provides protection against losses.”
The fund fundamentally rebalances 10 assets, which can be seen as 10 data sources, in a manner analogous to the FTSE Russell Capping Methodology, discussed in depth here, which looks like this:
Parameters of their base strategy include a rebalancing period and the number of constituent assets. So, we have insights into the data sources used, the algorithmic strategy, and the parameters. The paper even goes into the basics of the fitness function used:
In the above, ai represents weight, and Xi represents a performance criterion. Maximizing the function yields a portfolio close to the “efficient frontier” - basically, the goal is to make the most money at the least risk.
Read more on FTSE Russell Capping Methodology
Volume-Weighted Average Price (VWAP)
This strategy breaks up a large order and releases dynamically determined smaller chunks of the order to the market using stock specific historical volume profiles. The aim is to execute the order close to the VWAP, thereby benefiting on the average price.
Time-weighted Average Price (TWAP)
The time-weighted average price strategy breaks up a large order and releases dynamically determined smaller chunks of the order to the market using evenly divided time slots between a start and end time. The aim is to execute the order close to the average price between the start and end times, thereby minimizing market impact.
See also: STOP Using Moving Averages! Anchored VWAP is the FUTURE in Day Trading - YouTube
Algorithm libraries
- quantconnect strategy-library - each strategy is in form of tutorial with code, references. High quality.
NOTE: These notes are bits collected from the internet. Proper attribution is needed.
Other links
link | description |
---|---|
Algo-Trading-Strats | Application of various algorithmic strategies to produce max alpha |
sofienkaabar/Trend-Following-Strategies | code for the book Trend Following Strategies in Python; Kaabar, Sofien |
sofienkaabar/Contrarian-Trading-Strategies | code for the book Contrarian Trading Strategies in Python; Kaabar, Sofien |
sofienkaabar/The-Book-of-Trading-Strategies | code for the book The Book of Trading Strategies; Kaabar, Sofien |
Crypto-Gamma-Scalping- | Jupyter Notebook for scraping implementation and analysis, comments in Portugese |
Braavosi-Design/breakout-strategy | |
70+ Trading Strategies (Free) – A List of Quantified Systems – Quantified Strategies For Traders | multiple strategies described, often with accompanying backtesting |
Heikin-Ashi-based strategies
trading_strategies_playlist