API Support Forum
OEC API > API Support > Not able to get OHLC data for 1 minute through API
Author Topic: Not able to get OHLC data for 1 minute through API
(6 messages, Page 1 of 1)
Moderators: VPfau
SSprikut637
Posts: 12
Joined: Apr 04, 2011


Posted: Dec 20, 2011 @ 09:24 AM             Msg. 1 of 6
Hi,
I am requesting One minute OHLC for every single minute with the following code pasted below:

{
barType = OEC.Data.SubscriptionType.Bar;
interval = 1;
DateTime dt = DateTime.UtcNow;

Subscription s = _objOECClient.SubscribeBars(_objOECClient.Contracts[symbol], dt, barType, interval);

}
But I am getting a number of OHLC data in a single minute though I want only single OHLC in single minute. How can I get that?? Am I wrong somewhere while calling this method or there is some other way??

Sergey Sprikut
RuslanK
Posts: 69
Joined: Jun 02, 2010


Posted: Dec 22, 2011 @ 03:22 PM             Msg. 2 of 6
Hello Sergey

You're getting a number of OHLC data because you're subscribing for bars and data you receiving are realtime updates for the most current bar (if you compare an update with the previous data - you will see the difference).

If you would like to have a "snapshot" bar for last minute please consider to use this method:

RequestBars(Contract contract, DateTime EndDate, int Amount, Data.SubscriptionType Type, int Interval, bool IgnoreSessionBoundaries)

with Amount = 1 and EndDate = DateTime.Now

However in this case you will not receive any new bars unless you intentionally request one by calling this method again.

Please let me know if you have any further questions.

Ruslan Kartokhin
Software Developer
SHowes
Posts: 8
Joined: Jun 12, 2012


Posted: Jun 18, 2012 @ 05:04 PM             Msg. 3 of 6
Hello Ruslan

I tried:

Data.SubscriptionType Type, int Interval, bool IgnoreSessionBoundaries)

with Amount = 1 and EndDate = DateTime.Now

when oecClient_OnBarsReceived returns zero Bars, but I keep getting the same bar numerous times.


Am I doing something wrong?

When requesting 5 min Bars, how can I get OEC to fire OnBarsReceived only once per 5 minutes.

Regards
Sherry

Sherry Howes
RuslanK
Posts: 69
Joined: Jun 02, 2010


Posted: Jun 18, 2012 @ 05:08 PM             Msg. 4 of 6
Hello

The reason why you keep getting the same bar numerous times - event is being fired for every (or almost every) update of current bar.
So, subscribing to 5-minute bars doesn't mean that you will get an update once in five minutes - in fact you will get updates "almost" for every tick.

Ruslan Kartokhin
Software Developer
SHowes
Posts: 8
Joined: Jun 12, 2012


Posted: Jun 18, 2012 @ 07:14 PM             Msg. 5 of 6
Hello Ruslan

Thanks for quick response.

How should I request Bars with only one response per 5 minutes?

Regards
Sherry

Sherry Howes
SHowes
Posts: 8
Joined: Jun 12, 2012


Posted: Jun 20, 2012 @ 08:39 AM             Msg. 6 of 6
Hello Ruslan

I Get it now. Thanks.

Regards
Sherry

Sherry Howes