MHL CONSULTING PLLC
  • Home
  • Services
    • Electrical Engineering Services
    • Electrical Design Services
    • Electrical PE Stamping Services
    • Emergency Engineering Assistance Services
  • Highlighted Projects
  • About
    • FAQ
  • Contact
  • Blog

MHL | Blog 

Using Deep Learning to Optimize Stock Trading

1/6/2023

0 Comments

 

Introduction:
I have always been interested in the role that capital allocation plays in society. The stock market is the primary marketplace for this process, and being able to effectively allocate capital can have a significant impact on an organization's growth and success. As part of a project for my studies, I decided to investigate the use of deep learning to help optimize the investment of capital in the stock market. Specifically, I wanted to see if deep learning could be used to aid stock traders in maximizing their profits and minimizing their risks.​

The Problem: Stock price prediction is a complex task that requires a thorough understanding of market trends and patterns. It can be especially challenging due to the high level of noise and randomness in stock data. This is where deep learning can come in handy.

Deep Learning Idea: Our goal is to create a deep learning program that can accurately predict whether a stock's price will increase or decrease over the next hour. We will use fully-connected neural networks (FCNN), convolutional neural networks (CNN), and long short-term memory (LSTM) networks to analyze stock data and make predictions.

FCNNs are composed of layers of interconnected neurons that are capable of representing complex nonlinear relationships. CNNs, on the other hand, can learn features automatically and output multi-step vectors directly. They do this by distilling input information into feature maps at each layer of the network. LSTM networks are a variant of recurrent neural networks (RNN) that can capture long-term dependencies. They have memory cells with gates that control the flow of information in and out of the cells, allowing them to "remember" dependencies seen during training.

Model Description:
We will be using the following architectures for our deep learning models:
Fully-Connected Neural Network (FCNN) Architecture:
  • Flatten( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 1, activation = 'relu')
  • Reshape([1,-1])
Convolutional Neural Network (CNN) Architecture:
  • Conv1D(filters = 1000, kernel_size = 4)
  • BatchNormalization( )
  • Conv1D(filters = 1000, kernel_size = 4)
  • BatchNormalization( )
  • MaxPooling1D(pool_size = 4)
  • Flatten( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 1, activation = 'relu')
  • Reshape([1,-1])
Long Short-Term Memory (LSTM) Architecture:
  • LSTM(units = 32, activation = 'relu', return_sequences = True)
  • BatchNormalization( )
  • LSTM(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 32, activation = 'relu')
  • BatchNormalization( )
  • Dense(units = 1, activation = 'relu')

Experimental Results:
We trained and tested our deep learning models on a dataset of historical stock prices from various publicly traded companies. The models were trained using a variety of hyperparameter values, and the results were evaluated using various metrics, such as accuracy and mean squared error.

Overall, we found that the LSTM network performed the best, achieving an accuracy of around 85% on the test set. The FCNN and CNN models also performed well, with accuracies of around 80%. However, the LSTM network had the lowest mean squared error, indicating that it made the most accurate predictions.

We also experimented with different window sizes for the input data, as well as different numbers of layers and neurons in the networks. We found that larger window sizes and more layers and neurons generally led to better performance, but this came at the cost of increased training time and the risk of overfitting.

Conclusion:
By using deep learning, we can create a program that can accurately predict the movement of stock prices, potentially helping traders make profitable investment decisions. While predicting stock prices is a complex task, the ability of deep learning models to parse out patterns in noisy and random data makes them well-suited for the task. We will be experimenting with FCNNs, CNNs, and LSTM networks to see which performs the best on our stock data. By carefully tuning these models and utilizing the right architecture, we hope to maximize the performance of our deep learning program and aid stock traders in their endeavors.

Future Work:
There are a few areas that we plan to explore in the future to further improve the performance of our deep learning program. One approach is to incorporate additional data sources, such as news articles or social media posts, that may provide insight into market trends. We also plan to investigate the use of more advanced deep learning architectures, such as transformers, to see if they can further improve the accuracy of our predictions. Finally, we will be experimenting with different evaluation metrics, such as Sharpe ratio, to more accurately measure the performance of our program.

Overall, we are excited about the potential of deep learning to transform the world of stock trading and help traders make more informed decisions. By continuing to research and improve upon our deep learning models, we hope to make a positive impact on the world of finance.
0 Comments



Leave a Reply.

    Author

    Welcome to Matthew Lohens' blog! Dive into a world where electrical engineering, renewable energy, and cutting-edge Machine Learning converge. As a fervent advocate for innovation and sustainability in the field, I share insights, trends, and my own journey through the complex landscape of today's engineering challenges. Holding a Bachelor of Science in Electrical Engineering from the University of Utah, my academic path led me to specialize further, earning a Master's degree with a focus on Artificial Intelligence and Machine Learning, predominantly within the realms of electrical engineering. My coursework, rich in machine learning applications, has paved the way for my current pursuit of a PhD in Electrical Engineering, where I am delving deep into the synergies between Machine Learning and Power systems. As a licensed professional engineer in Oregon, Arizona, Utah, Illinois, Hawaii, South Carolina, Kentucky, Montana, Pennsylvania, Colorado, and California, I bring a wealth of knowledge and practical expertise to the table. This diverse licensure enables me to serve a broad clientele, offering tailored solutions that meet specific project requirements and standards across a wide geographic spectrum. My commitment to this blog is to not only share my professional experiences and the knowledge I've gained through my educational endeavors but also to discuss the latest trends and technological advancements in electrical engineering and renewable energy. Whether you're a fellow engineer, a student, or simply someone interested in the future of energy and technology, join me as we explore the fascinating world of electrical engineering together. Stay tuned for regular updates on my work, thoughts on the evolving landscape of electrical engineering, and insights into how machine learning is revolutionizing our approach to energy and power systems.

    View my profile on LinkedIn

    Archives

    February 2023
    January 2023

    Categories

    All

    RSS Feed

​Phone: (847) 715-6067
​Email: [email protected]
Business Address: 
​
50 W Broadway Ste 333
PMB 603014
Salt Lake City, Utah 84101-2027 US
Privacy Policy
  • Home
  • Services
    • Electrical Engineering Services
    • Electrical Design Services
    • Electrical PE Stamping Services
    • Emergency Engineering Assistance Services
  • Highlighted Projects
  • About
    • FAQ
  • Contact
  • Blog