Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
before_trading_start() - what simulation date applies for adjustments?

What if history() is called in before_trading_start()? Since it is called before the open, presumably it would not include any adjustments that would apply after the open. Or are you looking ahead to what will need to be applied after the open (split, dividend, or merger adjustments)? Or are you waiting to confirm that changes were effected once the market opens? Similarly for pipeline, fundamentals, etc. It is not specified on https://testdrive.quantopian.com/quantopian2/adjustments when the adjustments are applied to look-back windows. Are you effectively considering before_trading_start() to represent prices as they would be predicted for the upcoming day, based on planned splits, dividends, or mergers? What simulation date applies to before_trading_start()?

2 responses

In all pre-market activities (before_trading_start, pipeline, etc.), the simulation date is the date that you are preparing for, the upcoming open.

The key concept here is that splits, dividends, and mergers are applied overnight, after the market closed the previous day, and before the market is open today. Your question indicates that these events are applied before the open, and that is not correct.

Once that overnight concept is understood, the historical lookback windows are clearly explained on the adjustments page. "Price adjustments depend on three elements: the date of the price, the date that the price is being considered from, and any events (splits, dividends, and mergers) that happened between those two dates." In the case you describe, the date of the price is "yesterday." The date the price is being considered from is "today." The price is adjusted according to any events that happened in between those dates.

Your question used the word "prediction." There's no prediction in this model; there is only description of past events. The opening price is entirely unknown in pre-market activities.

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.

I think I get it. So the event (say a split) occurs after the close, but before pre-market activities the next day. So, all adjustments are made prior to the open. In the case of a split, the pre-market prices would (roughly) match those after the open. I guess the split always goes through; it's not like an accountant calls at 9:29 and says "Oops, we made a mistake...no split today." The split event is not at market open, but rather is somehow baked in ahead of time. Probably some rules, too. The CEO can't just wake up one day and decide to apply a split. So, you can make your pre-market adjustments with confidence.