Notebook in this repo will create various technical analysis indicators using open source "pandas_ta" package and use those features to create a machine learning model to predict rate of return over the next couple of days. This is a regression problem.
Rate of return is defined as
Where
Creating a portfolio of stocks that could give better returns with less volatility is the main requirement of portfolio creation. Some stocks could give high returns with even higher draw downs. Having such high volatile stocks in a portfolio could lead to high risk and higher margin requirements.
Traders use fundamental and technical analysis to identify the stocks that outperform the index using various valuation and quantiative techniques. This ML model attempts to predict rate of return using Open, High, Low and Close (OHLC) data.
Dataset was sourced from a Kaggle competiton - "JPX Tokyo Stock Exchange Prediction". This dataset consists of
- stock_prices.csv -> Historical stock data prices (non-confidential)
- options.csv -> Options based data
- secondary_stock_prices.csv -> Historical prices of stocks that are less liquid
- trades.csv -> Trading volumes from previous business week
- financials.csv -> Quarterly earnings reports
- stock_list.csv -> General information about each stock
For this initial version of the notebook, only "stock_prices.csv" is used.
- Data science platform
- Model catalog
Notebook uses two conda pacakages:
- "financialservices_p37_gpu_v1"
- "generalml_p37_cpu_v1"
Install these two packages from environment explorer before running the notebook.
This repo has 3 folders.
-
build_model - This folder hosts the notebook with code for feature engineering and model building
-
data- Copy the data from Kaggle source to "data/train_files" folder.
python notebook with create 5 parquet files one for each year of the data from 2017 to 2021.
- artifacts - All files creating during cataloging the model are saved here
- Download the Kaggle competition files from Kaggle and place the files in "data/train_files"
- Access the notebook from "build_model" folder
- For feature engineering steps in the code - use "financialservices_p37_gpu_v1 conda environment
- For model building steps in the code use -"generalml_p37_cpu_v1"