Back to Community
New Feature: before_trading_start Now Takes data Parameter

We have changed the signature of before_trading_start.

We have changed the signature of before_trading_start so that it now takes a data parameter in addition to context. Existing algorithms will continue to run, but there will be a warning asking you to add the data parameter.

You can fix the warning by changing your declaration of before_trading_start from before_trading_start(context) to before_trading_start(context, data).

Why are we making this change?
We are making this change because we are about to enter the alpha of our Modeling API. We shared our plans for this back in May, and have been steadily working on implementing it within Zipline. The API allows you to filter and rank the entire universe of securities by built-in or custom factors. Having access to data in before_trading_start will allow you to access information about your portfolio as well as any factors that you calculate.

We are very excited about the Modeling API and we are looking forward to get it into your hands as soon as possible. We are giving it to a limited number of users this week to get help with testing. We know this is an incredible tease, but we will do our best to get it out to everyone as soon as possible.

Please feel free to reach out to me if you would like to be included in the alpha.

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.

6 responses

Hi Karen,

Thanks - thanks for the feature (e.g. allow us to attach important fundamental data)!

As of this very moment, noticed using the before_trading_start(context,data) will cause error when I enter a new algorithm into the contest (i.e. the "Something went wrong and your live algorithm has stopped." message).

This is probably a temporary problem, and hope it will be fixed soon (posting here in case other quantopian runs into the same issue).

Cheers
boris

p.s. Will this feature be rolled out in time for the September contest?

Hi Boris,

That's indeed unexpected behavior. We're looking into the issue now.

-Scott

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.

Will the calculation of custom factors be limited by the 50 second time-out of before_trading_start?

Hi Boris,
I'm not able to recreate this issue. We will have someone reach out to help figure out why your contest entry isn't working.

KR

Hi folks, similar problems here.

"before_trading_start(context, data)" does not pass the syntax check when running a back test.

Also, I'm having problems with the history API. Apparently, there's no historic data available before 2010-11 (i.e. you get an empty data frame).

Alex

Any update on modeling API and dividend adjusted close prices for research?