Can we have different resolution for universe resolution? like 4 hour 2 hour

At the moment, there are daily and hour avaiable, how to create different resolution. Thank you


public override void Initialize()
            UniverseSettings.Leverage = 2.0m;
            UniverseSettings.Resolution = Resolution.Hour;

Update Backtest

Hi there,

I have the same issue than OuYangFeng, I would like to have a different resolution: 1 year in my case. After looking into the code, it does not seem to be possible to override the resolution easily since it is an enumeration and it is a parameter of the AddSecurity method...

That would be really nice to be able to customize the resolution and define it with more granularity.


The data in universe selection (coarse universe and fine universe) are in daily resolution. Therefore, when you use 

AddUniverse(CoarseSelectionFunction, FineSelectionFunction);,

 CoarseSelectionFunction and  FineSelectionFunction are set to default to run once a day (Running them on a lower resolution wouldn't change the filter result as the price, volume data in CoarseSelectionFunction and fundamental factor data in FineSelectionFunction are all daily data). After the universe selection, The data of symbols returned by FineSelectionFunction or CoarseSelectionFunction will be subscribed in OnData() based on the UniverseSettings

UniverseSettings.Resolution = Resolution.Hour;

That is to say, you can not use the price data of lower resolution than daily to filter stocks in universe selection but you can use the lower resolution to further screen stocks from the results returned by universe selection in OnData(). 

A reasonable way to use universe selection API would be trimming the result set down using coarse selection and using the hourly/minute price data in OnData(). You should be wary of large requests though, once you get over about 120K data points you'll run into timeout issues. 

For higher resolution universe selection like monthly, quarterly or yearly, it would be easy to use the scheduled event API to run universe selection. Here is an example

Thanks a lot, this is really helpful. I ended up using a similar implementation but I made a few mistakes.

I used the `OnSecuritiesChanged` method to have the delta (so I can know which stocks I should buy/sell) but it does not work well in this case. When the universe returns a different list of symbols `OnSecuritiesChanged` tries to remove the stocks I am invested in. I attached an example, the docs go quickly over this aspect. Basically, it is going to buy my stocks the first day and liquidate them the 2nd day because the new list is empty.

So it seems like `OnSecuritiesChanged` has been designed and should be used only when the user wants to trade at the same resolution than the universe.

Also when making this example, I noticed something a bit odd, AAPL works great but VZ ends up with a different symbol (BEL) in the logs when buying and selling. Not sure why.


The 2nd issue I have is when the universe refreshes, markets seem to be closed (at 12AM). So the orders end up being MarketOnOpen orders. In this case, I try to allocate all the portfolio's money, so I divide my cash by a number of positions. Now correct me if I am wrong: the positions sometimes fail because the number of shares is calculated according to the price of the stock when the universe selection was done. However the price when the market opens will likely be different. So if the price goes up too much I don't have enough money to buy the number of shares calculated the day before.

Not sure how to solve this issue.


Hope this helps.


 "OnSecuritiesChanged" reflects the added and removed symbols from the coarse and fine universe selection. As coarse and fine universe selection are set to run on the daily basis by default, the added symbols in "OnSecuritiesChanged" are symbols returned by the fine selection. The removed symbols are symbols returned by the fine selection in the previous day but not selected in today's fine list.  Data for "changes.RemovedSecurities" will be unsubscribed and "changes.RemovedSecurities" will be subscribed in the OnData().

"Debug(security.Symbol)" prints the string of the symbol object. To get the string ticker, you should use "Debug(security.Symbol.Value)".

To avoid such invalid orders, you can save the added and removed securities and move the SetHoldings() to OnData() and avoid placing orders at 00:00 (if Time.Hour !=0 && Time.Minute != 0) or you can set a higher leverage to allow more margin available.


Update Backtest


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.


This discussion is closed