Hi Stephen,

Here's a link to the most recent thread on the TWS Yahoo Group concerning how to decode the tick and volume stream from the mktData.  It's full of knowledge gained the hard way, especially regrading the double volume tick bug.  I think it would be best to read that thread where the topic was thoroughly hashed out. 

https://groups.yahoo.com/neo/groups/TWSAPI/conversations/topics/29480


 
--
Stergios Marinopoulos


________________________________
 From: Stephen Choularton <stephen@organicfoodmarkets.com.au>
To: r-sig-finance@r-project.org 
Sent: Thursday, February 27, 2014 3:41 PM
Subject: Re: [R-SIG-Finance] meaning of IBroker mktData information


I hope someone can help me with this. No one has replied so far.

I am working on the principal that:

1. Volume is issued each time a trade takes place and is the cumulative 
volume for the day, and
2. lastPrice is the last price a trade took place and that is only 
issued again when the price changes.

This would lead me to be able to deduce the size of each deal from the 
change in volume and apply the (current) lastPrice to the transaction.

Have I got that right?

Even if I have I still have a problem.  Logic dictates that Volume !< 1 
but for example if I extract just the price volume data I get some 
examples like this:


10:17:12.158900 volume: 135    Price: 33.13
10:17:13.720741 volume: -47    Price: 33.13
10:17:22.875066 volume: 589    Price: 33.15

The original data was:

<20140210 10:17:12.158900> id=1 symbol=NAB Volume: 263348
<20140210 10:17:13.048749> id=1 symbol=NAB askSize: 2334
<20140210 10:17:13.720741> id=1 symbol=NAB Volume: 263301
<20140210 10:17:13.721744> id=1 symbol=NAB lastTimestamp: 1391987823
<20140210 10:17:13.723745> id=1 symbol=NAB lastPrice: 33.16
<20140210 10:17:13.724759> id=1 symbol=NAB lastSize: 88
<20140210 10:17:13.943221> id=1 symbol=NAB askSize: 2246
<20140210 10:17:17.308927> id=1 symbol=NAB askPrice: 33.15 askSize: 589
<20140210 10:17:17.309927> id=1 symbol=NAB askSize: 589
<20140210 10:17:18.195319> id=1 symbol=NAB askSize: 889
<20140210 10:17:20.466965> id=1 symbol=NAB bidSize: 3998
<20140210 10:17:21.219959> id=1 symbol=NAB askSize: 589
<20140210 10:17:22.868062> id=1 symbol=NAB lastTimestamp: 1391987832
<20140210 10:17:22.873064> id=1 symbol=NAB lastPrice: 33.15
<20140210 10:17:22.874064> id=1 symbol=NAB lastSize: 589
<20140210 10:17:22.875066> id=1 symbol=NAB Volume: 263890
<20140210 10:17:22.877067> id=1 symbol=NAB bidPrice: 33.14 bidSize: 762
<20140210 10:17:22.878067> id=1 symbol=NAB askPrice: 33.16 askSize: 3332

[[elided Yahoo spam]]

I know you might say just use lastPrice and lastSize but logic dictates 
you could have a lastPrice and multiple lastSize's but not multiple 
lastPrice's but see three lastPrices in a row below:


10:15:45.332624> id=1 symbol=NAB lastSize: 93
10:15:45.987894> id=1 symbol=NAB lastSize: 50
10:15:46.888228> id=1 symbol=NAB lastSize: 104
10:15:47.447062> id=1 symbol=NAB lastSize: 50
10:15:48.552406> id=1 symbol=NAB lastPrice: 33.10
10:15:49.450579> id=1 symbol=NAB lastSize: 42
10:15:50.201786> id=1 symbol=NAB lastSize: 122
10:15:51.455403> id=1 symbol=NAB lastSize: 50
10:15:54.460002> id=1 symbol=NAB lastPrice: 33.085
10:15:55.461604> id=1 symbol=NAB lastPrice: 33.10
10:15:56.463385> id=1 symbol=NAB lastPrice: 33.11
10:15:57.568193> id=1 symbol=NAB lastSize: 58
10:15:58.466236> id=1 symbol=NAB lastPrice: 33.10
10:15:59.585589> id=1 symbol=NAB lastPrice: 33.11
10:16:00.457302> id=1 symbol=NAB lastSize: 8
10:16:01.344762> id=1 symbol=NAB lastSize: 50
10:16:02.016870> id=1 symbol=NAB lastSize: 85
10:16:02.900224> id=1 symbol=NAB lastSize: 46
10:16:03.654076> id=1 symbol=NAB lastSize: 50
10:16:04.464855> id=1 symbol=NAB lastPrice: 33.095

(I have only shown the relevant lines.)

Have I got this wrong?  All I am trying to do is get accurate deal by 
deal price and size data.





Stephen Choularton PhD, FIoD

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
	[[alternative HTML version deleted]]

