API Support Forum
OEC API > Market Data > MaxBars subscription count includes same subscription several times, wrong api call?
Author Topic: MaxBars subscription count includes same subscription several times, wrong api call?
(3 messages, Page 1 of 1)
Moderators: VPfau
CWeber984
Posts: 226
Joined: Apr 24, 2012


Posted: Jun 28, 2016 @ 06:08 PM             Msg. 1 of 3
Currently we ask for historical intraday 1 minute data this way (we are COM api users):

OECAPI()->RequestBars(contract, fromDate, toDate,OECAPICOM::SubscriptionType_Bar, 1);

We get the callback in OnBarsReceived. We cancel the subscription:

OECAPI()->CancelSubscription(subscription);

Then we ask for more data according to what we don't yet have:

OECAPI()->RequestBars(contract, fromDate, toDate,OECAPICOM::SubscriptionType_Bar, 1);

and so on until we have the data up to the current time.

What ends up happening is the number of updateable subscriptions keeps on increasing, and we see more than one instance of being subscribed to one minute data:

6BU6 - Intraday Bar (1)
6BU6 - Intraday Bar (1)
6BU6 - Intraday Bar (1)
6BU6 - Intraday Bar (1)

UPDATE: In testing I found one call is sufficient to get all the desired history. We were concerned we were using the wrong call, or using the call incorrectly. We were using it incorrectly.

Thanks,
Edited by CWeber984 on Jun 29, 2016 12:24 AM
NShine
Posts: 36
Joined:


Posted: Jun 29, 2016 @ 08:47 AM             Msg. 2 of 3
Hello

I'm glad you are now receiving historical data. I'll add a couple notes which might help with any confusion you still have.

You are using the correct historical data request method. RequestBars/RequestTicks will fire OnBarsReceived/OnTicksReceived as each data packet comes in. You must be subscribed to these if you want to catch the data. When we are done sending data for a request, either because the request has been satisfied or the maximum amount of data has been returned for a single request, you will get a response with an empty bar/tick array. With this in mind, you can always create a new request if you need more data.

When it comes to subscriptions, you cannot cancel an un-updatable one. These will be removed once the final zero-length array packet comes in. So after calling RequestBars, do not call CancelSubscription.

Good luck!
CWeber984
Posts: 226
Joined: Apr 24, 2012


Posted: Jul 01, 2016 @ 09:16 PM             Msg. 3 of 3
We found we did need to make more than one request to get all available historical data. We were just doing it the wrong way. We weren't waiting for the zero bar callback before kicking off another request.

Thanks again,
Edited by CWeber984 on Jul 01, 2016 09:18 PM