Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
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...
(I have other questions/concerns about going live, but I will probably ask those in another thread)

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

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.