项目作者: dummy26

项目描述 :
Predict stock prices using python
高级语言: Python
项目地址: git://github.com/dummy26/Stock-Prediction.git
创建时间: 2021-07-30T04:03:40Z
项目社区:https://github.com/dummy26/Stock-Prediction

开源协议:

下载


Stock-Prediction

Predict stock prices using python

Contents

Installation

Clone this repo and open an instance of terminal and cd to the project’s file path, e.g

  1. cd Users/User/Desktop/Stock-Prediction

Then, run the following in terminal:

  1. pip install -r requirements.txt
  2. python run.py

Quickstart

  1. from data.data_processor import PandasDataProcessor
  2. from data.keras_data.keras_preprocessed_data import KerasPreprocessedData
  3. from data.raw_data import YfinanceNSERawData
  4. from model.keras_models.keras_model import LstmModel
  5. ticker = 'Reliance'
  6. model = LstmModel(ticker, KerasPreprocessedData, PandasDataProcessor, YfinanceNSERawData, name='model_1')
  7. model.train(epochs=1)
  8. pred_date = '2022-02-04'
  9. x, pred_date = model.predict(pred_date) # To get latest prediction call with pred_date = None
  10. print(f'Model predicts that percentage change in closing price of {ticker} on {pred_date} will be: {x}')

(Currently, only symbols of NSE stocks can be used as a ticker)

Overview

This project has a Model class which can be used to train a model on a stock and predict the percentage change in closing price.

Model

Model -> An abstract model class.
LstmModel -> Inherits from Model and uses keras LSTM.

Data

data package contains classes responsible for getting raw data and processing it.

RawData -> Abstract class to get raw data.
YfinanceNSERawData -> Inhertis from RawData and fetches data from NSE using yfinance.

DataProcessor ->Abstract class for intermediate processing of raw data.
PandasDataProcessor -> Inherits from DataProcessor and uses pandas and sklearn for intermediate processing of raw data.

PreprocessedData -> For final processing of data.

Disclamer

This is only for educational purposes and should not be used for actual trading. I won’t be resposible for your losses.

Contributing

Feel free to fork, play around, and submit PRs. I would be very grateful 😁 for any bug fixes 🐛 or feature additions.