Define the shared model
The schema defines nine concepts for the current portfolio, market data, scenarios, and results. This excerpt shows the declarations for the primary concepts used to optimize the portfolio.
Regime represents a market condition, such as base or crisis. Scenario
combines a budget with a regime. Stock.regime_covar records the
covariance between each pair of stocks for a regime. Stock.x_quantity
represents how much of a stock the optimizer assigns to a scenario.
FrontierPoint represents one risk and return result.
FrontierPoint.scenario links that result to its scenario.
Regime = model.Concept("Regime", identify_by={"regime_name": String})
Scenario = model.Concept("Scenario", identify_by={"name": String})Scenario.budget = model.Property(f"{Scenario} has {Float:budget}")Scenario.regime = model.Property(f"{Scenario} in {Regime}")
Stock.regime_covar = model.Property( f"{Stock} and {Stock} in {Regime} have {Float:regime_covar}")Stock.x_quantity = model.Property(f"{Stock} in {Scenario} has {Float:quantity}")
FrontierPoint = model.Concept( "FrontierPoint", identify_by={"scenario_label": String, "eps_label": String},)FrontierPoint.scenario = model.Property(f"{FrontierPoint} for {Scenario}")Regime = model.Concept("Regime", identify_by={"regime_name": String})
Scenario = model.Concept("Scenario", identify_by={"name": String})Scenario.budget = model.Property(f"{Scenario} has {Float:budget}")Scenario.regime = model.Property(f"{Scenario} in {Regime}")
Stock.regime_covar = model.Property( f"{Stock} and {Stock} in {Regime} have {Float:regime_covar}")Stock.x_quantity = model.Property(f"{Stock} in {Scenario} has {Float:quantity}")
FrontierPoint = model.Concept( "FrontierPoint", identify_by={"scenario_label": String, "eps_label": String},)FrontierPoint.scenario = model.Property(f"{FrontierPoint} for {Scenario}")