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

I'm new to Python and Quantopian. I am currently manually trading a stock on Robinhood and would like to automate the process as my first project. The stock is range-bound between $0.12 and $0.19. I would like to pick it up between $.12 and $.14 (up to 50% of the portfolio) and sell between $.15 and $.19. (up to 100% of the portfolio) I would like to place limit orders in 100 share blocks.

4 responses

Hey Scott. This algo should do what you want, except it orders as a percentage of your portfolio all at once, instead of in 100 share blocks. Just replace the symbol of the pink sheet stock I used with the one you are trying to test.

Rookie mistake, that buys short to the tune of $1.67M, Robinhood doesn't even allow it yet. Also a limit order in this case (sell) is not equal to simply selling and allowing selling short as the code does, it is selling (in this case 100 shares at a time) as the price reaches certain points (the limit) on upward movement.

Searches for "limit order" ...

Using Quantopian's in-house search specifying threads with backtests:
https://www.quantopian.com/posts/search?q=%22limit%20order%22&attachment=backtests

Google, past year, attempting to find those with backtests, and you can also sort these by date:
https://www.google.com/search?q=%22limit+order%22+%22def+handle_data%22+site%3Aquantopian.com&tbs=qdr:y
Crud, that's a Google bug, you may need to click on 'Search Tools', and then you should see the dropdown for sorting.

Frank, thank you for the input.

I'm new to all of this and come from a finance background so my quantopian and python game is weak - I truly appreciate everyone's input!

As Garyha indicated, I'm not able to go short in Robinhood; it's long-only and I have no ability to use leverage.

I want to execute the order in 100 share blocks instead of percent terms. This leads me to a few other questions:

  • Am I able to buy/sell 100 shares at a time?
  • Is it possible to scale into the position so I don't blow my wad in one trade if more volume follows the first 10% block? (e.g. 10% of the portfolio @ $.14, 20% @ $.13, and 40% @ $.12)

How would I account for unsettled funds given robinhood doesn't offer margin and is subject to the T+3 rule?

Is there any other code that I need to incorporate to live trade through Robinhood?

Thanks,

Scott

Hi scott,

There's a nice framework that we included in the docs. Some of it is meant to simulate Robinhood behavior in the backtester and some of it is meant to be used for managing the T+3 rules, check it out: https://www.quantopian.com/help/#sample-robinhood

Thanks
Josh

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.