Giter VIP home page Giter VIP logo

stock-analysis's Introduction

Stock-analysis

##Overview

Stock data was pulled for 2017 and 2018 and a macro was created to pull information for each stocks total volume, start and end prices, and returns. The code ran in .87 seconds. For larger projects with mass stocks over many years, this would take a fair amount of time. Thus the code needed to be refactored to be more effecient. Microsoft VBA was used in order to accomplish this task.


##Results To achieve a quicker run time the existing code was editted to make the process of iterating through stocks more streamlined. variables were vreated for the ticker volume, start, and end prices. The tickers for stocks were iterated over, pulling values for each of the variables declared. The start and end prices were then used to calculate the return of each stock and output to the excel sheet. For easy and clear visualization of the returns, formatting was done to color code positive and negitive returns and format the chart headers. The original code ran in 0.847 seconds.

Code_Run_Time_Original_Module_Code

Once the code was refactored it ran in 0.765 seconds. Refactored_code_run_time From this we can see an improvement in time, saving 0.082 seconds per run. Improvements were made to iterating through the stock tickers, as this is where the majority of refactoring was done. The updated code is as follows: Refactored_Code Refactored_Code_2 Refactored_Code_3


##Summary When refactoring code, the main advantage is having quicker run times as code is made to be more efficient and streamlined. This allows code to be used with larger files as the code can quickly work through great amounts of data. A disadvantage is that it could lead to error or bugs while editing old code that may be avoided by starting fresh. This can be avoided with careful commenting and organization to assist in avoiding errors. The original VBA script was slower, and would not perform well with a larger data file of thousands of stocks, but handles well with the small file it was originally created for. The refactored code is faster, but it took a significant amount of time to create.

##Challenges I encountered many challenge throughout the refactoring process. I tried to get help in office hours, tutoring, and through askBCS and continued to get compile errors with my variables, especially when using tickerIndex. So, I ended up commenting the tickerIndex out or removing it later in the code because after hours of working with it I still could not get it to successfully run. My code still ended up being faster than the orignal, so I got to the goal through a different path.

##Contact Me

Email: [email protected]
LinkedIn

stock-analysis's People

Contributors

shumph10 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.