Skip to content

sergiocapacho/stock_analysis_vba

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

VBA Stock Analysis

Overview of the project

The purpose of this project is to analyze a variety of green energy stocks information that Steve has gather in an Excel file. He was to give is parents different options as they have decided to invest all their funds in DAQO New energy corp (DQ). With all this information analyze, Steve parents will be able to take an informed decision.

Results

Stocks

Refactored Tables

Table 2018 Table 2017

After performing the analysis between the stocks that Steve selected in accordance with his parents investment objectives there were very interesting insights that will have a determinant value to them at the time of taking any decision.

First of all, “DQ” performance during 2017 -2018 was completely different. Although in 2007 it was a return of investment of 199.4%, in 2018 lost 62.6%. Meaning that if Steves’ parents objectives are short term, it might be not the be not the best idea to invest everything in this stock. However, they can still invest a percentage of their fund in “DQ” and take advantage of the cheap price as market conditions in 2018 were not favorable.

The best stocks according to the performance were “ENPH” and “RUN”. The first one it’s been having an excellent behaviour both years, gaining more than 200% returns during these years, and its daily volume increase almost three times by 2018 meaning that has great liquidity. “Run” on the other hand has had a not so impressive performances bur it has managed to have positive ROI both years and doubling its total daily volume by 2018, this might be a sign that it’s gaining trust from the market and its a good time to invest.

Execution times

The refactored script was clearly faster than the original as execution time decreased by 0.5703125 in 2017 and by 0.5625 in 2018. (See images)

2017 Original

2017 Original

2017 Refactored

2017 Refactored

2018 Original

2018 Original

2018 Refactored

2018 Refactored

Summary

What are the advantages or disadvantages of refactoring code?

One of the main advantages of refactoring code is that it becomes easier to read. On top of that it might help to decrease the execution time as when its possible less processes will run or/and more efficient ones will be in place.

As for disadvantages, the most critical one is that it might be time-consuming. Finding the piece of code that may require change takes time, and finding the right one, written in the correct form, even more; This also brings the chance to make mistakes and ruin the whole work if changes are not done accordingly.

How do these pros and cons apply to refactoring the original VBA script?

It was challenging to understand the reasons behind the required changes and keep up with the part needed in the original refactored code. Introducing new variables and indexes became confusing with those set before, which brought mistakes while updating. On the contrary, once everything came together, the logic was more comfortable to read, follow, and understand, resulting in less execution time.

Refactoring also corrected mistakes from the original, the original tables below did not reflected the numeric results as the refactored code and the cells colours.

Original tables

2017 2018

About

Used VBA to perform stock analysis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published