Back

Universe Selection

Hey guys,

Does anyone know if there is a way to set the time when your algo's Universe is updated? For example, if I wanted to update my universe right before market open, instead of at midnight.
Update Backtest








This is possible by defining your own universe object. I'm curious what kind of universe you're using. Is this a data-driven universe, such as coarse, or is this a 'user-defined-universe', such as calling a web service to get the tickers for the day. Here's an example of a custom universe object that will fire 10 minutes before us-equity market open each day. He only returns SPY as being in the universe, but you can replace the selection logic with your own web service call. If you have a custom data source or are using coarse, let me know and I can whip together an example for those too!
0

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.


Thanks Michael! I'm using a user defined universe imported via dropbox, so this is perfect!
0

Hey Micheal
Can please you show me an example of how to use a user defined universe with a custom data source?
https://www.dropbox.com/s/qx8hs2q81im9zmu/SymbolToday.csv?dl=1
Thanks so much

0

@Travis - please check out this Github example:
https://github.com/QuantConnect/Lean/blob/master/Algorithm.CSharp/CustomDataUniverseAlgorithm.cs

0

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.


@Jared
Thank you, I've used that example and got it to work with my custom data. Now I'm trying to get the algorithm to read from my data source five minutes after the market opens, add and then buy the symbol. I Noticed that the example above has AddUniverse(new PreMarketDailyUsEquityUniverse(UniverseSettings, TimeSpan.FromMinutes(10), dateTime =
{

but that doesn't work either...

0

When you say it 'doesn't work', do you mean it doesn't compile? If so, make sure you copy the PreMarketDailyUsEquityUniverse class from the sample since it's not provided as part of the base engine.

If the issue is something different, please attach a sample project and I'll take a look at it.

0

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.


I added all of the code from your example to try and pre-charge the algorithm but I wasn't adding a subscription on initialize. I appreciate the help.

0

@MichaelH,

Do you happen to have or know of an example of executing coarse universe selection at a custom specified time or on initialization? Is this even possible?

0

I should be grateful if someone would provide me with the necessary changes to fix the following two errors in the above algo:

Build Error: File: Main.cs Line:71 Column:14 - 'UserDefinedUniverse' does not contain a constructor that takes 4 arguments

  Lines 70 & 71 are:

public PreMarketDailyUsEquityUniverse(UniverseSettings universeSettings, TimeSpan timeBeforeMarketOpen, Func<DateTime, IEnumerable<string>> selector)
: base(CreateConfiguration(), universeSettings, TimeSpan.MaxValue, selector)

Build Error: File: Main.cs Line:80 Column:74 - The call is ambiguous between the following methods or properties: 'MarketHoursDatabase.GetEntry(string, string, SecurityType)' and 'MarketHoursDatabase.GetEntry(string, Symbol, SecurityType)'

  Line 80 is:

var marketHoursDbEntry = MarketHoursDatabase.FromDataFolder().GetEntry(QuantConnect.Market.USA, null, SecurityType.Equity);
0

Hi Richard! Glad you're diving into the open source! But we can't do support for that here, please use google groups if possible and attach all your config and sample data so we can replicate the issue:

https://groups.google.com/forum/#!forum/lean-engine

0

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.


@Richard Hamilton: your call to PreMarketDailyUsEquityUniverse does not match the parameters, you pass 4, but 2 are accepted. The other is a casting issue, you can cast with (string) or (Symbol). Can you share your code so I can have a look?

0

@Quant Trader, thanks for the comments.  The full algo can be cloned from above...it's from Michael Handschuh's reply to the op.

0

this is first fix:

var marketHoursDbEntry = MarketHoursDatabase.FromDataFolder().GetEntry(QuantConnect.Market.USA, (Symbol) null, SecurityType.Equity);

second fix under investigation as I set null, but maybe you need to give an interface to an initialized object;


public PreMarketDailyUsEquityUniverse(UniverseSettings universeSettings, TimeSpan timeBeforeMarketOpen, Func<DateTime, IEnumerable<string>> selector)
: base(CreateConfiguration(), universeSettings, null, TimeSpan.MaxValue, selector)
{
_timeBeforeMarketOpen = timeBeforeMarketOpen;
}
0

fixed

1


@Quant Trader, ty, very much appreciated

0

Update Backtest





0

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.


Loading...

This discussion is closed