Unraveling the Mysteries of the Stock Market: A Deep Dive into Convolutional Neural Networks for Financial Forecasting
Leveraging Advanced Machine Learning Techniques to Decipher Market Trends and Movements
The stock market is an ever-changing and complex entity, and accurately predicting its movements is a challenge that has fascinated and perplexed analysts for decades. “Going Deeper with Convolutional Neural Network for Stock Market Prediction” is a groundbreaking repository that tackles this challenge head-on. This project aims to predict whether the stock market price will rise in the near future by leveraging the power of advanced convolutional neural networks (CNNs) and a robust methodology.
Download the source code and dataset from the link in comment section.
Data Collection
The data for this project is meticulously gathered from Yahoo! Finance, focusing on time series data for a comprehensive analysis. It includes data from 50 leading companies in the Taiwan 0050.TW index and the top 10 companies from the Indonesia Stock Exchange. This diverse dataset ensures a broad and inclusive approach to stock market prediction.
Methodology
Our approach utilizes candlestick charts as the primary input model for various advanced neural networks. The models employed in this project include:
DeepCNN
ResNet 50
VGG16
VGG19
Random Forest
KNN
These models are chosen for their proven effectiveness in pattern recognition and predictive analysis, especially in complex datasets like stock markets.
Usage
Prepare Environment
We recommend using a virtual environment for optimal results:
Create a virtual environment:
python3 -m venv .env
Ensure you’re running Python 3.5
Install required packages:
pip install -U -r requirements.txt
Prepare Dataset
Convert OHLCV (Open/High/Low/Close/Volume) stock market data to Candlestick charts:
Run binary preprocessing:
python run_binary_preprocessing.py <ticker> <tradingdays> <windows>
.
Example:
python run_binary_preprocessing.py 2880.TW 20 50
Generate the dataset:
python generatedata.py <pathdir> <origindir> <destinationdir>
.
Example:
python generatedata.py dataset 20_50/2880.TW dataset_2880TW_20_50
Remove the alpha channel from images:
Navigate to the dataset directory:
cd /dataset/dataset_2880TW_20_50
Execute:
find . -name "*.png" -exec convert "{}" -alpha off "{}" \;
Training
Train the DeepCNN model:
Command:
python myDeepCNN.py -i <datasetdir> -e <numberofepoch> -d <dimensionsize> -b <batchsize> -o <outputresultreport>
.Example:
python myDeepCNN.py -i dataset/dataset_2880TW_20_50 -e 50 -d 50 -b 8 -o outputresult.txt