Risk analysis
Risk analysis drilldown
In order to perform risk analysis on a portfolio, we assume that we have already created a portfolio snapshot and a context. See Snapshot for more details.
For a risk drilldown of a snapshot, we need to define pivot_field and fields (also known as indicators).
Then we call the pivot_view and get_risks methods to get the risk as a pandas DataFrame.
Calling the get_risks method sends a request to the risk service to get the risk as a pandas DataFrame.
pivot_fields = ["sector", "ticker"]
fields = ["MAV", "STD", "STD%", "\\\\div(STD,MAV)", "STD.BM%"]
pivot_view = snapshot.pivot_view(context, pivot_fields)
df_risks = pivot_view.get_risks(fields)
print(df_risks)
For a full example, see example_analyze_risk.py.
Covariance analysis
For covariance analysis, we do not need a snapshot, but just context and list of tickers.
covariance_output = qcs.get_covariance(
context,
unit="LVL",
currency="EUR",
xtickers=["EQUITYEUR68", "EQUITYEUR70"],
ytickers=["EUR", "GBP", "INVALID_TICKER"],
)
df_covariance_matrix = covariance_output.covariance
df_meta = covariance_output.meta_info
See full example in example_covariance.py.