Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Context score computation

I am trying to compute the contest score using the data from get_backtest().daily_performance["returns"] and the formula given in the contest rules https://www.quantopian.com/contest/rules, but there it is not specified what is meant by volatility:
Is it the a)returns volatility or the b)portfolio equity volatility?
According to my calculations the score published on the 8/2/2019 leaderboard (I think it has not been updated for few days so the could be a bug there) is not obtained from neither a) or b), but in this notebook https://www.quantopian.com/posts/contest-constraint-check-notebook-with-compact-output it is computed using a). Is there any public code with the exact calculation of the score?

By the way I don't think the function in volatility_adjusted_daily_return in that notebook is consistent with the mathematical definition give at https://www.quantopian.com/contest/rules, because it uses the annualized volatility instead of the 63 trailing volatility.

Thanks
JC

1 response

Hi,
I am surprised nobody has replied this. How can we participate to the contest if the score computation is not clear?
I have done some more checks and I can confirm the recent scores on the leaderboard are not correct. If some stuff member could confirm with few lines of code how is the score computed it would be very useful for everybody. As I already stated the contest score definition leaves some ambiguity in regard to what is meant by volatility.

This is how I compute them in research:

import numpy as np
import pandas as pd
bt = get_backtest('your backtest ID')

ret=bt.daily_performance["returns"]
cum=bt.cumulative_performance["returns"]

Nd=6 # number of days for which the score is compute

print(ret[-Nd-1:])

vol=np.maximum(ret.rolling(63).std(),0.02) # volatility of returns

vol=np.maximum(cum.rolling(63).std(),0.02) # this is for the case of computing the volatility of the portfolio equity

score=ret/vol
dict={'ret': ret , 'score': score, 'vol': vol}
df=pd.DataFrame(data=dict)
print "cumulative return : ",cum[-1],"\n", df[-Nd:]

print vol[-Nd:],"\n",ret[-Nd:],"\n", score[-Nd:],"\n", score[-Nd:].sum()

score[-Nd:].sum()