Code Monkey home page Code Monkey logo

portfolio-optimization's Introduction

Portfolio-Optimization

Creating a python program to optimize budget allocation for selected stocks to gain maximum return using efficient frontier method.

Deploying the module as AWS serverless API using AWS lambda and AWS API gateway. It can provide good results for more diversified portfolios or portfolios with many stocks.

Efficient Frontier

A modern portfolio theory for estimating maximmum expected return for a given risk. Instead of using formula 10000 monte carlo simulation have been caluclated for the given portfolio and the maximum expected return is calculated for a given risk using the simulations.

Assumptions

  1. All investors make decision rationally and have knowledge about all the facts of the markets
  2. The portfolio is diversified
  3. The assests follow a normal distribution
  4. The real costs like taxes, brokerage, fee, etc. are not taken into consideration while constructing the frontier.

Package Overview

test

API-Syntax

https://gqpev2z6wl.execute-api.ap-south-1.amazonaws.com/getEF?amount=<amount>&stocks=<Stock1>&stocks=<stock2>&stocks=<stockn>

API-Example

https://gqpev2z6wl.execute-api.ap-south-1.amazonaws.com/getEF?amount=10000&stocks=GOOG&stocks=AMZN

API-Output

{"symbols": ["GOOG", "AMZN"], "list": {"1": {"price": [8628.0, 1246.3], "output_stocks": [75.0, 10.0], "remaining": 125.7, "expected return": 0.256, "risk": 0.32}, "2": {"price": [9893.44, 0.0], "output_stocks": [86.0, 0.0], "remaining": 106.56, "expected return": 0.267, "risk": 0.33}}}

Challenges Faced

  1. Had trouble in using lambda layers for installing dependencies
    • Solution - Used AWS Lambda layers with proper file structure, i.e python ->site_lib->packages and installed the dependencies in a linux environment using WSL
  2. Had trouble in displaying get response in browser
    • Solution - Changed key output to body in the return response
  3. Had trouble in finding errors in the program
    • Solution - Used AWS cloudwatch and print (event) in lambda_function.py

portfolio-optimization's People

Contributors

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