Code Monkey home page Code Monkey logo

tfsm00 / efficient-frontier-calculator Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 1.0 475 KB

A Portfolio Efficient Frontier Calculator which includes graphical visualization of Correlation, Security Market Line and Rolling Beta for U.S. Equities

Home Page: https://tfsm00-markowitz-efficient-frontier-efficient-frontier-foagx5.streamlit.app/

License: MIT License

Python 99.63% Shell 0.28% Procfile 0.09%
efficient-frontier finance python efficientfrontier efficient-frontier-calculator

efficient-frontier-calculator's Introduction

Efficient Frontier Calculator

Project Description

This is a financial data science project that allows the user to obtain a efficient frontier graph for a specific portfolio of stocks as well as other portfolio performance indicators using monthly-based price data.

It is a web-hosted interactive application, hosted using Streamlit's Sharing functionality.

The project can be found here: Link

Features

  • Correlation Matrix
  • Efficient Frontier
  • Alpha and Beta Statistics
  • Performance Indicators
    • Compound Annual Growth Rate
    • Annualized Volatility
    • Sharpe Ratio
    • Sortino Ratio
    • Calmar Ratio
    • Max Drawdown
    • Value at Risk
    • Conditional Value at Risk
  • Security Market Line
  • Rolling Beta

Usage

Ticker Input


This is where the tickers which form the portfolio are inserted. They must be space-separated, that is, a space between each ticker. Also, at least 2 tickers should be inserted. In the example below, the tickers for Apple Inc., Microsoft Corp. and International Business Machines Corp. were used.


Date Input


This is where a start and end date are to be selected. Obviously, the start date must be earlier than the end date. For a result with better accuracy, the time period should be of, at least, 1 year.



If one of the date input boxes is clicked (image above), a calendar widget will appear (image below), making it easier to select a date.



Rolling Window Slider


This a slider widget, where a month window is selected and used by the rolling beta function. The slider spans from 2 months to half the selected period of time.

Essentially, if a 6 month window is selected, a beta is calculated from month 1 to 6, from month 2 to 7, and so on until the end of the timeframe.



"Run Calculations" Button


This one is straightforward. After making sure all the other inputs explained before were used correctly, click it and wait a few seconds for the results to appear (a 5 stock and 20 year calculation takes ~15 seconds).


Facts and Assumptions

  • The most important assumption made in this project is that the Standard and Poor's 500 Index is used as market benchmark for all calculations as this project's main target are U.S. Equities.

  • The returns are obtained using Yahoo Finance's Price Data and are logarithmic, not arithmetic.

  • The risk free rate and market premiums are obtained from E. Fama and K. French's 3 Factor data and the values used are averages from the selected timeframe.

  • The efficient frontier is obtained from a Monte Carlo simulation of 5000 runs with random portfolio weights.

  • The alpha and beta statistics are obtained through a linear regression between the returns of each asset and the market.

Issues and Suggestions

If you encounter an error in the program, a way to make the code run faster, any wrong application of financial formulas and concepts or just want to make a suggestion on how to make this project better, raise a new issue here.

๐Ÿ“ Licence

Copyright ยฉ 2022 Tiago Moreira.
This project is MIT licensed.

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.