Coder Social home page Coder Social logo

financial-analysis-porfolio-optimization's Introduction

1__TntFs2nymL715CKoSOTAg

Portfolio Optimization of High-Value Tech Stocks

The purpose of this project is to analyze financial data, by calculating financial statistics to understand the individual performance of an asset, how groups of assets are related, and how to allocate investments across assets for optimal performance

Table of contents

Adjusted closing prices over time

Let’s first look at how the price of each stock has evolved over a year

1_cmC_lkCJ6_b00piNkrxpPw

Amazon and Google’s stock price was relatively more expensive than others. But since Apple, Microsoft and Facebook are at the bottom, it is hard to see the movement of these three.

Daily Simple Rate of return

By plotting daily returns, we can see the stock's volatility

1_wPWPTNVqREUe9VM58Wc4vQ

Netflix has the highest returns in the first quarter and a couple of negative spikes indicating negative returns. From the above plot, we can roughly see that Amazon and Netflix looks like risky stock, and Google seems to be the most stable one among them.

Correlations between stocks

It would be nice if every asset made large, consistent positive returns every period. If that were the case, we could invest all of our money in the asset with the highest expected return. But, the return of any given asset is unpredictable. This is the place where you give instructions to developers on how to modify the code.

1_rAfBUxr-0C2i0cAIZ0v7-w

We quantify the risk of a portfolio, by calculating the variance of each asset, and the covariance between each asset and every other asset.

If two assets have a positive covariance, then they respond similarly to market forces. Assets with a negative covariance will not

The Covariance Matrix above indicates, None of the stocks are negatively correlated. Apple and Google are highly correlated, while Microsoft and Amazon exhibit the lowest correlation.

MEAN-VARIANCE Portfolio Optimization

The fundamental goal of portfolio theory is to allocate investments between multiple assets optimally. Markowitz mean-variance optimization (MVO) is an approach to choose how to allocate money between multiple assets by considering the risk-return trade-off of asset combinations.

Efficient Frontier

The efficient frontier is a set of portfolios that give us the highest return for the lowest possible risk. This method returns a set of portfolios where:

  • The expected return is greater than any other with the same or lesser risk
  • The risk is less than any other with the same expected return

1_FVv86gDfn5iY-Qv5S9sToA

The blue dots above indicate a set of portfolios, Using return_portfolios() function that accepts the expected returns and covariance matrix for a collection of assets, I generated random 5000 portfolios of random asset weights.

Given that our goal is to minimize volatility and maximize expected return, the portfolios that fall on the left-most edge are the best portfolios.

1_2rkNGBxbTskhIlsABZwqUw

Summary

The yellow line is on top falls on the portfolios that maximize the expected return at all risks, and minimize the risk at all expected returns. The vertical red lines in the figure above display the standard deviation of each asset.

As you can see from the above plot, the stocks with the least risk are Google at around 0.00225 and Microsoft at around 0.00175, these stocks are optimized for historical risk and return data.

Thank you for reading!

financial-analysis-porfolio-optimization's People

Contributors

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