Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
A few questions regarding platform

I did a fair bit of poking around in the documentation as well as googling and couldn't seem to find any answers to my questions. So here they are, hopefully someone could help clarify.

(1) How does the system handle corporate actions other than divs and splits? For example, how are spins or rights offerings accounted for?

(2) Suppose I have a large list of symbols I'd like to trade, is there any way define this large list within the platform without having to define each sid? I found this thread (https://www.quantopian.com/posts/getting-sid-programmatically) as well as went through the set_universe documentation. It's a bit unclear if that method can actually do what I want, also I couldn't seem to find any documentation on the methods for the universe class.

(3) Similar to the previous question, but is it possible to import a set of dates so I can define exclusions?

(4) I might be wrong here, but it seems like there is a liquidity constraint imposed on your trades which is fine. However, is there a way to get order acknowledgements in an event-driven fashion?

TIA

6 responses

Hello,

To answer your questions,

  1. We handle spins and you will see smooth data for the stock. We handle them in a similar way that we do splits (https://www.quantopian.com/help#overview-datasources). For an example, see this thread: https://www.quantopian.com/posts/smooth-data-for-iac. Right offerings that are corporate action splits will be in the data. I don't know enough about them to be sure we're talking about the same thing, so please ask again if its unclear.

  2. I saw that you found that past thread where it indicates how to randomize a SID. If this and set_universe() don't work for you, then you'll have to initialize your entire custom list of SIDs. However, the IDE will autocomplete by symbol so hopefully that will save you some time. In the future we'll make it so you can just supply a list of symbols.

  3. You can import a set of dates using fetcher (link) and use them as trade signals. For example, if you want to exclude market holidays, you can import a signal "is_holiday = 1" that is true on market holidays. . You'll also want to import a subsequent event where "is_holiday = 0" and its not a holiday. Values are forward-filled, so there isn't a way to import a one-day event; you need to change the signal explicitly back to the default.

  4. We have the functionality for order acknowledgements. It depends exactly on what you're trying to do. For instance, you can use the special order methods like order_target_percent() and then you don't have to worry particularly about order fills (https://www.quantopian.com/help#api-order-methods). If those special methods aren't good enough, you can track acknowledgements yourself using get_open_orders() and get_order(). The documentation has some examples on how you can track orders in your handle_data() loop.

Hopefully this is what you were looking for, and if not, I'd be happy to answer any additional questions!

Cheers,
Alisa

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.

Alisa,

Thank you for the reply.

(1) For rights offerings, does the adjustment occur post ex-eligibility date? Is the data adjusted by price/volume, cash, or increased number of shares? Suppose spot is trading under the rights offering strike, is an adjustment still made?

(4) Ok so it sounds like all orders and cancels are accepted no matter what, so there's no real need for order acks - does this sound about right? Now is there a way to get executions (also partials) asynchronously? A few of the order methods seem to return an OrderID, guess this is like a ClOrdID?

Thanks,

-A

Hi Al,

Here is the info you're looking for:

(1) Our data provides information for smoothing of stock splits/dividends, cash dividends, and spin-off details. We don't provide specific information or adjust data for rights offerings. This backtracks a bit on my above statement where I said they would be handled as splits. That was incorrect, and after some additional digging, I realized we do not support right offerings.

I'm curious, is this something that would be useful? How would you use this information (in a simple use case)?

(4) Correct me if I'm wrong, but this is how I understood your question: You place an order with a broker and you're waiting for a response ack that the order was received. This statement is correct; there is no need for order acks because Quantopian does the ack under the hood with the broker. When you place your order, we make sure that the broker gets the order.

Now if you want to know when the order gets filled, there are two ways: in the UI and in the algo. In the IB dashboard (which you can see if you're paper trading or live trading with IB) you will see a box with your positions. It will show you the securities, #shares, price, average cost, value, and unrealized amounts. If you want to monitor the order fills in your algo, you can use the get_order() call. For more details, see: https://www.quantopian.com/help#ide-ordering. You'll be able to log the order amount and see # shares filled.

Best,
Alisa

(1) Well I think it's just important to understand how the data is adjusted, for a rights offering it's a bit tricky right? Do you assume the a holder at ex-rights date will always execute (i.e. 100% participation)? It's not entirely clear, though FWIW I know BBG and TR adjust them the usual way (link).

A simple example of where spins and/or rights offerings would create an issue is suppose you're simply trying to replicate some index where you rebalance EOD. In either spin-offs or rights offering, your target allocations could be thrown off either by the spin hitting your portfolio or excess shares respectively.

(2) So ignoring broker infrastructure for a second and let's just assume DMA for simplicity. In a typical case you'll sendOrder, cancel, or cancelReplace with a clOrdId and/or order instructions. Then you should get an order ack back from the exchange specifying if your order has been accepted or rejected w/ the associated clOrdId. Now suppose you've sent an order which has been accepted, you will then receive fills until your order is fully executed each also tagged with a clOrdId.

Now let's say I get a partial fill on a given order, then would like to cancelReplace (doesn't seem like you guys support cancelReplace, so let's just say you cancel then send a new order out) that order with a new order. A few things could happen here: 1) My cancelReplace is successful, 2) I get filled on the original order before my cancelReplace is ack'd. then the cancelReplace should be rejected, and 3) there a bunch of other corner cases but let's just talk about those 2 for now.

The second case is particularly troubling, so is there a way you to receive the fills in such a way that you won't end up sending out more orders than you'd like? I can't seem to figure it out under the current methods you've provided.

Hi Al,

(1) The market data source we currently use does not provide information or adjustments for rights offerings. The minute bars will provide the open, close, high and low prices but we do not provide the number of shares outstanding, as TR does. We get our data from a vendor that receives U.S. equity data from NYSE; who then receives it from their subsidiary, SIAC. This data comes directly from the Consolidated Tape Authority (CTA), the official trading record.

(2) You are correct, we do not yet support the cancelReplace function - though its a neat tool! If you were to manually code a cancelReplace, your request will be accepted both in the backtest and in IB. If you have a partial fill when you cancel an order, you will maintain that partial position, but additional orders to fill the position will not get placed. If you want notifications of the successful cancellation and # shares on your partial position, you can input log messages in your code. This way, you won't be sending out more orders than you want and you'll always be aware of your portfolio position.

Alisa

To expand on #2:

You will need to manage the confirmed/cancelled orders. Your code logic should check that an order is successfully cancelled before placing another order, to prevent messages get crossed. We place the cancel order as fast as we can, but you would need to safeguards to prevent misbehavior.

If you don't want to track the logic yourself, you can use the order_target() function and we'll handle the process for you.

Imagine this scenario:

  • In minute 1 you place an order for 1,000 shares
  • In minute 2 you get get an update (you check the order in your code) and 50 shares are filled
  • In minute 3 you get an update (again via a check by you) and 100 more shares are filled. You issue a cancel. You order 2,000 shares at a lower price.
    • Your code should check for the successful cancellation of your first order before placing your second order
  • In minute 4, a couple things can happen based on your code logic
    • IB processes the cancel for the remaining 850 stocks and then you order 2,000 shares
    • The cancel does not get there in time and you have 850 stocks filled from your first order and your second order filled at 2,000 shares

The key distinction in minute 4 is that we can't guarantee the cancel order and prevent further fills - you will need to provide cautionary logic to be conservative with your position.