- ago
When I call the GetHistory method of the DataProviderBase and pass the option to filter out the pre-post market data, the data is not actually filtered when using my own custom DataProvider.

In my data provider, I've implemented the method GetHistoryInternal. As far as I can tell, the options which are passed to DataProviderbase.GetHistory method are not passed along to the GetHistoryInternal method. So I cannot tell whether or not the pre-post market data should be filtered or not. So I do not filter it.

Normally, this works fine for the bars that are passed to a strategy's Execute method: WL filters out the pre-post market data for me. But when I use GetHistory this is not the case.

Is this correct, am I missing something, or should WL also filter out the pre-post data for me when using GetHistory?

Below is the code I use to call GetHistory.
Using WL8 build 89.

Thanks.

CODE:
public static BarHistory GetHistory(this BarHistory bars, HistoryScale scale, int priorDays, bool? filterPrePost = null) {    DataRequestOptions options = null;    if (filterPrePost.HasValue) {       options = new DataRequestOptions {          FilterPrePost = filterPrePost.Value       };    }    var dp = bars.GetDataProvider();    var history = dp.GetHistory(bars.Symbol, scale, bars.StartDate.AddDays(-priorDays), bars.EndDate, int.MaxValue, options);    return history; }

0
230
Solved
12 Replies

Reply

Bookmark

Sort
Cone8
 ( 6.32% )
- ago
#1
GetHistory() isn't a method to be implemented by the Historical Data Provider. It's most often used by Streaming provider to obtain the previous day's close by calling the companion's HistoricalDataProvider.Instance.GetHistory().

If it's not clear, GetHistory() calls your provider's GetHistoryInternal() method as required.

Also, GetHistory() in the UserStrategyBase is a function (with a different signature) you'd use in a Strategy to access bars of another symbol. See the QuickRef for details.
0
Best Answer
- ago
#2
Yes, that’s all clear. My point is that the option FilterPrePost is not respected, I.e. when set to true, the pre-post market data is still included after the call. Shouldn’t the pre-post market data be filtered out?
0
Glitch8
 ( 12.10% )
- ago
#3
Hi Erik,

Your provider should always return all of the data in GetHistoryInternal, WL will then filter out the data as required.

Let me know if this clears things up.
0
- ago
#4
Ok, that's clear, and that is exactly what I do: my provider returns all the data in GetHistoryInternal. However, WL does NOT filter out the pre-post market data in the call to GetHistory().

So I assume this is a bug then?

I can work around it for now, by calling the bars.FilterPrePost() method on the returned result from GetHistory(), but it would be nicer if WL filtered it out for me.

Thanks.
0
Glitch8
 ( 12.10% )
- ago
#5
I’m unclear of where and why YOU are calling GetHistory? Let’s open a chart and load intraday data from your provider, with filter pre/post enabled. Is the intraday data filtered?
0
- ago
#6
Yes, loading it into a chart with the pre-post filter enabled works fine.

Where I am using the call to GetHistory() is from within a strategy. I want to get additional data for the same symbol, but on a different time frame. In my case the strategy is set to use the minute time frame, but I also want to get the bars on an hourly time frame for that same symbol. I use this to determine support and resistance levels at the hourly time frame, which I then use within the strategy.
0
Cone8
 ( 6.32% )
- ago
#7
Then you're using the wrong GetHistory function, as I alluded to in Post #1. For a Strategy, call either GetHistory() or GetHistoryUnsynched() apply your scaling and Synchronize.
0
Glitch8
 ( 12.10% )
- ago
#8
Cone is right, do not call GetHistory of your provider directly, it won't work.
0
- ago
#9
Ok, that's clear.

So I would need to use the GetHistoryUnsynched, as I want the same symbol, but for a different time scale. But I cannot specify the start and end date for the data to be returned with this function, and I cannot specify whether the pre-post market data should be filtered out or not. I assume the values as specified in the strategy settings will be used for this. Is that correct?

Thanks.
0
Cone8
 ( 6.32% )
- ago
#10
Maybe you're overthinking it. GetHistory returns the synchronized the data, There's no value for this if you're requesting the same symbol as the chart symbol.

GetHistoryUnsynched returns all the data, including after market for the scale you specify. If and when you synchronize it, it will remove Pre/Post per the charted symbol.

If you really need the other function to specify start/end dates for some purpose, then you can call it from the WLHost.Instance.GetHistory(). In my experience, Pre/Post is honored.

CODE:
         DataRequestOptions dro = new();          dro.FilterPrePost = true;          BarHistory b = WLHost.Instance.GetHistory(bars.Symbol, HistoryScale.Minute10, DateTime.Now.Date.AddDays(-5), DateTime.Now.Date, 0, dro);          for (int i = 0; i < b.Count; i++)          {             WriteToDebugLog($"{b.DateTimes[i]:yyyyMMdd HHmm}\t{b.Close[i]}");          }
0
- ago
#11
Ok, thanks, that’s clear.

Just one last question. Which data provider is used when the WLHost.Instance.GetHistory() is called?

Thanks.
0
Cone8
 ( 6.32% )
- ago
#12
Top to bottom priority of the checked Historical Providers.
1

Reply

Bookmark

Sort