API Support Forum
OEC API > API Support > Subscribe to Last Traded Price and Volume
Author Topic: Subscribe to Last Traded Price and Volume
(7 messages, Page 1 of 1)
Moderators: VPfau
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 25, 2011 @ 04:47 PM             Msg. 1 of 7
Question:

Here's what I want, subscribe to Last Traded prices and size for a Contract.

How do I get that?
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 25, 2011 @ 05:06 PM             Msg. 2 of 7
Hello,

if you need just some last price and size, Subscribe() and OnPriceChanged will be enough. If you need to capture all trades (or ticks), you need to use SubscribeTicks() and OnTicksReceived

Victor Vins
Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 25, 2011 @ 05:48 PM             Msg. 3 of 7
The documentation on SubscribeTicks doesn't really tell us much about it. In fact, it's a little misleading, as it says it's for a "time range" but that range is actually open-ended.

If I give a StartDate of "DateTime.Now", why do I still get a ton of historical ticks? (Is that a bug in your API?) I'd expect only ticks for trades that occur now or afterward.

For instance, in my app right now I subscribed to ticks for ESM1 on the prod feed. I get this:

First Tick: 4096 entries (received 5/25/2011 4:34:57 CDT):
[Tick entries follow: timestamp - volume - price]
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 2 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 2 - 1319
- - 5/25/2011 6:56:14 PM - 3 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 3 - 1319
- - 5/25/2011 6:56:14 PM - 2 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 5 - 1319
- - 5/25/2011 6:56:14 PM - 4 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 25 - 1319
- - 5/25/2011 6:56:14 PM - 3 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 2 - 1319
- - 5/25/2011 6:56:14 PM - 21 - 1319
- - 5/25/2011 6:56:14 PM - 1 - 1319
- - 5/25/2011 6:56:14 PM - 3 - 1319
- - 5/25/2011 6:56:14 PM - 2 - 1319
[4000+ more entries follow]

Now, I'm guessing that 6:56 PM is UTC, which is 1:56 CDT. Why am I getting ticks from 3 hours ago when my StartDate was "DateTime.Now"?

Another question: The first ~100 entries in the ticks object all have the same timestamp 6:56:20 PM. Did all those trades happen in the same minute?
Edited by THarnett81 on May 25, 2011 at 17:49:51
VictorV
Posts: 746
Joined: May 08, 2007


Posted: May 25, 2011 @ 06:23 PM             Msg. 4 of 7
StartDate is expected in UTC. Please try to use DateTime.UtcNow.

You're right, it is open-ended time range. The same is correct for all bar-related subscribe methods. To differentiate open-ended subscriptions from closed range request, we are calling closed range requests like RequestXXX()

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


Posted: May 25, 2011 @ 06:25 PM             Msg. 5 of 7
About timestamp: precision of timestamp is seconds.

Victor Vins
Software Developer
THarnett81
Posts: 78
Joined: Jan 13, 2011


Posted: May 26, 2011 @ 06:10 PM             Msg. 6 of 7
Just to be clear, should we expect the last elements in Ticks.Prices/Ticks.Volumes to be "in sync" with the latest PriceUpdateEvent's Price.LastPrice/Price.LastVol values?
VictorV
Posts: 746
Joined: May 08, 2007


Posted: Jun 01, 2011 @ 08:33 AM             Msg. 7 of 7
Just in some cases when you do not receive any ticks/price anymore after the last update (end of session, illiquid contract, no trades, etc)

Victor Vins
Software Developer