This is the R shinyapp I made to analyze stock trading algorithm. It incorporates different time scales, transformation(log) of stock price, buy/short or both, risk free percent, stop loss, algorithms based on stock or index. The app will show the trading history, different aspect of your algorithm and you can download the report of your backtest. For the sake of limited computational resources, I’ve fixed the stock as “SPY” and the time frame from 1995-01-01 to 2009-12-31. Please scroll down to see more details and examples. You can download the report with all the information in the app after you have your own algorithm!


Examples

Here are some examples that shows how you can tuning different parameters in this shinyapp.

Moving Average

First let’s look at the moving average of the stock price. I have smoothing moving average(SMA) and exponential moving average(EMA) in the app.

Weekly SMA10 cross SMA30

If We buy when weekly SMA10 up cross SMA30, and sell when weekly SMA10 down cross SMA30, it outperformed the SPY in the long term, but it performs worse than SPY in the first 7 years.