Hi Everyone,
My primary resolution for OnData is minute level. In order to return yesterday's bar data, is it possible to have daily resolution for OnData as well? Ideally I want to have a method to process yesterday's data before the market opens. I know we could use Consolidator with daily resolution to do that, but for large universe, there might be some performance concerns. Any ideas?
Best,
TC
Fred Painchaud
Hi TC,
You can subscribe to multiple resolutions with AddEquity(X…Minute), AddEquity(X…Daily), for instance.
If you are using a Universe, then it is also possible to have many Universe Selections at different resolutions for the same assets as Universes are very well encapsulated and generic - but less trivial.
Let me know if you are using Universes.
Fred
T C
Hi Fred,
I am using Universes. I also tried your suggestion of using AddEquity(X…Minute), AddEquity(X…Daily). I am not sure where I did wrong, but it always returned the eod close of March 24. It seems that the Resolution.Daily overwrites Resolution.Minute.
# region imports
from AlgorithmImports import *
# endregion
class HipsterOrangeBison(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 3, 25) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("AAPL", Resolution.Minute)
self.AddEquity("AAPL", Resolution.Daily)
def OnData(self, data: Slice):
for symbol in data.Keys:
self.Debug(f"bar close: {data[symbol].Close} at {self.Time.strftime('%Y-%m-%d, %H:%M:%S')}")
Best regard,
TC
T C
Very interesting, for the above code, if you run it under debug mode, it actually outputs different result.
T C
Ran it directly:
Ran it under debug mode:
T C
Adding “fillDataForward = False” seems working. I haven't figured out how to do this easily for the entire universe.
Fred Painchaud
The two outputs in debug/no debug is indeed weird. But I dunno if you changed the code but it does output minute bars. You probably removed the Daily one.
Re fillforward, it is also very strange. Since fillforward should only have an impact when there is no data. Not when there is. Since it outputs always the same price when not in debug, it looks like a bug. Is it a bug specific to that run or does it happen all the time, this is something you should test. In other words, do you get the correct prices only when in debug mode? If so, you should report to support@quantconnect.com. It can only be a bug.
For fillforward for entire universes, you can use self.UniverseSettings.FillForward = True, before declaring the Universe.
Fred
T C
Hi Fred,
That output is pretty consistent and you probably can reproduce from your end using the code that I pasted earlier. As for how to apply both daily and minute resolutions to the entire universe, I still don't know how to do that. I have some walkaround solution, but it's not ideal.
Best regards,
Yuan
Fred Painchaud
Yep, I could reproduce the error but I already trusted you. So IMHO it needs to be reported to support.
Are you on Discord? If so, I could discuss multi-universes with you a bit later there as a chat instead of forum posts would be more appropriate (lengthy back and forth discussion on that topic is anticipated).
Fred
T C
Hi Fred,
I am on Discord. Let me know how I can add you. Thanks!
Best regards,
TC
Fred Painchaud
I am Fred Painchaud there also.
Fred
T C
Hi Fred,
I can't add you. It's asking for four digit tag. Thanks!
Best,
TC
Fred Painchaud
You should see me on the QC Discord server, here's the invite: https://www.quantconnect.com/discord
Fred
T C
Thanks Fred! I sent a friend request there.
T C
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!