Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
confusion over when can a stock be ordered?

As I understand, a stock has to be in data before an order can be placed? Is it correct that once the stock is introduced using update_universe() a further condition is that the first trade must be encountered for the stock to be added to data? Effectively, the added stock can be transacted no sooner than 1 minute after the first trade is encountered?

For a stock that has just started trading on the market, I suppose this behavior would be justified. But for a stock that has a price history, why not forward-fill from the prior day's close?

If I understand all of this correctly, the limitation seems overly restrictive and unnecessary. Perhaps Q support could explain the rationale?

Refs.:

https://www.quantopian.com/posts/security-in-history-but-not-in-data#568923bbdc3cd3346800073d
https://www.quantopian.com/posts/dealing-with-partial-fills-slash-low-liquidity-sync-async-order-modification-pains
https://www.quantopian.com/posts/thinly-traded-stocks-why-no-gaps

5 responses

Hi Grant,

You are correct in that the first trade must be encountered before a stock can be added to data. This means that a trade for this stock cannot be placed any sooner than 1 minute after this first trade.

There is no current rationale as to why this is the case. It was initially implemented this way due to technical challenges (this was before history() was around), and hasn't been improved since. We recognize that this isn't ideal and it's something that's on our list of things to improve.

I hope this answers your question.

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.

+1

It might be interesting to let us know a couple of days before this change, a bunch of people run some of their algos and store results in detail and then again after the change to see any difference. Especially for live/real then, a few might want to make an adjustment if differences are noteworthy.

By the way I think currently in the case of a scheduled market_open, if a sid doesn't trade until the 300th minute, that is considered its open, the order would be placed then (it isn't skipped just because it didn't trade on minute 1, for example that month if monthly). Pls correct me if I'm wrong.
While the code-surgeon-developers have the patient opened up, I wonder if this might not also be a good time to have backtest open orders canceled at the end of the day too, to match live. For testing, maybe track_orders() can help.

Thanks Jamie,

Is it a particularly sticky problem? Both history() and update_universe() have been around awhile, so perhaps you could elaborate on the difficultly in implementing the change?

Grant

Grant,

Our engineers are always working on improving the quality of the platform whether it be by adding new features, or improving existing ones. This particular issue hasn’t been at the top of the priority list but a solution for it is in the works. There’s no timeline on when it will be fixed but this issue will be addressed.

As I understand, a stock must be in data before its price can be found. When you specify the number of shares, directly by using order or indirectly by order_target, orders should go through. (Their execution will then wait in backtesting or paper trading until one or more trades have occurred on the exchange, because Quantopian needs a price from the market to feed to the slippage model, but that's another issue.) When the number of shares must be calculated using the price, as in all the order_*value and order_*percent functions, and stock is not in data, Quantopian throws an error ("Something went wrong").

I suspect Quantopian uses data[stock].price to find the latest price in order_*value and order_*percent, without checking if stock in data, and without falling back on history otherwise. It also does not care to recognize what "went wrong", and to report it to the user in an informative way. True?