This might turn out to be a dumb question, but I was wondering if there's a simple way to simulate the functionality provided by Quantopian's Pipeline API within the QuantConnect framework? For anyone who isn't familiar, Quantopian provides the following generalized description in their documentation of what Pipeline does:
- For each asset in a known (large) universe, compute N scalar values for the asset based on a trailing window of data.
- Select a smaller “tradeable universe” of assets based on the values computed in (1).
- Calculate desired portfolio weights on the trading universe computed in (2).
- Place orders to move the algorithm’s current portfolio allocations to the desired weights computed in (3).
I've been attempting to do something like this in QuantConnect by calling History while simultaneously using Coarse Universe Selection, but haven't had much success thus far.
Jared Broad
Of course, anything they can do, we can do better ;) Check out this example algorithm in Github.
AddUniverse(coarse => { return (from cf in coarse // grab the SelectionData instance for this symbol let avg = _averages.GetOrAdd(cf.Symbol, sym => new SelectionData()) // Update returns true when the indicators are ready, so don't accept until they are where avg.Update(cf.EndTime, cf.Price) // only pick symbols who have their 50 day ema over their 100 day ema where avg.Fast > avg.Slow*(1 + Tolerance) // prefer symbols with a larger delta by percentage between the two averages orderby avg.ScaledDelta descending // we only need to return the symbol and return 'Count' symbols select cf.Symbol).Take(Count); });
This will give you the output of 1) from here you can calculate your weights and use SetHoldings() to purchase the allocations you need.
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Gisli
Hi,
I'm new here on QuantConnect and had a very similar question as Brendan.
In the example above the univeres selection and alpha signal generation are bundled into one step. What is the best way to do the following (say, every day/Monday/month etc.)
To my understanding (1) would be covered in the example above. The question on how to request historical data for each security in the unverse (and even grab the select symbols) and how to schedule this analysis. I'm still trying to figure out (find good examples) of how to use the UniverseManager/History functionality optimally.
Any suggestions much appreciated.
Gisli
actually found https://www.quantconnect.com/forum/discussion/1251/scan-nasdaq/p1 which is helpful.
Brendan Driscoll
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!