trophy

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

Back

Requesting History by the Calendar Month

I a looking for a way to request historical data from the last calendar month. I see you can use delta 7 for calendar weeks and delta 365 for calendar years, but I could not find anything for a calendar Month. I'm sure it is because unlike a week or year, the number of days in a month varies. So I'm asking if someone knows a way I can get historical data by the calendar month, please let me know below. Whether it is your own creativity or an api I don't know about.

I'm a longer-term trader and 85% of the problems I face would be solved if QC just had a simple weekly and monthly calendar resolution. Instead of using delta and Consolidators (can't use consolidators in self.History(). If there is a way let me know that would also solve this current problem)

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.


Hi,

Monthly consolidation is available, please see this example algo for more information.

Consolidators can definitely be used with the History() call. You simply need to call the consolidator's .Update() method on each of the received rows of daily history. This example shows how to do it for indicators, but the process is much the same for consolidators.

0

Douglas Stridsberg 

Could you provide a template on how I would get the consolidated data into the history() function. My understanding from what I read and what I was told is that it only takes in resolutions.

0

Hi,

What exactly are you looking to achieve with the history call? I thought you were trying to "warm up" a consolidator so-to-speak, using the History function, but it would seem that's not what you want.

Mostly people use the history call to warm up indicators - if you have a consolidator you want to use instead, it's a simple case of registering the indicator to use that consolidator directly. When the consolidator has new data, it will push it straight to the indicator.

0

Douglas Stridsberg 

Am I am trying to use history() to get the past calendar month data values. Then make trades based on those data values (ex: open, high, vol etc).  So basically how someone can use delta 7 and delta 365 to get the calendar week and year data values in the history() function. I want to do the same for the calendar month.

 

Also a quick side question, is their a way I could use history() to get the data values from a specific historical bar or is rolling window the only way to achieve that.

0

I see.

I would do the following:

  1. Create a monthly consolidator and register it using AddConsolidator (meaning it will warm up automatically if you use SetWarmup in Initialize).
  2. Create a rolling window to store monthly prices/volumes/bars (whatever you need).
  3. Update the rolling window from the consolidator by creating a handler function (example here, in the handler function you run rollingWindow.Add with the incoming data)
  4. Done! Access the data in the rolling window.

Running multiple History() requests is slow and inefficient. It's better to let the algorithm get the data and update the rolling window for you.

0

Douglas Stridsberg , won't using rolling windows require the algorithm to collect and fill up all the windows before it can use the data. So for example, if I have 2 rolling windows the current month and last month. Won't the algo have to "warm-up" and do nothing for 1 whole month before it has data to use? And a more extreme of if I wanted the last 8 months (9 rolling windows) then the algo would have to collect data for 8 months before it can start executing, or have I missed understood how rolling windows work?

0

No - you can still use a rolling window even if it's not fully populated. You just need to be very careful with not trying to access the empty elements.

A better approach is simply to tell your algorithm to warm up before it starts, so that all your windows are ready and populated. There are examples in the documentation and github on how to do this. If you've registered the consolidator with the subscription manager, you can use SetWarmup() in the Initialize() method.

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