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

Outdated.

3 responses

@Karl, your habit of deleting posts is becoming to be annoying. It muddles the exchange of thoughts and ideas and unfair to those reading and learning from them. Although you can say that it is done with good intentions so as not to taint the the Quantopian Tutorial with our personal exchanges, I would have accepted that provided that you repost all our discussions here. But for whatever reasons, you didn't and I thought you were my downunder buddy :( But I anticipated that you will do this, so I saved it and here is it for the community's reading pleasure , in its entirety, raw and uncut:

@Karl, the algorithm score is not quite the same as Information Ratio because algorithm score only computes the standard deviation (volatility) of the algo returns as opposed to IR's which is standard deviation of [Rp - Rb] aka "Active Returns". Below is contest scoring code:

def volatility_adjusted_daily_return(trailing_returns):
"""
Normalize the last daily return in trailing_returns by the annualized
volatility of trailing_returns.
"""
todays_return = trailing_returns[-1]
# Volatility is floored at 2%.
volatility = max(ep.annual_volatility(trailing_returns), 0.02)
score = (todays_return / volatility)
return score
def compute_score(returns):
"""
Compute the score of a backtest from its returns.
"""
result = []
cumulative_score = 0
count = 0
daily_scores = returns.rolling(63).apply(volatility_adjusted_daily_return)
cumulative_score = np.cumsum(daily_scores[504:])
latest_score = cumulative_score[-1]
print ''
print 'Score computed between %s and %s.' % (cumulative_score.index[0].date(), daily_scores.index[-1].date())
plt.plot(cumulative_score)
plt.title('Out-of-Sample Score Over Time')
print 'Cumulative Score: %f' % latest_score
Karl 1 hour ago
What we understand:
returns = benchmark, beta = 1
returns != benchmark, beta → 0

As compared to:
Active Returns = E[Rp - Rb] :: portfolio returns in excess of market ie. due to manager's skill to value add
Information Ratio = E[Rp - Rb] / √var[Rp - Rb] :: portfolio active_returns / std(active_returns)

excess_returns = algo_returns - spy_returns :: algo returns above the benchmark ie. attributable to algorithm's alpha
Score = (todays_return / volatility) :: excess_returns / std(excess_returns)

Postulate as beta → 0
todays_return is in effect excess_returns so then Score is a measure similar to IR

Humour me.

James Villa 1 hour ago Edit Delete
@Karl, love to humor you, again. In your equation above:

excess_returns = algo_returns - spy_returns :: algo returns above the benchmark ie. attributable to algorithm's alpha
Score = (todays_return / volatility) :: excess_returns / std(excess_returns)

Where do you see this implementation the subtraction of SPY returns to algo returns and the subtraction of SPY volatility to algo volatility in actual code of score below?

def volatility_adjusted_daily_return(trailing_returns):
""" Normalize the last daily return in trailing_returns by the annualized
volatility of trailing_returns.
""" todays_return = trailing_returns[-1]

Volatility is floored at 2%.

volatility = max(ep.annual_volatility(trailing_returns), 0.02)
score = (todays_return / volatility)
return score

It does not compute excess returns, only algo returns and (are you laughing now?)
it does compute excess volatility, only algo volatility to conform to IR. Do you get it now?

Karl 58 minutes ago
Let's ask simply:
How do we characterise the Returns as Beta-to-SPY gets to zero?

James Villa 43 minutes ago Edit Delete
Quite simply Karl, and just quote Investopedia:

What is a 'Zero-Beta Portfolio'
A zero-beta portfolio is a portfolio constructed to have zero systematic risk or, in other words, a beta of zero. A zero-beta portfolio would have the same expected return as the risk-free rate. Such a portfolio would have zero correlation with market movements, given that its expected return equals the risk-free rate or a relatively low rate of return compared to higher-beta portfolios.

Read more: Zero-Beta Portfolio https://www.investopedia.com/terms/z/zero-betaportfolio.asp#ixzz54jvu6pte
Follow us: Investopedia on Facebook

James Villa 34 minutes ago Edit Delete
And by the way Karl, I tried to give you hints in my other thread and just in case you haven't read it, here is it below and quote myself:

@Karl, "Relativity", a word made famous by Prof. Albert Einstein is the key to understanding Information Ratio in the context of market neutral strategies. What does the hedge fund industry use as benchmark for market neutral strategies? Three month US Treasury Bills (aka risk free rates) not SPY. Below I quote a Morningstar whitepaper ( http://advisor.morningstar.com/uploaded/pdf/alt_marketneutralmfcs.pdf) :

Because market-neutral funds hedge out broad
market risk, a cashlike benchmark (such as Treasury
bills) is more appropriate than a stock or bond
market index.

Karl 20 minutes ago
Not really.. let's ask more precisely:
How do we characterise the Returns in excess of SPY even as Beta-to-SPY gets to zero?

Karl 5 minutes ago
I have moved the IR discussion to a new thread, and proceeded to delete my posts above, for clarity.

James Villa 21 minutes ago Edit Delete
@Karl,

Not really.. let's ask more precisely:
How do we characterise the Returns in excess of SPY even as Beta-to-SPY gets to zero?

The Holy Grail! Have you found it, please share?

Ok then, carry on with your intelligent questions. Last we left off is me asking you if you have found the Holy Grail, Excess returns over market returns with
beta -> 0! I hope this results are in the context of market neutral strategies because I've be really amazed. I've seen market neutral strategies beat market returns for a year or two but within +-0.30 bounds of beta. Have seen the tear sheet of your algo, where I commented that I was really impressed by its returns which probably beat market returns point in time but as I recall it had a beta of 0.14 and volatility of 9.1% and daily turnover of 78.5 (did not pass contest threshold of 65%). It was also an intraday strategy to shelter you from overnight risks while collecting cash on daily basis. If you can sustain this going forward and lower beta to less than 0.05 and lower volatility to round 5%, then I'd be really impressed. But then your results might just be overfitting to the last two year's bull run. Have you tried backtesting to years 2008 and 2009 to test bear market?

@Karl,

I'm happy with Optimize API shaping a Beta 0.14 from MaxBetaExposure = 0.1 set - quite impressed actually!

With these results, you still believe and actually quite impressed that the beta constraint in Optimize API is working properly while not able to constrain it to your set MaxBetaExposure = 0.1 ? How do you explain that discrepancy of 30% (0.14-0.10 / 0.10) ex post?