I would really like to not invest 25% of $25,000 at my first live algo attempt! Limiting account percentage with Robinhood Template Algo The Robinhood algo, here: https://www.quantopian.com/posts/robinhood-live-trading-update-stop-waiting-3-days-with-robinhood-instant , uses this,  # We will weight each asset equally and leave a 5% cash reserve. context.weight = 0.95 / len(context.assets)  to equally distribute funds throughout the list of assets in our context. I would like to make this work with a Large cash reserve and a Small investment to limit my risk. I've set the account starting amount at$26,000 and changed the context.weight = .038 to invest ~$1,000 of my cash. However, this results in having 0% returns throughout. I've also played with this and it seems like the magic number is around .25; so when I set context.weight = .25 , then I get returns, BUT not at .2 Does anyone know what is going on here? I would really like to not invest 25% of$25,000 at my first live algo attempt! hah...

Any ideas or workarounds are appreciated.

3 responses

The culprit is in the 'order_for_robinhood' method. There is a check to see if the amount to order is within 1% of the target. Since you start with such a small amount this check fails. It's commented out in the attached algorithm. There may be other issues but that one was the first I found.

    if abs(percent_to_order) < .01:
return


2
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
 Returns 1 Month 3 Month 6 Month 12 Month
 Alpha 1 Month 3 Month 6 Month 12 Month
 Beta 1 Month 3 Month 6 Month 12 Month
 Sharpe 1 Month 3 Month 6 Month 12 Month
 Sortino 1 Month 3 Month 6 Month 12 Month
 Volatility 1 Month 3 Month 6 Month 12 Month
 Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 58b1e24d4551215e41ba330c
There was a runtime error.

It's possible that your orders are being rounded down. You can't buy partial shares so for example, if you had $100 and wanted to use 1% of that to buy$100/share, you'll order nothing! I would advise to make an order function that manually targets a certain amount of shares instead of a target percent.

Okay. Thank you both. I'll look into those and see if it helps.