Hi Q,
Is this strategy worth investing? If yes, what is the process to get it funded?
Best regards,
Pravin
Hi Q,
Is this strategy worth investing? If yes, what is the process to get it funded?
Best regards,
Pravin
No b/c leverage so high means the great looking curve is an illusion. Return on the amount spent is 59%, lower than the benchmark.
This is a minimal version for keeping an eye on PvR that will usually work by just pasting this at the end of initialize() [or depending on how ordering is being done, sometimes you might need to call info() more often, like from from handle_data()]
schedule_function(info, time_rules.market_close())
def info(context, data):
c = context # For brevity
shorts = 0 # Shorts value
for p in c.portfolio.positions: # Total up shorting, because it is risk
shrs = c.portfolio.positions[p].amount
if shrs < 0:
shorts += int(abs(shrs * data[p].price))
if 'risk_hi' not in c: c.risk_hi = 0 # Init this in initialize for better efficiency
cash_dip = int(max(0, c.portfolio.starting_cash - c.portfolio.cash)) # all of these as positives
risk = int(max(cash_dip, shorts))
c.risk_hi = max(risk, c.risk_hi)
# Profit_vs_Risk returns based on max amount actually put into play (risk high)
if c.risk_hi != 0: # Avoid zero-divide
pvr_rtrn = 100 * (c.portfolio.portfolio_value - c.portfolio.starting_cash) / c.risk_hi
record(PvR = pvr_rtrn) # Profit_vs_Risk returns
If the performance holds up using a dynamic universe, it might be on to something? Backtests with fixed lists of assets, if they aren't an unbiased set of ETFs (like all the sector ETFs, or all the country ETFs) make me pretty skeptical. But I am not Quantopian!
@James Miller, since the algo longs stocks and shorts SPY, you might want to try and pick winning stocks from dynamic universe. Alternatively you could remove the bounds in minimize method to find a long short portfolio.
Best regards,
Pravin
I changed James' version slightly: