API Support Forum
OEC API > API Support > RequestBars for Day bars not working still !
Author Topic: RequestBars for Day bars not working still !
(11 messages, Page 1 of 1)
Moderators: VPfau
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 12:00 PM             Msg. 1 of 11
I've looked at the OEC sample code, and I've used the same code thats worked before but RequestBars() only works sometimes. I cant get it to work for Daily. I've only gotten it to work for 15 min and 60min about 4 times total.

Can anyone confirm that they were able to get historical bars for Daily bars ?

Also, please post the code in C# to RequestBars if you have it working. I've worked with dozens of APIs over the last 10 years, and I've never had this many issues with something so simple. I'm just trying to get Daily bars from the last year up to now. I'm using ESM4 as the symbol

oecapi.RequestBars(contract,
OEC.API.Duration.Date(DateTime.UtcNow.AddDays(-89), DateTime.UtcNow),
OEC.API.BarDescription.Days(1)
);

Daniel Clark
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 26, 2014 @ 12:58 PM             Msg. 2 of 11
According our today's logs, you are trying to connect twice and the second connection kills the first one. Please check OECAPI logs.

Victor Vins
Lead Software Developer
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 01:58 PM             Msg. 3 of 11
I only have one application I use, so I dont see how there would be 2 connections.

Where is the log located ?

Thanks

Daniel Clark
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 26, 2014 @ 02:09 PM             Msg. 4 of 11
You need to use http://www.openecry.com/api/api/html/M_OEC_Log_Start_1.htm method before using OEC API to start logging at a folder that is the best for you.

Victor Vins
Lead Software Developer
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 02:33 PM             Msg. 5 of 11
Ok, I did that, but the log doesnt really tell me anything. There is only one instance of my program running. I even put in some code that creates a Mutex to prevent multiple instances.

Can you send me some RequestBars() code that you know works for Daily bars if you dont know ? I'm using the same code that works sometimes with Intraday.

Here is the log:

13:27:18.445 Dbg System #1 DClark1295 : Loaded, API: 90.0052ms, Client: 154.0088ms
13:27:18.830 Dbg System #1 1 ESM4: 267 Bars <Bars Items=[267] />
13:27:18.849 Dbg System #1 4 ESM4: 179 Bars <Bars Items=[179] />
13:27:18.903 Dbg System #1 2 ESM4: 69 Bars <Bars Items=[69] />
13:27:18.907 Dbg System #1 5 ESM4: 64 Bars <Bars Items=[64] />
13:27:18.908 Dbg System #1 5 ESM4: 0 Bars <Bars />
13:27:18.914 Dbg System #1 3 ESM4: 23 Bars <Bars Items=[23] />

Daniel Clark
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 26, 2014 @ 03:16 PM             Msg. 6 of 11
13:27:18.907 Dbg System #1 5 ESM4: 64 Bars <Bars Items=[64] />
13:27:18.908 Dbg System #1 5 ESM4: 0 Bars <Bars />

These two lines relate to your RequestBars call. Here is your request:
<Price Subscribe=Load Type=DayBar StartDate=12/27/2013 6:27:18 PM EndDate=3/26/2014 6:27:18 PM Interval=1 SubscriptionID=5 ContractID=273825720 />

At the same time, you subscribed to daily bars too. <Price Subscribe=Subscribe Type=DayBar StartDate=5/30/2013 6:27:18 PM EndDate=12/31/9999 11:59:59 PM Interval=1 SubscriptionID=4 ContractID=273825720 /> and this response relate to it:
13:27:18.849 Dbg System #1 4 ESM4: 179 Bars <Bars Items=[179] />

So, I guess our server responded correctly to your request. How do you handle responses?

Victor Vins
Lead Software Developer
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 03:25 PM             Msg. 7 of 11
Thanks for the reply !

I'm only checking if there is no bars currently and printing them out if they are present.

As soon as I start the app, I get this in on the screen:
13:27:18: oecapi_OnBarsReceived() No openEcry bars ; Updatable:True
13:27:18: oecapi_OnBarsReceived() No openEcry bars ; Updatable:False


Here is the code snippet:

static void oecapi_OnBarsReceived(OEC.API.Subscription subscription, OEC.API.Bar[] openecryBars)
{
if (openecryBars.Length < 1)
{
Console.WriteLine("oecapi_OnBarsReceived() No openEcry bars ; Updatable:{0}", subscription.Updatable);
return;
}

//code to print out bars here ....

}

Daniel Clark
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 03:40 PM             Msg. 8 of 11
Also, what do you mean your server is working as expected since I didnt get any bars I requested for Daily ?

I've tried commenting out all the SubscribeBars() calls and only leaving the RequestBars for Daily, but I still get the same exact result.

I would expect some bars to show up

Daniel Clark
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 26, 2014 @ 03:45 PM             Msg. 9 of 11
Historical responses come with several packets. After the last packet with historical bars, our server sends an empty packet. So, your output will always show "No openEcry bars" for every subscription or request.

Victor Vins
Lead Software Developer
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Mar 26, 2014 @ 03:49 PM             Msg. 10 of 11
OEC API writes down bars to the log right before calling OnBarsReceived (of course, if it is hooked by any handler). From what I see in your log clip, bars were sent by server.

Victor Vins
Lead Software Developer
DClark1295
Posts: 15
Joined: Jan 16, 2014


Posted: Mar 26, 2014 @ 04:57 PM             Msg. 11 of 11
Victor,

Thank you ! I really appreciate your help. I was able to figure out what the issue was. You are the best !

Daniel Clark