Skip to content

pladams777/stock_analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

An Improvement on the Analysis of Green Stocks

Refactoring code used to analyze stock performance over a given year.

Project Overview

With this project we took code that was written in prior lessons and refactored it to improve efficiency. The purpose of both the original and refactored code is to analyze stocks, specifically green energy stocks. The dataset used contains daily trading information for 12 green energy stocks in two given years. The intention by refactoring the existing code is to create a subroutine that will efficiently analyze a much larger number of stocks, potentially the entire stock market over the last few years.

Results

The original code was written to analyze 12 specific stocks. There are 252 trading days per year which multiplied by 12 stocks left us with over 3000 rows of data. The original code cycled through the entire dataset over and over for each different stock.

In an attempt to improve efficiency, we refactored the code to only have to cycle through the data one time by utilizing multiple arrays. The hope is that with improved speed and efficiency, the refactored code will be able to analyze a much larger dataset in a reasonable amount of time.

The refactored code reduced the run-time of the original code by more than 80%.

Times for given year using Original Code:

green_stocks_2017,green_stocks_2018

Times for given year using Refactored Code:

VBA_Challenge_2017,VBA_Challenge_2018

Summary

There can be both Pros and Cons to refactoring code. One advantage can be efficiency as shown in our example. Refactoring can often lead to faster running code that takes up less machine resources. Disadvantages can be that doing so may exceed a given budget or time limit to create a certain project.

When refactoring the original Stock analysis code, the biggest disadvantage was time: the time it took to rebuild and debug the refactored code. But this was definitely outweighed by the advantage of a more efficient code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published