trophy

Long Only, ETF Alpha Streams Competition with $27,500 Prize Pool

Back

Documentation discussion algorithm-reference/universes

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.


Question about the resolution :

 

self.UniverseSettings.Resolution = Resolution.Daily // What resolution should added assets use

 

suppose I want to perform a universe selection every 7days or month , 

how could it be implemented ?consolidating data and then use it as resolution?

0

Hi Ofir,

There are many options to achieve your goal.1. We could use Scheduled Universe Selection. Here is an example of performing an universe selection every Monday:

# in self.Initialize():
self.AddUniverseSelection(ScheduledUniverseSelectionModel(
    self.DateRules.Every(DayOfWeek.Monday),
    self.TimeRules.Every(timedelta(hours = 12)),
    self.SelectSymbols # selection function in algorithm.
))

def SelectSymbols(self):
    # your strategy here


To preform it monthly, we could use this as our date rule:

# self.AddEquity("SPY")
self.DateRules.MonthStart("SPY")


Here is more information regarding scheduled event.

2. We could use data consolidator. Here is an example to consolidate "SPY" daily data into 7-day bar:

from datetime import timedelta
# in self.Initialize():
self.AddEquity("SPY", Resolution.Daily)
consolidator = TradeBarConsolidator(timedelta(days=7))
consolidator.DataConsolidated += self.OnDataConsolidated
self.SubscriptionManager.AddConsolidator("SPY", consolidator)
# later in the algorithm:
def OnDataConsolidated(self, sender, bar):
    # perform your strategy here

3. We could use a flag. Here is an example with a monthly flag:

# in self.Initialize():
self.month = -1
# before universe selection:
if self.month == self.Time.month: return
# after universe selection:
self.month = self.Time.month # ensure the universe selection only run once in every month

Hope it helps.

1

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.


Please explain to me on what date the data are taken in the Universe Selection. For example if self.SetStartDate(2019,6,4) how can I understand that Coarsefundmental is taking data from the previous trading day(2019-06-03)?

By default, self.UniverseSettings.fillForward == False?
0

ok...I helped myself.

 for x in coarse:
            self.Log(x.Time) 

Coarsefundmental takes data from the current trading day. Why??

0

*Coarsefundmental starts with data from self.SetStartDate.

0

Sorry, I was wrong. I didn't count the following when I checked the data:

"Finally, when reviewing the results of your history requests remember they are indexed by the EndTime of each data point. For daily data, this results in makes it appear datapoints appear on Saturday, and skipping Monday's bar."

0

In the article above "LEAN automatically subscribes to these new symbols and adds them to your algorithm."

But I don't know how I can access that filtered symbols. Where is the filtered symbols?

Thanks.

0

Hi Bill,

Thank you for your question. Generally speaking, the subscribed data for the filtered symbols are in the slice variable in the OnData(Slice slice) method. You can just simply access any of them with slice[symbol]. For example, if "AAPL" is in your filtered symbols set, then you can assess its data using slice["AAPL"] in the OnData(Slice slice) method.

If you only want the added or removed universe, then the changes variable in the OnSecuritiesChanged() method would suffice. We provide many examples of how to use filtered symbols after Universe Selection. Please check out the examples on the top of the same page. Thank you!

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.


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