Giter VIP home page Giter VIP logo

capym's Introduction

CAPyM

These are some codes related to CAPM and portfolio management with Python. In the next lines I expect to explain the basics about CAPM, Beta, and some of the tools used to calculate it in Python, but I strongly recommend a review of the references at the end of this doc.

Capital Asset Pricing Model

According to Wikipedia, CAPM is a model used to determine the appropriate rate of return of an asset, and it can be helpful when building a diversified portfolio. It can be expressed by:

CAPM Formula

Where the Beta represents the sensitivity of an asset in comparison with a benchmark:

Beta Formula

Python Libraries

The notebooks in this repository will rely on yfinance to import data from yahoo finance directly into the code, pandas will be used for data wrangling, matplotlib will be preferred for visualization, and stats module from SciPy will be the source of the statistical functions.

import yfinance as yf
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats

Calculating the beta

As a first effort, two Brazilian companies were selected and compared to the iBovespa benchmark to find the beta: Petrobras and Itaú. Some graphs were built as well to assist the visualization.

1. Calculating the Beta - Petrobras & Itaú

and a simpler example was made for American companies.

2. Calculating the Beta - Netflix & Amazon

(...)


Please drop me a note with feedback, contribute to this repository and/or send me a message on LinkedIn.

Arthur Bretas

capym's People

Contributors

bretasarthur avatar

Stargazers

 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.