3.0 KiB
Backtesting
This menu aims to apply backtesting strategies regarding a pre-loaded ticker, and the usage of the following commands along with an example will be exploited below. Note that this is currently just a simple logic (i.e price comparisons). These strategies should not be used immediately and should be researched, improved and further tested on your own.
- ema
- buy when price exceeds EMA(l)
- ema_cross
- buy when EMA(short) > EMA(long)
- rsi
- buy when RSI < low and sell when RSI > high
NOTE: The current implementation uses the bt library.
ema
usage: ema [-l] [--spy] [--no_bench]
This strategy buys when price > EMA(l).
- -l: Period of EMA to use. Default = 20.
- [--spy]: Flag that overlays the results if you buy and hold SPY
- [--no_bench]: Flag that removes the benchmark comparison of just buy and hold the stock.
ema_cross
usage: ema_cross [-l] [-s] [--spy] [--no_bench] [--no_short]
This strategy goes long when EMA(short) > EMA(long) and goes short when EMA(short) < EMA(long). It provides the option to go long only through the --no_short flag.
- -l/--long: Long period of EMA to use. Default = 50.
- -s/--short: Short period of EMA to use. Default = 20.
- [--spy]: Flag that overlays the results if you buy and hold SPY
- [--no_bench]: Flag that removes the benchmark comparison of just buy and hold the stock.
- [--no_short]: Flag that removes the shortable option. Will just be long positions when short > long EMAs.
rsi
usage: rsi [-u] [-l] [-p] [--spy] [--no_bench] [--no_short]
This strategy goes long when the RSI is "oversold" - defined as the low parameter. It goes short when the RSI is "overbought" - defined as the high (upper) parameter
- -u/--high: High (upper) value to consider overbought. Default = 70
- -s/--short: Short period of EMA to use. Default = 30
- -p/--periods: Periods to use for RSI calculation. Default = 14.
- [--spy]: Flag that overlays the results if you buy and hold SPY
- [--no_bench]: Flag that removes the benchmark comparison of just buy and hold the stock.
- [--no_short]: Flag that removes the shortable option. Will just be long positions when short > long EMAs.





