June 27, 2022

# 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:**

- https://www.kdnuggets.com/2020/01/get-started-algorithmic-finance.html)
- Article with Description and code: https://www.oreilly.com/content/algorithmic-trading-in-less-than-100-lines-of-python-code/
- 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: https://www.kdnuggets.com/2020/01/get-started-algorithmic-finance.html

One investment fund that makes some of its strategies public is Invictus Capital’s CRYPTO10 Hedged fund, through their 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, *a**i* 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.

## Algorithm libraries

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 sca;ping implementation and analysis, comments in Portugese |

Braavosi-Design/breakout-strategy | d |

70+ Trading Strategies (Free) – A List of Quantified Systems – Quantified Strategies For Traders | multiple strategies described, often with accompanying backtesting |