Creating your first portfolio
Now let’s start by setting up some basic classes to capture and store information about portfolios:
class Portfolio: def __init__(self, name, riskBucket, expectedReturn=0, expectedRisk=0): self.name = name self.riskBucket = riskBucket self.allocations = [] self.expectedReturn = expectedReturn self.expectedRisk = expectedRisk class Allocation: def __init__(self, ticker, percentage): self.ticker = ticker self.percentage = percentage
In this example implementation, we’ve stored key MPT properties in expectedReturn
and expectedRisk
. Additionally, we’ve added the riskBucket
property to capture some information about the relative level of risk between our different portfolios. Finally, we added a list of objects belonging...