Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

Lab MST-4

Student Name: Maadhav Hira UID:22BCS10380


Branch: CSE Section/Group:602-‘B’
Semester: 4th Date of Performance: 18/04/2024
Subject Name: NM&O using python Subject Code:22CSH-259

1. Aim:

You are planning to build a portfolio of investments consisting of three assets: Asset X, AssetY,
and Asset Z. Each asset has a certain expected return and risk associated with it. You have a
total of $1,000,000 to invest. However, you also have the following constraints and Maximise
the expected return on investment while minimising the risk. • You want to invest at least
$300,000 in Asset X. • You want to invest at least $200,000 in Asset Y. • You want to invest at
least $100,000 in Asset Z. • You cannot invest more than $600,000 in Asset X. • You cannot
invest more than $400,000 in Asset Y. • You cannot invest more than $300,000 in Asset Z.
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

2. Source Code:

import pulp

prob = pulp.LpProblem("Portfolio Optimization", pulp.LpMaximize)

x = pulp.LpVariable("x", lowBound=300000, upBound=600000)


y = pulp.LpVariable("y", lowBound=200000, upBound=400000)
z = pulp.LpVariable("z", lowBound=100000, upBound=300000)

returns = {"X": 0.08, "Y": 0.1, "Z": 0.12}


risks = {"X": 0.15, "Y": 0.18, "Z": 0.2}

prob += returns["X"] * x + returns["Y"] * y + returns["Z"] * z,

prob += x + y + z == 1000000,
prob += x >= 300000,
prob += y >= 200000,
prob += z >= 100000,

prob.solve()

print("Optimal Portfolio:")
for var in prob.variables():
print(f"{var.name}: ${var.varValue:.2f}")
print(f"Total Expected Return: ${pulp.value(prob.objective):.2f}")
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

Learning Outcomes:

1. Understand the concept of portfolio optimisation in investment management.


2. Apply mathematical models to maximise the expected return on investment while
minimising risk, considering constraints such as minimum and maximum investment
amounts in different assets.
3. Analyse the trade-offs between risk and return in portfolio construction.
4. Implement portfolio optimisation techniques using tools such as Excel, Python, or
specialized software.
5. Develop strategies to construct diversified portfolios that meet specific investment
goals and constraints.

You might also like