Hi Andre,

Somehow missed the first message.

While I agree the code for cleaning up can be improved, you *don't* in fact
have to worry about reusing id's in this context -- the API works fine if
you reuse.

> ibg <- ibgConnect()  # new connection to IBGateway (see googlecode
version, or change port#)

> reqMktData(ibg, twsSTK("AAPL"))
<20101109 19:40:29.989188> id=1 symbol=AAPL Volume: 133941
<20101109 19:40:29.991599> id=1 symbol=AAPL highPrice: 321.3
<20101109 19:40:29.992062> id=1 symbol=AAPL lowPrice: 314.5
<20101109 19:40:30.385254> id=1 symbol=AAPL lastTimestamp: 1289350673
<20101109 19:40:30.387106> id=1 symbol=AAPL lastTimestamp: 1289350790
<20101109 19:40:30.387568> id=1 symbol=AAPL lastPrice: 316.23
<20101109 19:40:30.387995> id=1 symbol=AAPL lastSize: 0
<20101109 19:40:30.388391> id=1 symbol=AAPL highPrice: 321.3
<20101109 19:40:30.388785> id=1 symbol=AAPL lowPrice: 314.5
<20101109 19:40:30.389189> id=1 symbol=AAPL closePrice: 318.62
<20101109 19:40:30.389603> id=1 symbol=AAPL openPrice: 321.0
<20101109 19:40:30.390021> id=1 symbol=AAPL bidPrice: -1.0  bidSize: 0
<20101109 19:40:30.390439> id=1 symbol=AAPL askPrice: -1.0  askSize: 0
<20101109 19:40:30.390899> id=1 symbol=AAPL bidSize: 0
<20101109 19:40:30.391293> id=1 symbol=AAPL askSize: 0
<20101109 19:40:30.884942> id=1 symbol=AAPL optionCallVolume: 143748
<20101109 19:40:30.888552> id=1 symbol=AAPL optionPutVolume: 92580
<20101109 19:40:30.889085> id=1 symbol=AAPL optionCallOpenInterest: 823586
<20101109 19:40:30.889520> id=1 symbol=AAPL optionPutOpenInterest: 689051
<20101109 19:40:30.890177> id=1 symbol=AAPL optionHistoricalVol:
0.28083274376268874 NA
<20101109 19:40:30.890640> id=1 symbol=AAPL optionImpliedVol:
0.26788630640248584
<20101109 19:40:30.891026> id=1 symbol=AAPL averageVolume: 190390
<20101109 19:40:30.891437> id=1 symbol=AAPL 13-week High: 320.17999268
<20101109 19:40:30.891875> id=1 symbol=AAPL 13-week Low: 235.55999756
<20101109 19:40:30.892300> id=1 symbol=AAPL 26-week High: 320.17999268
<20101109 19:40:30.892751> id=1 symbol=AAPL 26-week Low: 231.3500061
<20101109 19:40:30.893141> id=1 symbol=AAPL 52-week High: 320.17999268
<20101109 19:40:30.893572> id=1 symbol=AAPL 52-week Low: 188.67999268
<20101109 19:40:30.894023> id=1 symbol=AAPL shortable: 3.0
^C

# using the same connection, and as you can tell "id=1"
> reqMktData(ibg, twsSTK("YHOO"))
<20101109 19:40:35.136816> id=1 symbol=YHOO lastTimestamp: 1289350614
<20101109 19:40:35.138302> id=1 symbol=YHOO lastTimestamp: 1289350780
<20101109 19:40:35.138763> id=1 symbol=YHOO lastPrice: 16.88
<20101109 19:40:35.139165> id=1 symbol=YHOO lastSize: 30
<20101109 19:40:35.139568> id=1 symbol=YHOO Volume: 558702
<20101109 19:40:35.140046> id=1 symbol=YHOO highPrice: 17.6
<20101109 19:40:35.140449> id=1 symbol=YHOO lowPrice: 16.86
<20101109 19:40:35.140859> id=1 symbol=YHOO closePrice: 16.44
<20101109 19:40:35.141273> id=1 symbol=YHOO openPrice: 17.16
<20101109 19:40:35.141693> id=1 symbol=YHOO bidPrice: -1.0  bidSize: 0
<20101109 19:40:35.142110> id=1 symbol=YHOO askPrice: -1.0  askSize: 0
<20101109 19:40:35.142532> id=1 symbol=YHOO bidSize: 0
<20101109 19:40:35.142909> id=1 symbol=YHOO askSize: 0
^C

I'll take a look at fixing the cancel coding though.  It should really
handle the cancels by the id's originally passed in, not just a sequence---
again I'll look to implement a fix.  Thanks.

Best,
Jeff

On Tue, Nov 9, 2010 at 6:18 PM, Andre Zege <azege@yahoo.com> wrote:

>
>  I am not sure if this is a bug -- tried to reach Jeff Ryan through Nabble
> message a while back, but it doesn't look like he got my message. So here
> goes my question
>
> In reqMktData in a couple of places expression
> as.numeric(tickerId):length(Contract)) is used. In particular, it is used
> in
>
>    on.exit(cancelMktData(con,
> as.character(as.numeric(tickerId):length(Contract))))
>
> It seems to me this works fine when you call reqMktData once with default
> tickerId="1". It then cancels all tickerIds in the range
> 1:length(Contract).
> So far, so good. However, as tickerIds are not reusable in IB until you log
> out from TWS, if you need to call reqMktData more than once, this code is
> not going to cancel tickerId, as you will need to start with some other
> tickerId, say tickerId=100. If i understand it correctly, there should be
> something like
>    tid<-as.numeric(tickerId)
>    on.exit(cancelMktData(con, as.character(tid:(tid+length(Contract)))))
>
> Maybe i am confused though, so any clarification would be appreciated
> --
> View this message in context:
> http://r.789695.n4.nabble.com/possible-bug-in-IBrokers-or-my-confusion-tp3035331p3035331.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance@stat.math.ethz.ch 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.
>



-- 
Jeffrey Ryan
jeff.a.ryan@gmail.com

	[[alternative HTML version deleted]]

