Code Monkey home page Code Monkey logo

stocks_analysis's Introduction

Stocks Analysis

Overview

Steve is a financial analyst who is seeking help to analyze stocks for his clients to determine which ones yield the greatest returns. There are 12 stocks he would like to have analyzed for the years of 2017 and 2018. The VBA code that was written for him will need to be refractored to allow for a more complex analysis that won't take a long time to run.

Results

image

The Total Daily Volume is the number of trades of the given stock for a day, over the course of a year (2017 or 2018). The Return column is the stock values at the end of the year, divided by its price at the beginning of the year,

Cells(4 + i, 3).Value = (tickerEndingPrices(i) / tickerStartingPrices(i)) - 1

showing if the stock gained value or lost value. Green signifies an increase in value, while red signifies a decrease in value. From the data, it can be determined that more stocks increased in value in 2017, with only the stock "TERP" losing value. The top stocks for 2017 were "DQ" and "SEDG". However, in 2018, most stocks lost value and are "in the red". Only "ENPH" and "RUN" gained value, with "DQ", the stock Steve's clients were originally interested in. Due to our finidings, it would be beneficial to share this information with his clients and suggest a different stock to invest in, perhaps "RUN", which is the only stock that gained value from 2017 to 2018.

The original code, consisting of nested loops, took over a second to iterate through all of the data Steve wanted analyzed. By using refactored code, the time the code ran for was cut drastically.

Instead of nested loops, an array of the stocks was created and iterated over:

image

Because the nested loops have now been replaced, these are the run times for each year:

image

Summary

Refactoring is beneficial because it cuts down on the amount of time complex chunks of code take to run. In the world of finance, and for Steve's needs, this is a great advantage. The code is also easier to read. A downside to refactoring that was encountered was that if a specific line or chunk of code needs to be removed and is not done properly, you can receive a prompt that warns the entire macro (all code) will be "reset". While this is frustrating, one remedy is to write the code in an editor, such as Visual Studio Code or Notepad, and then paste that entire code into the macro. Since writing out code beforehand is a good practice in data analytics in its own right, the benefits of refactoring still outweight the disadvantages.

stocks_analysis's People

Contributors

jennyjohnson78 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.