Skip to content

Contains my attempt at predicting NIFTYBank Index returns & generic modelling utilities

License

Notifications You must be signed in to change notification settings

raghavsikaria/Project-Rajasuyya

Repository files navigation

Project-Rajasuyya

Contains my attempt at predicting NIFTYBank Index returns & generic modelling utilities

DISCLAIMER - What this project is not:

  1. This project does not give any investment advice & is purely for research and academic purposes
  2. The analysis is based on data spanning 2 decades and the macro-economic scenario changes alone in that span, make it impractical for us to draw any inference in short term from this analysis
  3. The code is not meant for production, error-catching and logging mechanism have been skipped intentionally

AND IFF

  • You like the project -> please star it on GitHub
  • You find anything wrong -> please raise an issue in GitHub repository here
  • You want to enhance/improve/help or contribute in any capacity -> please raise a PR in GitHub repository here
  • You use any of the codes -> kindly provide a link back to this project or my profile on LinkedIn/GitHub (courtsey in Open Source) ...there's always scope in improving the code design!

I can't recall ever once having seen the name of a market timer on Forbes' annual list of the richest people in the world. If it were truly possible to predict corrections, you'd think somebody would have made billions by doing it.
                                                  - Peter Lynch

Hello reader, this project is completetly about Time Series - its analysis, prediction modelling and hyperparameter optimization(HPO) - specifically Bayesian HPO using Gausian Processes. I have made sure that the code is reusable. You can find some cool coding hacks and extensive API usage of libraries in the code. What's more?! Since the code is generic, you can also try it out on different data sets as well! We'll employ ARIMA, Deep Learning - CNNs, LSTMs & the likes. It's going to be extremely technical, all code has been open sourced here and I have tried my best to aid you with explicit code comments and annotations. The project has been implemented in Python & following are the libraries utilised:

  • Deep Learning library - tf.keras (yes, there's difference between this and Keras)
  • Visualization library - Bokeh
  • Hyperparameter Optimization library - Skopt (scikit-optimize)
  • Data processing library - Pandas, Numpy, sklearn & statsmodels

Will also be writing in detail in upcoming weeks about underlying math and theory of the concepts involved in the project!

I attended CFA Society, India's webinar on 11th April '20 by Kriti Mahajan moderated by Shreenivas Kunte, CFA, CIPM on the topic- "Practitioners' Insights: Using a Neural Network to Predict Stock Index Prices" which gave me the idea & inspiration to invest my time in this direction and this project was born!

P.S: Like always all code can be found here.

Objective

  • To analyse a Time Series dataset (in this project - NIFTYBANK specifically, but you can use any dataset)
  • To conduct Data exploration for understanding the data
  • To process time-series data, normalise it and conduct data-stationarity testing
  • To prepare benchmark in predictive modelling using traditional algorithms like ARIMA
  • To apply Deep Learning techniques & try and improve on predictive modelling performance
    • To automate modelling process
    • To automate & apply Bayesian HPO techniques and find optimal hyperparameters for the models
    • To automate & generate markdown document for each model which summarizes the model in its entirety - from architecture to HPO process to performance

Contents

  1. Data Exploration, Analysis & Processing
  2. Generating Benchmark using ARIMA
  3. Deep Neural Networks
  4. Understanding the Code
  5. Acknowledgements
  6. References

Understanding the Code

Here is quick primer to understand repository and structure of code:

.
├── assets
│   ├── simple_cnn
│   └── simple_lstm
├── config
│   └── model_configurations.py
├── initiate_predictive_modelling.py
├── LICENSE
├── models
│   └── neural_network_models.py
├── README.md
└── utils
    ├── data_processing_utils.py
    ├── data_stationarity_utils.py
    ├── data_visualization_utils.py
    └── model_utilities.py
  • assets: You can find all plots, html files, markdown documents here
  • config/model_configurations.py: You can find all config variables set here for the entire project
  • initiate_predictive_modelling.py: A temporary piece of code I created over other utilities so that one can carry out end to end process and get a feel of things
  • utils/data_processing_utils.py: You can find all Data processing tools here - reading CSV, dealing with NA, interpolation of data, saving df, computing lagged features, splitting time series data, data standardization, data normalization, etc
  • utils/data_stationarity_utils.py: You can find functions here to check for covariance stationarity over given data
  • utils/data_visualization_utils.py: You can find all visualization related functions here - bokeh utils, skopt plots, etc
  • utils/model_utilities.py: You can find all model related utilities here - saving your model, generating predictions, conducting HPO, etc
  • models/neural_network_models.py: Contains interfaces for all models that we prepare

If I've had your interest so far, let's collaborate over GitHub and make this better. You can also reach out to me incase you have any queries pertaining to anything. Hope this helps!

Acknowledgements

My sincere thanks to Kriti Mahajan, Shreenivas Kunte, CFA, CIPM & CFA Society, India to conduct and host the webinar. It was quite insightful & gave me all the inspritaion I needed to take this project up. The entire session can be found here on Youtube.

References

Time Series modelling & tf.keras Resources

Hyperparameter Optimization Resources

NIFTYBank Data Resources

About

Contains my attempt at predicting NIFTYBank Index returns & generic modelling utilities

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages