Coder Social home page Coder Social logo

portfolio-optimization's Introduction

Portfolio Optimization with Mean-Variance Analysis

This project demonstrates portfolio optimization using Mean-Variance Analysis. It utilizes financial data fetched from Yahoo Finance using the pandas_datareader library and optimizes portfolio weights to achieve desired returns while minimizing risk.

Overview

This script fetches financial data for a list of assets (e.g., stocks) from Yahoo Finance, calculates their historical returns and volatility, and performs various portfolio optimization tasks using Mean-Variance Analysis. The goal is to find optimal asset allocations that maximize returns given a certain level of risk or minimize risk for a given expected return.

Features

  • Fetches financial data from Yahoo Finance for specified assets.
  • Calculates historical returns and volatility for each asset.
  • Visualizes the relationship between returns and volatility of the assets.
  • Performs portfolio optimization to find the optimal asset allocation for maximum return or minimum risk.
  • Plots random portfolios and portfolios with target returns on a risk-return graph.

Installation

  1. Clone this repository to your local machine:

    git clone https://github.com/Agu-Ribo/Portfolio-Optimization.git
    
  2. Navigate to the project directory:

    cd Optimizacion de Portfolio.py
    
  3. Install the required Python packages:

    pip install numpy matplotlib pandas pandas_datareader cvxopt pypfopt
    

Usage

  1. Open the portfolio_optimization.py script in your preferred Python IDE or editor.
  2. Modify the tickers list to include the symbols of the assets you want to analyze.
  3. Adjust the start and end dates in the pdr.get_data_yahoo function to specify the data retrieval period.
  4. Run the script. It will display visualizations of asset returns, volatility, and portfolio optimization results.

Configuration

No additional configuration is required for this script. However, you can explore the code to adjust parameters related to portfolio optimization, such as the number of random portfolios to generate or the target returns.

Contributing

Contributions to this project are welcome! If you have ideas for improvements or bug fixes, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License.

portfolio-optimization's People

Contributors

agu-ribo 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.