Algo Trading Basics
Learn the basic process and components for Algo trading
This will review the process for portfolio management in regards to Algo trading. Remember this is all simply portfolio management, so let us not get too focused on the machine learning component of it. We can use advanced machine learning techniques in order to improve the prediction accuracy of time-series predictions. In order to make that useful let us first learn the basic components.
Basic Algo Development Process:
This process is similar to software development in that it ensures a proper framework for implementation, and testing methodology so as not to release any updates that are not performing as good or better than their predecessors. The important parts here are ensuring you are building something against a theory and then properly backtesting it before allowing it to trade with real money. A simple backtest should have a baseline so we can compare it against a buy and hold. In our example, we use the backtest metrics natively, but in future, we will expand this to first use the S&P buy/hold as the baseline, then to include the performance of past algorithms as we release them.
The implementation can be a vague view of what can be a complicated solution. To simplify it we have laid out some of the major components that exist in all Algos and attempt to explain the purposes of each.
Algo Trading Process:
- Trigger: How is the process for Algo processing triggered? IE. Time(Daily, Weekly), Event Based(Passing SMA)
- Screener: Simple quick criteria for filtering the stocks. IE. Min Volume, Min Per Stock Price, No legal Action
- Analysis: Main logic for stock evaluation and possibly machine learning for prediction. IE. Fundamental Analysis, Technical Analysis, Stock Prediction
- Portfolio Weighting: Portfolio management to determine what to do with the previous analysis. IE. Equal Weight(Determine how to sell and equalize the weight of all stocks in portfolio).
- Execution: Take determined action on the selected stocks. IE. Sell Apple, Buy TSLA
- Monitoring: Monitor the portfolio for new data and unpredictable events. IE. New pending legal action is released.
This gives a broad overview of the components in creating your own Algorithm for trading. We should now be able to see where is it appropriate to insert machine learning into the process.
The final most important piece of information is to do proper backtesting and then use the standard metrics used in trading to determine the performance of the your Algorithms to ensure you are not utilizing one that decreases performance.
Below is an example out from our example for metrics on backtesting:
Stat above50sma
------------------- ------------
Start 2010-01-03
End 2020-06-08
Risk-free rate 0.00%
Total Return 207.37%
Daily Sharpe 0.59
Daily Sortino 0.97
CAGR 11.37%
Max Drawdown -36.50%
Calmar Ratio 0.31
MTD 15.79%
3m 26.51%
6m 8.39%
YTD 2.93%
1Y 21.45%
3Y (ann.) 4.32%
5Y (ann.) 7.01%
10Y (ann.) 13.66%
Since Incep. (ann.) 11.37%
Daily Sharpe 0.59
Daily Sortino 0.97
Daily Mean (ann.) 13.23%
Daily Vol (ann.) 22.25%
Daily Skew 1.26
Daily Kurt 29.64
Best Day 22.93%
Worst Day -7.99%
Monthly Sharpe 0.61
Monthly Sortino 0.94
Monthly Mean (ann.) 13.26%
Monthly Vol (ann.) 21.73%
Monthly Skew -0.97
Monthly Kurt 1.73
Best Month 15.79%
Worst Month -22.73%
Yearly Sharpe 0.64
Yearly Sortino 1.60
Yearly Mean 13.76%
Yearly Vol 21.62%
Yearly Skew -0.51
Yearly Kurt -0.31
Best Year 43.65%
Worst Year -25.96%
Avg. Drawdown -3.88%
Avg. Drawdown Days 39.95
Avg. Up Month 4.56%
Avg. Down Month -5.49%
Win Year % 80.00%
Win 12m % 73.91%
Backtesting will give you all of these metrics to get a general idea of how your algorithm is performing. In future, we may expand this backtesting to essentially be multi-test to determine it’s quality across different stocks and different time periods. Perhaps we can reflect it’s performance against similar times where the market sentiment matched the current one to try to more accurately predict it’s current performance.
In the meantime feel free to check out the videos and GitHub review to start creating your own empire.
Check out the youtube: https://www.youtube.com/watch?v=91_rjDr7rB0
Check out the Repo: https://github.com/Deamoner/ultimate-stock-machine-learning-training-dataset
Checkout the Colab Notebook: Notebook Link