Giter VIP home page Giter VIP logo

piero-c / robo-advisor Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 252 KB

robo-advisor is a quantitative analysis script written in Python that generates the least volatile portfolio given a list of stocks, with the goal of a 0% return.

Jupyter Notebook 96.42% Python 3.58%
capm data-analysis data-visualization matplotlib monte-carlo-simulation multithreading numpy pandas python queue recursion statistics computational-finance finance quantitative-finance

robo-advisor's Introduction

robo-advisor

Enjoy!

Authors: Piero C (Lead), Sathun Suthakaran, Ishaan Bansal

Themes: Quantitative Analysis, Computational Finance, Capital Markets

Dependencies: See imports

Runtime: ~ 1 minute

Achievements:

  1. Decreased runtime 50% by implementing multithreading, queues, and recursion to speed up requests from AlphaVantage API.

    • This project had the fastest data cleaning pipeline out of everyone who completed the same project (University class).
  2. Generated a portfolio with over 40% less volatility compared to a benchmark by using optimized algorithms to develop accurate predictions and financial analyses.

  3. Outperformed the benchmark across 100% of trials in metrics such as standard deviation and expected return through effective mathematical models and strategies, as well as optimization algorithms.

    • Includes a five-hundred thousand iteration Monte Carlo simulation that runs in as little as 15 seconds.
  4. Successfully implemented the Capital Asset Pricing Model to accurately predict portfolio expected returns.

  5. Scored extremely well when evaluated by professor James Thompson and Teaching Assistants.

Problems we Were Able to Fix / Improvements we Were Able to Make:

  1. The initial API used for this project broke.

    • Chose a new API for stock data, and developed alphawrap. Alphawrap was created such that all it took to generate the exact same data as the old API calls was a change of the stock object name.
    • The old stock objects were called 'yf.Ticker'. Once Piero developed AlphaWrap, all we had to do was CTRL+F yf.Ticker, replace with 'Stock', and everything worked as normal.
  2. Selecting a model which would be conducive to the goal of the program.

    • Collaborated to discuss important statistical measures, found a trusted pricing model that accurately implements all of them, modified it to fit our needs.
  3. General issues with CPU-bound and IO-bound tasks slowing down the program.

    • Removed redundancies and number of API requests, implemented recursive threading, simplified code, implemented Queues and efficient algorithms. (Especially exemplified in Monte Carlo simulation and data cleaning).
  4. No objectively correct way to select the tickers that would be used in the final portfolio.

    • Decided that volatility and correlation were the most important factors to consider, created the points system for selecting tickers.
  5. Requesting stock history data from AlphaVantage API in the desired format requires a lot of (repetitive) code.

    • Created alphawrap, a module which simplifies the process of performing the requests. Alphawrap also provides functions for other parts of the program (like risk-free rate, stock 'info')
  6. Trying to use just one equation to pick the best portfolio presented changes. While beta does consider both volatility and correlation, it's not a perfect measure for our use case.

    • De-coupled influencing factors by implementing a brand new weights system that took the points system into consideration.
  7. Risk-free rate data was hard-coded and not automatically updated, causing small inaccuracies in the expected return of the portfolio.

    • As part of alphawrap, created a function that collects the risk-free rate from AlphaVantage.

Problems / Improvements that Still Exist:

  1. The Monte Carlo simulation is a CPU-heavy task. Since the best_weighting function needs to generate 1 million portfolios, the computer spends most of the runtime crunching numbers. With this being said, multiprocessing may have been preferred for our simulation. Unfortunately, we decided that multiprocessing was beyond our scope of expertise.

  2. Small optimizations could be made to improve the runtime of the program. For example, re-using stock price information to limit the number of API calls.

  3. AlphaVantage can be inconsistent. This means we have to run the API calls at a slower speed than would be optimal.

robo-advisor's People

Contributors

piero-c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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