Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Newbie: Accessing Risk Metrics in zipline

Greetings all. First off, congrats on such a great project.

I've followed the published examples and have printed out the various results from the TradingAlgorithm class. I am trying to access the risk metrics computed in RiskMetricsBase however, and am struggling.

I have seen banter about including the risk metrics in the results data dump, but how would one access these metrics in the meantime? I have received several different errors I can post if warranted. Hopefully there is a simple example someone can lead me to.

1 response
>>> from zipline.finance import trading  
>>> from zipline.finance import risk  
>>> from zipline.utils.factory import create_returns_from_list  
>>> start = pd.datetime(2010, 01, 01, tzinfo=pytz.UTC)  
>>> end = pd.datetime(2012, 01, 01, tzinfo=pytz.UTC)  
>>> env = trading.SimulationParameters(start, end)  
>>> returns_risk = create_returns_from_list(results.returns, env)  
>>> my_risk = risk.RiskMetricsBase(start, end, returns_risk)  
>>> my_risk