Dataloader Question [SOLVED]
Posted: Sep 02 2013
I ran into a few issues with Dataloader that are either a bug or I have an improper understanding of their usage. I am using the current 64 Bit version of MC.NET.
1. When establishing an InstrumentDataRequest by referencing Bars.Request, the To and From properties are not available from Bars.Request. The workaround is easy, but this is either a bug or the documentation should articulate this point.
2. I set the DataRequest.ToAlwaysIsNow property to true and set the DataRequest.To property to new DateTime(1901, 1, 1). I expected that the ToAlwaysNow property would override any date in the To property field, but instead it returned no results. Is this a bug, or does ToAlwaysNow work differently than I stated?
3. The Dataloader.BeginLoadData is an async call, so it it highly possible that CalcBar() will fire before your finished receiving the callback or processed the results. I added thread blocking code, but this should also be articulated in your documentation. MC.NET is on the 4.0 framework so this could be refactored into the new Async / Await format and simplify the model as to avert this potential issue. Unless of course you have a different model in mind to manage this process?
Thanks for your replies.
Code: Select all
protected override void StartCalc()
{
var symbolCategory = ESymbolCategory.None;
Enum.TryParse(Category, true, out symbolCategory);
var dataRequestRange = new DataRequest
{
RequestType = DataRequestType.BarsBack,
Count = Bars.FullSymbolData.Count,
From = new DateTime(1901, 1, 1),
To = Bars.LastBarTime,
ToAlwaysIsNow = true
};
var request = Bars.Request;
request.Subscribe2RT = false;
request.Range = dataRequestRange;
request.TimeZone = RequestTimeZone.Local;
request.Exchange = Exchange;
request.Category = symbolCategory;
request.Symbol = Symbol;
var asyncDataRequest = DataLoader.BeginLoadData(request, OnData, null);
while (!asyncDataRequest.IsCompleted || !IsDataLoaded)
{
Thread.Sleep(100);
}
}
2. I set the DataRequest.ToAlwaysIsNow property to true and set the DataRequest.To property to new DateTime(1901, 1, 1). I expected that the ToAlwaysNow property would override any date in the To property field, but instead it returned no results. Is this a bug, or does ToAlwaysNow work differently than I stated?
3. The Dataloader.BeginLoadData is an async call, so it it highly possible that CalcBar() will fire before your finished receiving the callback or processed the results. I added thread blocking code, but this should also be articulated in your documentation. MC.NET is on the 4.0 framework so this could be refactored into the new Async / Await format and simplify the model as to avert this potential issue. Unless of course you have a different model in mind to manage this process?
Thanks for your replies.