I created a strategy (I guess it can be an indicator as well) to check the completeness of data on a chart for back testing purposes. The output would look as follows for SPY loading daily bars from 1/1/1993 to 19/09/2022, it computes that about 3.5% of the data over that time period is missing:
------------------------------------------------------------------------
SPY - Quality 96.52%, Received 7264, Expected 7526
------------------------------------------------------------------------
Symbol,MissingBars,StartDate,EndDate
SPY,3,12/30/1993 4:00:00 PM,1/3/1994 4:00:00 PM
SPY,2,1/16/1994 4:00:00 PM,1/18/1994 4:00:00 PM
SPY,2,4/1/1994 4:00:00 PM,4/3/1994 4:00:00 PM
SPY,1,4/27/1994 4:00:00 PM,4/27/1994 4:00:00 PM
SPY,2,6/19/1994 4:00:00 PM,6/21/1994 4:00:00 PM
SPY,2,10/9/1994 4:00:00 PM,10/11/1994 4:00:00 PM
SPY,3,11/10/1994 4:00:00 PM,11/14/1994 4:00:00 PM
SPY,2,1/15/1995 4:00:00 PM,1/17/1995 4:00:00 PM
SPY,2,4/14/1995 4:00:00 PM,4/16/1995 4:00:00 PM
SPY,2,6/18/1995 4:00:00 PM,6/20/1995 4:00:00 PM
SPY,2,10/8/1995 4:00:00 PM,10/10/1995 4:00:00 PM
SPY,3,11/9/1995 4:00:00 PM,11/13/1995 4:00:00 PM
......
Given that this data is pretty fragmented I want to add functionality to this strategy to send data requests to download the missing sets of data, I'm using FreeQuotes for this but the data vendor is not that relevant. I've added the following code to the strategy but it does not seem to work:
Code: Select all
if (FixData)
{
foreach (Tuple<DateTime, DateTime> missingBarRange in _missingBarRanges) {
InstrumentDataRequest request = Bars.Request;
request.Subscribe2RT = true;
DataRequest dataRequest = new DataRequest();
dataRequest.RequestType = DataRequestType.FromTo;
dataRequest.From = missingBarRange.Item1;
dataRequest.To = missingBarRange.Item2;
request.Range = dataRequest;
DataLoader.BeginLoadData(request, OnData, null);
}
}
Thank you in advance for any feedback.
Kind regards
Ettienne