Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Passing Factor data from pipeline into TradingAlogrithm?

In a separate thread @Mathew Lee mentioned:

we don't yet support Pipeline for zipline algos in the research
environment. So - any algorithm that attaches a pipeline to a
TradingAlgorithm won't work in research. You should stick to
backtesting in the IDE for this one.

I have a pipeline which consistently times out on long runs in the backtester however it works in the notebook. So I'd like to use zipline in the research environment to generate my backtest. Unfortunately it doesn't appear that attaching a pipeline is supported in the notebook environment. But I assume I should be able to merge my pipeline output with price data and pass that to my TradingAlgorithm. I'm a bit confused on how one would go about that though.

The pricing data fed to the TradingAlgorithm looks like:

'                         ', 'Equity(2 [ARNC])', 'Equity(24 [AAPL])', 'etc...'
'2016-03-07 00:00:00+00:00',           '28.587',           '100.270', 'etc...'
'2016-03-08 00:00:00+00:00',           '28.912',            '98.694', 'etc...'

However the factor data from the pipeline output is in the form:

'                         ', '                      ', 'Factor_1', 'Factor_2', 'etc...'
'2016-03-07 00:00:00+00:00',       'Equity(2 [ARNC])',       '12',       '0.5, 'etc...'
                                  'Equity(24 [AAPL])',       '10',       '0.2, 'etc...'  
'2016-03-08 00:00:00+00:00',       'Equity(2 [ARNC])',        '5',       '0.7, 'etc...'
                                  'Equity(24 [AAPL])',       '10',       '0.2, 'etc...'

What is the recommend method to incorporate factors generated with pipeline into TradingAlgorithm?

How do I combine these two datasets so that they will work with the TradingAlgorithm class? Or is there, currently, a way to attach a pipeline and have it processed by TradingAlgorithm?

5 responses

Does your pipeline use fundamentals data? We recently launched a faster version of Pipeline fundamental data and I'm wondering if that will solve your problem.

I don't yet know the answer to your direct question of formatting pipeline output data to use as input to TradingAlgorithm. If the faster fundamentals don't help, let me know and I can try to get you an answer.

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'm not sure if I understand what you're referring to regarding fundamentals data. I'm using the modules:

quantopian.pipeline.data.morningstar  
quantopian.pipeline.data.psychsignal  
quantopian.pipeline.data.builtin  

Is this what you mean?

Sorry, I forgot to paste the link. This is what I mean: https://www.quantopian.com/posts/faster-fundamental-data.

We just launched a new implementation of fundamental data in Pipeline which is faster than the old system. The old version was accessed with quantopian.pipeline.data.morningstar while the new way is accessed via quantopian.pipeline.data.Fundamentals. The details are in the linked post. Let me know if this helps.

That may have sped the backtest up a bit for me but, unfortunately, perhaps due to the other data sources, the pipeline still times out. I think I still need to figure out a way to use the factors generated from pipeline within TradingAlgorithm.

Just for anyone following this or having similar issues, this is what I received from Q support...

Unfortunately, TraderAlgorithm.run cannot take data extracted from a
pipeline. As noted in your community post, attaching a pipeline to a
zipline algorithm is also not supported by the Research environment.

I hope, in the future, we'll be able to attach pipeline and work with TradingAlgorithm in the notebook to better replicate what happens in the IDE.