API Support Forum
OEC API > API Support > RequestBars sometimes works, sometimes does'nt
Author Topic: RequestBars sometimes works, sometimes does'nt
(12 messages, Page 1 of 1)
Moderators: VPfau
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 04, 2013 @ 11:26 AM             Msg. 1 of 12
Hi,

I'm trying to obtain the Settlement price for some contracts, this contracts belongs to the same base symbol (CC-M, the futures). In order to do this I'm requesting the bars, just because this request fills the CurrentPrice field in Contract object (well, first I subscribe the contracts), and into this field (which its type is Price) I can get the settlement price.
The problem is I don't always get all the bars, I mean, not all the executions of my program run OnBarsReceived method, sometimes yes, sometimes not. When I don't get all the executions of OnBarsReceived, varies which contracts have their bars, not always fail same contracts.
What am I missing?
Is there another way to obtain the CurrentPrice?

Thanks in advance

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 04, 2013 @ 01:16 PM             Msg. 2 of 12
Hello,

you don't need to request bars to obtain CurrentPrice. All what you need for it is just to subscribe for quotes http://www.openecry.com/api/api/html/M_OEC_API_OECClient_Subscribe.htm

Missed OnBarsReceived can be related to a error message that you mentioned in previous topic ("Your loading limit of 16 has been reached") - the bar request is ignored after reaching the limit

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 04, 2013 @ 01:37 PM             Msg. 3 of 12
Hi,

I manage that limit of 16 requests, just like RuslanK suggested, so I don't have that message any more, and sometimes I get all the bars, and there's no problem.
Actually CC-M future contracts are only 12, so I never reach that limit of 16. But I dont get bars for all that contracts all the time.
Previously I was just subscribing and waiting for OnPriceTick event, but, some contracts doesn't fire that event, just because they have no ticks in that particular moment when I execute my program, so, CurrentPrice never get updated and remains as null. I have observed, that the CurrentPrice is not null anymore until the first OnPriceTicks event is fired. That's why I change my logic and I use OnBarsReceived, but, sometimes I get bars for all that 12 contracts, but sometime I don't.

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 04, 2013 @ 03:05 PM             Msg. 4 of 12
OEC Trader populates Quotes window on OnPriceChanged event: this event is raised by initial setting of CurrentPrice. You can try to use this event too.

Please send me username and exact time of the issue when you requested bars and didn't receive a response.

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 04, 2013 @ 04:53 PM             Msg. 5 of 12
Hi,

OnPriceChanged works, I can read CurrentPrice field, but, if market is closed, this info from CurrentPrice is updated anyway? I mean, does it have the last settlement price? or the last price?

On the other hand, all RequestBars for all contracts don't fire all OnBarsReceived, for example in this execution:

I make RequestBars for all CC-M futures:
CC-MK3
CC-MM3
CC-MN3
CC-MQ3
CC-MU3
CC-MZ3
CC-MH4
CC-MK4
CC-MN4
CC-MU4
CC-MZ4
CC-MH5


And just some of them fired OnBarsReceived. OEC log is:

15:39:54.018 Dbg System #11 Logger level: Core (Data feed: every 1 per 00:01:00)
15:39:54.366 Dbg Reader Order Login to OEC Server 4.1.0.0
15:39:54.366 Dbg Reader Price Login to OEC Server 4.1.0.0
15:39:55.350 Dbg System #11 AAlonso : Loading
15:39:56.940 Dbg System #11 AAlonso : Loaded, API: 94.0054ms, Client: 1496.0855ms
15:39:57.425 Dbg System #11 13 CC-MK3: 68 Bars <Bars Items=[68] />
15:39:57.520 Dbg System #11 21 CC-MN4: 33 Bars <Bars Items=[33] />
15:39:57.526 Dbg System #11 19 CC-MH4: 67 Bars <Bars Items=[67] />
15:39:57.636 Dbg System #11 18 CC-MZ3: 68 Bars <Bars Items=[68] />
15:39:57.646 Dbg System #11 22 CC-MU4: 16 Bars <Bars Items=[16] />
15:39:57.655 Dbg System #11 17 CC-MU3: 68 Bars <Bars Items=[68] />
15:39:57.661 Dbg System #11 20 CC-MK4: 51 Bars <Bars Items=[51] />
15:39:57.794 Dbg System #11 15 CC-MN3: 68 Bars <Bars Items=[68] />


I ran this with:
username: AAlonso
host: prod.openecry.com



Thanks in advance.

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 05, 2013 @ 11:49 AM             Msg. 6 of 12
OECAPI logs a message for bar packages that have length more than 10 bars to prevent flood of messages. Missed log messages were related to contracts that have no bars at all or less than 10. Sorry for confusion.


Victor Vins
Lead Software Developer

Edited by VictorV on Apr 5, 2013 at 11:50:17
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 08, 2013 @ 10:53 AM             Msg. 7 of 12
Ok, I just think this was a good idea to show how not all OnBarsReceived events are fired. Anyway, I can see that not all the events are fired because I show lastPrice and other things just inside OnBarsReceived event, and not all of them are shown. There are only 12 contracts, I'm sure that not everyone fired the event.
The weird thing is, that sometimes all events are fired, so I have info from all 12 contracts, but sometimes doesn't, and I have info from some contracts (which and how varied)

On the other hand I have a question:
OnPriceChanged works, I can read CurrentPrice field, but, if market is closed, this info from CurrentPrice is updated anyway? I mean, does it have the last settlement price? or the last price?


Thanks in advance

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 08, 2013 @ 12:01 PM             Msg. 8 of 12
Are you sure your OnBarsReceived is not fired with less than 10 bars? The log snapshot from OECAPI is just a log issue, not an issue with events.

OnPriceChanged will be raised even market is closed. CurrentPrice will contain the latest known state, including the last and settlement price.

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 08, 2013 @ 12:11 PM             Msg. 9 of 12
I'm sure OnBarsReceived is not fired with any bars, as I said before, I just thought that showing OECAPI log was a good idea, but not, I'm sorry.
I have my own logs and also, I use OnBarsReceived event to show info into a windows form, and sometimes shows info from all contracts, and sometimes don't, and only are 12. And of course I update info in windows form asynchronously.

Now, that I know, thanks to you, OnPriceChanged works for my purposes, that's what I will use, but anyway, why RequestBars/OnBarsReceived doesn't work as expected?


Regards

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 08, 2013 @ 02:45 PM             Msg. 10 of 12
Our sample application loads daily bars of all CC-M contracts as expected. Could you please build a sample application to reproduce the issue?

Victor Vins
Lead Software Developer
CZendejas116
Posts: 51
Joined: Apr 13, 2011


Posted: Apr 08, 2013 @ 04:28 PM             Msg. 11 of 12
will be to send it to you?

Claudia Zendejas
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Apr 10, 2013 @ 05:20 PM             Msg. 12 of 12
Yes, this is ok

Victor Vins
Lead Software Developer