java2509 / Stock_Analysis

Analysis of stock data using VBA and refactored code so that the script runs faster.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stock_analysis

An Analysis on Green Energy Stock.

Wall Street Picture

Stock Analysis

Overview of Project

Purpose:

Steve's parents are interested in investing in Green Energy Stock, they are looking at putting all their money in to DAQO New Energy Corp. (ticker DQ), they have not done any research on DQ and have asked Steve to help them with their decision. Steve has data for 12 Green Energy Stocks for the years 2017 and 2018. Steve is going to use this data to determine the Total Daily Volume and Yearly Return, based on this he can give his parents an informed recomendation.

Results:

Definations (referenced from Module 2.2.1)

  • Total Daily volume is sum all the total number of shares traded throughout the day in the year; it measures how actively a stock is traded.
  • Yearly return is the percentage difference in price from the beginning of the year to the end of the year.

DQ Analysis (2018):

The data from 2018 was used to determine the Total Daily volume which was almost 108M as well as the yearly return of -63%. Steve decided to do an analysis on all 12 of the stock for 2017 and 2018 since the 2018 return on DQ was so poor.

All Stock Analysis (2017-2018):

The analysis on the 2017 and 2018 yearly return shows that only EPNH and RUN performed better in 2018, all other stock had poor performanses in 2018 vs. 2017. (see screenshots for results)

All Stock Analysis (2017)

Screen Shot 2021-12-05 at 11 11 21 PM

All Stock Analysis (2018)

Screen Shot 2021-12-05 at 11 11 34 PM

Refactored Code:

Steve has determined that he could use this workbook to analyse data for future years and has asked to refactor the VBA code so that it runs faster.

The orginal code took almost 0.30 seconds to run for 2017 and 0.296 seconds for 2018. (see screenshots below)

Screen Shot 2021-12-05 at 9 41 04 PMScreen Shot 2021-12-05 at 9 42 02 PM

After the code was refactored it took 0.085 seconds to run for 2017 and .078 seconds to run for 2018.

VBA_Challenge_2017VBA_Challenge_2018

Summary:

What are the advantages or disadvantages of refactoring code?
  • Advantages of refactoring code is that it improves readability, the code is cleaner and much easier to comprehend. When working with big sets of data, you can save a considerable amount of time as the code runs faster.

  • Disadvantages of refactoring code if there is a lack of understanding of what the code does you risk creating bugs, refactoring is also very time-consuming.

How do these pros and cons apply to refactoring the original VBA script?
  • Pros: The time to run the code has decreased by almost 300%, this is useful when using this workbook to analyze massive amounts of data.

  • Cons: It was time-consuming to debug the modified code. Debugging would be challenging and time-consuming if there were thousands of lines of code.

About

Analysis of stock data using VBA and refactored code so that the script runs faster.