Page 1 of 1

Dataloader Question  [SOLVED]

Posted: Sep 02 2013
by FistPeso
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.

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);
}
}
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.

Re: Dataloader Bugs/issues

Posted: Sep 05 2013
by FistPeso
DataRequest.ToAlwaysIsNow only applies to the time component of the DateTime property. Support indicated that they will add the async/await model as an enhancement request.

Re: Dataloader Question

Posted: Sep 10 2013
by Henry MultiŠ”harts
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.
We have ensured that these properties are available in MultiCharts .NET64 Version 8.7 Release (Build 7689). Please attach the code you are having problem with.
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?
This issue has been confirmed. It will fixed in the next version of MultiCharts .Net
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?
The method you have decided to use is possible, but we still recommend to use sleeps (Thread.Sleep(100);). Waiting can also be implemented with the help of events. Please check the attached code.

Re: Dataloader Question

Posted: Sep 08 2014
by MidKnight
From the example, it is not clear to me why you would use an array of WaitHandles and call WaitAny() rather than just a single WaitHandle and call WaitOne() ?

Also, would it not be prudent to have a timeout mechanism in place?

Perhaps you could clarify for us. Thank you.