Strategy examples#

Here you can find trading strategy examples as Jupyter notebooks.

Note

If you are new to the Trading Strategy framework or algorithmic trading in general, please start by watching the recorded workshop tutorial session from Avalanche Summit.

  • The examples show how to use Trading Strategy framework for algorithmic trading

  • Some notebooks are examples of complete strategies

  • Some notebooks highlight a particular feature

  • These examples also include backtests that you can run yourself.

  • You can copy these files, run and and start editing them to suit your needs.

  • Refer to the Tags section to see all the tags associated with each notebook

Prerequisites#

Get started

Notebook Description
pancakeswap-ema Explore a basic example of Exponential Moving Average (EMA) strategy on PancakeSwap. This notebook is perfect for beginners to learn trend-analysis establish a trading foundation.
pancakswap-ema-stop-loss Discover how to create and run backtests with a stop-loss parameter. This example can help you learn about basic risk management to prevent substantial losses.
osmosis Study an example of creating your own synthetic data. This way, you can simulate any market condition you want as a stress test for your strategy.
bollinger-band-strategy Learn how to convert a PineScript strategy into our own TradingStrategy framework. This notebook uses introduces an indicator called the Bollinger Band in a way that is suitable for beginners.
pancake-eth-usd-indicators Explore the application of detached technical indicators on PancakeSwap's ETH-USD pair. This notebook is a great way to learn how to use detached indicators in your trading strategies, as well as how to visualise horizontal lines and cross over events between multiple indicators. It uses a basic EMA strategy to make trades.

Advanced

Notebook Description
portfolio-construction-model Dive deep into the construction of a momentum-based portfolio. This advanced strategy will show you how to work with a portfolio of assets and improve your understanding of market momentum, which can be a crucial factor in successful trading.
trader-joe-momentum Another example on the construction of a momentum-based portfolio of multiple assets. It uses a simple moving average (SMA) and will also hone your skills in trend analysis.
grid-search Experiment with a grid search example that experiments with different variations of the Bollinger bands strategy shown in the 'Get Started' section. This notebook will enhance your understanding of hyperparameter tuning, essential for optimizing your trading strategies and also demonstrates mean reversion by combining the use of Bollinger Bands and RSI indicators.
momentum-crossover Investigate more complex buy/sell signals with crossovers and crossunders. This advanced example is beneficial for those seeking to employ nuanced trade signals in their trading strategies.
Shorting with Bollinger bands This notebook introduces shorting capabilities. Shorting allows us to profit from downturns in the market. It uses mean reversion to decide on long/short signals. For users seeking to maximize gains from both bull and bear markets, this notebook is for you.
Shorting with Binance data This notebook introduces the concept of 'sideloading', which refers to the use of external data within the TradingStrategy framework. In this case, we use Binance data to short the market. This notebook is a great way to learn how to use external data in your trading strategies to lengthen your backtesting period.

More examples

Notebook Description
synthetic-ema Demonstrates a basic EMA example using synthetic data. Gain a better understanding of EMA application on artificial data for prototyping and testing new trading ideas and strategies.
synthetic-ema-stop-loss Master the use of stop-loss in an EMA strategy using synthetic data. This example will improve your skills in risk management and in the application of algorithmic trading techniques on artificial data.
hackatom-2022-osmosis-backtest Examine synthetic data analysis again with the Hackatom-2022 Osmosis backtest. This notebook places more emphasis on creating and analyzing your synthetic data, and explains how to create data for different market trends and volatilities.
backtest-fee-analysis An example of creating a strategy on synthetic data with a fixed price. This allows us to focus solely on the trading fees paid for each transaction.
examine-live-strategy Examine a live trading strategy using summary statistics and visuals. This is a great way to learn how to evaluate strategy performance in real-time, an essential skill for algorithmic trading.
debugging-live-strategy Learn to debug unsuccessful trades in a live trading strategy. This knowledge will help you identify and correct potential issues in your strategies, improving your trading success rate.
examine-live-strategy-2 Learn how to reverse engineer data from live strategies in order to recreate the current state and OHLCV candles. These candles may also show useful decision making indicators.

Deprecated

Notebook Description
strategy-backtest-template Get familiar with an old backtesting template. Despite its deprecated status, understanding the evolution of backtesting templates can provide insights into the improvements made over time.

Notebook Overview#

Tags#