<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#ffffff">
Hi Jeff<br>
<br>
Sorry to put this up again, but I am completely stuck. <br>
<br>
How do I reference the second data object<br>
<br>
BidPrice2 <- as.numeric(eWrapper$.Data$data[[2]][,5]) doesn't
work.<br>
<br>
<div class="moz-signature">Stephen Choularton Ph.D., FIoD<br>
<br>
9999 2226<br>
0413 545 182<br>
<br>
<img src="cid:part1.01050001.09020306@organicfoodmarkets.com.au"
alt="" width="300" align="" border="0" height="188"><br>
for insurance go to <a href="http://www.netinsure.com.au">www.netinsure.com.au</a><br>
for markets go to <a href="http://www.organicfoodmarkets.com.au">www.organicfoodmarkets.com.au</a><br>
</div>
<br>
On 09/12/2010 8:06 AM, Stephen Choularton wrote:
<blockquote cite="mid:4CFFF34A.6060402@organicfoodmarkets.com.au"
type="cite">Hi Jeff <br>
<br>
Thanks, but when I try to reference the second data object using
this (which is all I can think of): <br>
<br>
BidPrice2 <- as.numeric(eWrapper$.Data$data[[2]][,5]) <br>
<br>
The code runs but I don't get any info.
eWrapper$.Data$data[[2]][,5] appears to exist but to be empty. Do
I have to do something to place the data into it? <br>
<br>
Plus does curMsg <- readBin(con, character(), 1) give me the
ticker id? <br>
<br>
<br>
<br>
Stephen Choularton Ph.D., FIoD <br>
On 09/12/2010 4:07 AM, Jeff Ryan wrote: <br>
<blockquote type="cite">Stephen, <br>
<br>
You're close. <br>
<br>
On Tue, Dec 7, 2010 at 1:13 PM, Stephen Choularton <br>
<a class="moz-txt-link-rfc2396E"
href="mailto:stephen@organicfoodmarkets.com.au"><stephen@organicfoodmarkets.com.au></a>
wrote: <br>
<blockquote type="cite">So back again! <br>
<br>
I have two problem in converting my callback to two handle two
symbols so I <br>
can set up spreads. (Or at least that's what I can see it at
the moment): <br>
<br>
When I run this using myCALLBACK function below: <br>
<br>
con = twsConnect() <br>
<br>
reqMktData(con, list(twsSTK("MSFT"),twsSTK("AAPL")), <br>
event=eWrapper.data(1), CALLBACK=myCALLBACK) <br>
</blockquote>
The eWrapper needs to be set up to handle the number of
contracts you <br>
are watching. You need: eWrapper.data(2), with 2 being the
length of <br>
the contracts you are watching. <br>
<br>
The ticker id is by default mapped to the order of the Contracts
you <br>
pass in. So MSFT is 1, AAPL is 2 ... <br>
<br>
HTH, <br>
Jeff <br>
<blockquote type="cite">I get this <br>
<br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " NA
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
2 -1 2104 Market data farm connection is OK:aufarm <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " NA
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
2 -1 2104 Market data farm connection is OK:usfarm <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " NA
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " NA
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " NA
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
NA <br>
[13] "Volume: " NA <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " NA <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " NA "BidPrice: " NA
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
NA <br>
[7] "AskSize: " NA "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"4" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343529" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "1435" "BidPrice: " "26.96"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.97" <br>
[7] "AskSize: " "828" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
[1] "BidSize: " "970" "BidPrice: " "26.97"
"AskPrice: " <br>
"26.98" <br>
[7] "AskSize: " "847" "Last: " "26.97"
"LastSize : " <br>
"2" <br>
[13] "Volume: " "343550" <br>
Error in `*tmp*`[[id]] : subscript out of bounds <br>
<br>
<br>
I think what is happening is that the function fails on its
first attempt to <br>
get data on AAPT and the above data is on MSFT but I am quite
unsure as to <br>
what direction to take to amend the function. Any pointers
most welcome. <br>
<br>
Secondly I need to be able to know which symbol I am dealing
with. The <br>
output for: <br>
<br>
reqMktData(con, list(twsEquity("MSFT"),twsEquity("AAPL"))) <br>
<br>
is <br>
<br>
TWS Message: 2 -1 2104 Market data farm connection is
OK:aufarm <br>
TWS Message: 2 -1 2104 Market data farm connection is
OK:usfarm <br>
<20101208 05:55:28.974000> id=1 symbol=MSFT Volume:
343560 <br>
<20101208 05:55:28.978000> id=1 symbol=MSFT highPrice:
27.09 <br>
<20101208 05:55:28.983000> id=1 symbol=MSFT lowPrice:
26.88 <br>
<20101208 05:55:28.988000> id=2 symbol=AAPL Volume:
79079 <br>
<20101208 05:55:28.993000> id=2 symbol=AAPL highPrice:
323.99 <br>
<br>
and shows the symbol I need but when I try to find something
that refers to <br>
it in myCALLBACK I seem to fail. Is it somewhere in the data
object? Is it <br>
somewhere esle someone can point me to? <br>
<br>
Stephen Choularton Ph.D., FIoD <br>
<br>
<br>
On 07/12/2010 5:24 PM, Stephen Choularton wrote: <br>
<blockquote type="cite">Just for the record I though I should
post this as it did actually place <br>
the order I was after: <br>
<br>
library(IBrokers) <br>
<br>
myCALLBACK<- <br>
function(twsCon, eWrapper, timestamp, file, playback = 1,
...) { <br>
<br>
con<- twsCon[[1]] <br>
traded<- FALSE <br>
while (TRUE) { <br>
socketSelect(list(con), FALSE, NULL) <br>
#data <br>
curMsg<- readBin(con, character(), 1) <br>
if (!is.null(timestamp)) { <br>
processMsg(curMsg, con, eWrapper, format(Sys.time(),
timestamp), <br>
file, ...) <br>
} else { <br>
processMsg(curMsg, con, eWrapper, timestamp, file,
...) <br>
} <br>
# EXTRACT DATA HERE <br>
BidSize<- as.numeric(eWrapper$.Data$data[[1]][,1]) <br>
BidPrice<- as.numeric(eWrapper$.Data$data[[1]][,2]) <br>
AskPrice<- as.numeric(eWrapper$.Data$data[[1]][,3]) <br>
AskSize<- as.numeric(eWrapper$.Data$data[[1]][,4]) <br>
Last<- as.numeric(eWrapper$.Data$data[[1]][,5]) <br>
LastSize<- as.numeric(eWrapper$.Data$data[[1]][,6]) <br>
Volume<- as.numeric(eWrapper$.Data$data[[1]][,7])
<br>
print(c("BidSize: ", BidSize, "BidPrice: ", BidPrice,
"AskPrice: ", <br>
AskPrice, "AskSize: ", AskSize, "Last: ", Last, "LastSize :
", LastSize , <br>
"Volume: ", Volume )) <br>
# TRADE LOGIC HERE <br>
if(!traded&& !is.na(Last)&& Last>=
49) { <br>
<br>
print(c("inside the trading logic ")) <br>
id<- reqIds(twsCon) <br>
#placeOrder(tws, twsEquity("CBA","ASX","AUD"),
twsOrder(id, "BUY", <br>
"1", "MKT")) <br>
traded<- TRUE <br>
} <br>
} <br>
} <br>
<br>
<br>
<br>
con = twsConnect() <br>
<br>
<br>
<br>
#reqMktData(con, twsEquity("GOOG"), event=eWrapper.data(1),
<br>
CALLBACK=myCALLBACK) <br>
<br>
<br>
reqMktData(con, twsEquity("CBA","ASX","AUD"),
event=eWrapper.data(1), <br>
CALLBACK=myCALLBACK) <br>
<br>
<br>
<br>
closeAllConnections() <br>
<br>
<br>
I imagine I will be back as I am actually trying to use this
for spreads - <br>
so now I have to move on and try two symbols, etc but for
what it is worth <br>
the code is there for anyone who wants to use it. <br>
<br>
Stephen Choularton Ph.D., FIoD <br>
<br>
<br>
On 06/12/2010 10:17 AM, Jeff Ryan wrote: <br>
<blockquote type="cite">Stephen, <br>
<br>
Comments inline: <br>
<br>
On Sun, Dec 5, 2010 at 1:23 PM, Stephen Choularton <br>
<a class="moz-txt-link-rfc2396E"
href="mailto:stephen@organicfoodmarkets.com.au"><stephen@organicfoodmarkets.com.au></a>
wrote: <br>
<blockquote type="cite">Hi <br>
<br>
If you read this list you will have noticed I have been
working on <br>
callbacks <br>
and I finally got to some code that appears to work so I
though I would <br>
share it: <br>
<br>
library(IBrokers) <br>
<br>
myCALLBACK<- <br>
function(twsCon, eWrapper, timestamp, file, playback =
1, ...) { <br>
con<- twsCon[[1]] <br>
twsOC<- twsConnect(2) # our order connection <br>
con2<- twsOC[[1]] <br>
ocWrapper<- eWrapper(TRUE) <br>
traded<- FALSE <br>
while (TRUE) { <br>
cons<- socketSelect(list(con, con2), FALSE,
0.01) <br>
if(cons[1]) { #data <br>
curMsg<- readBin(con, character(), 1) <br>
if (!is.null(timestamp)) { <br>
processMsg(curMsg, con, eWrapper,
format(Sys.time(), <br>
timestamp), file, ...) <br>
} else { <br>
processMsg(curMsg, con, eWrapper,
timestamp, file, ...) <br>
} <br>
} else if(cons[2]) { <br>
curMsg<- readBin(con2, character(), 1) <br>
if (!is.null(timestamp)) { <br>
processMsg(curMsg, con2, ocWrapper,
format(Sys.time(), <br>
timestamp), file, ...) <br>
} else { <br>
processMsg(curMsg, con2, ocWrapper,
timestamp, file, ...) <br>
} <br>
} # TRADE LOGIC HERE <br>
curBID<-
as.numeric(eWrapper$.Data$data[[1]][3]) <br>
if(!traded ) { # add back on open:&&
!is.na(curBID)&& curBID> <br>
141.00 <br>
<br>
print(c("the cur bid is ", curBID)) <br>
# IBrokers:::.placeOrder(twsOC,
twsEquity("CBA","ASX","AUD"), <br>
twsOrder(1053, "BUY", "0", "MKT")) <br>
traded<- TRUE <br>
} <br>
} <br>
twsDisconnect(twsOC) <br>
} <br>
<br>
con = twsConnect(1) <br>
<br>
# contracts<- list(twsSTK("MSFT"),twsSTK("AAPL"))) <br>
<br>
<br>
reqMktData(con, twsEquity("GOOG"), CALLBACK=myCALLBACK)
<br>
<br>
twsDisconnect(con) <br>
<br>
However, even though I have tried to close down my
twsCnnections, if I <br>
run <br>
the code twice I get a warning along the lines: <br>
<br>
unable to connect. client id already in use. retry with
unique client id <br>
<br>
and R freezes. Does anyone know how to solve the
problem? <br>
</blockquote>
R is likely "freezing" due to buffering on Windows (which
you can turn <br>
off in the GUI), but that isn't really the core issue.
You don't need <br>
to have a second connection opened in the CALLBACK. It is
in the <br>
examples of one of my talks to illustrate having an
external mkt data <br>
feed and IB execution. If you are only looking at IB (for
data and <br>
execution), DON'T use a second connection. Seriously it
is not needed <br>
at all, and it is just making things more confusing I
suspect. <br>
<br>
<blockquote type="cite"> From there (on connection)
close(con) or twsDisconnect(con) should <br>
</blockquote>
indeed free up the client id. You can always go the route
of <br>
closeAllConnections() route in R to 'start over'. <br>
<br>
<blockquote type="cite">Incidentally I notice that the
code gets curBID<- <br>
as.numeric(eWrapper$.Data$data[[1]][3]). Does anyone
know what the <br>
appropriate indices are for the other data in
eWrapper$.Data and what <br>
that <br>
data is? <br>
<br>
</blockquote>
As Mark points out in his reply, look at the source for
the <br>
answers/hints: <br>
<br>
In order: BidSize, BidPrice, AskPrice, AskSize, Last,
LastSize and <br>
Volume. The first four ordering mimic what it looks like
when you <br>
stand in the pit on the floor and look at the CRTs (or
your own custom <br>
screen...) ;-) <br>
<br>
<br>
# from the source <br>
<blockquote type="cite">eWrapper.data <br>
</blockquote>
function (n) <br>
{ <br>
eW<- eWrapper(NULL) <br>
eW$assign.Data("data",
rep(list(structure(.xts(matrix(rep(NA_real_, <br>
7), nc = 7), 0), .Dimnames = list(NULL,
c("BidSize", <br>
"BidPrice", "AskPrice", "AskSize", "Last",
"LastSize", <br>
"Volume")))), n)) <br>
eW$tickPrice<- function(curMsg, msg, timestamp,
file, ...) { <br>
tickType = msg[3] <br>
msg<- as.numeric(msg) <br>
id<- msg[2] <br>
data<- eW$get.Data("data") <br>
attr(data[[id]], "index")<-
as.numeric(Sys.time()) <br>
nr.data<- NROW(data[[id]]) <br>
if (tickType == .twsTickType$BID) { <br>
data[[id]][nr.data, 1:2]<- msg[5:4] <br>
} <br>
else if (tickType == .twsTickType$ASK) { <br>
data[[id]][nr.data, 3:4]<- msg[4:5] <br>
} <br>
else if (tickType == .twsTickType$LAST) { <br>
data[[id]][nr.data, 5]<- msg[4] <br>
} <br>
eW$assign.Data("data", data) <br>
c(curMsg, msg) <br>
} <br>
eW$tickSize<- function(curMsg, msg, timestamp,
file, ...) { <br>
data<- eW$get.Data("data") <br>
tickType = msg[3] <br>
msg<- as.numeric(msg) <br>
id<- as.numeric(msg[2]) <br>
attr(data[[id]], "index")<-
as.numeric(Sys.time()) <br>
nr.data<- NROW(data[[id]]) <br>
if (tickType == .twsTickType$BID_SIZE) { <br>
data[[id]][nr.data, 1]<- msg[4] <br>
} <br>
else if (tickType == .twsTickType$ASK_SIZE) { <br>
data[[id]][nr.data, 4]<- msg[4] <br>
} <br>
else if (tickType == .twsTickType$LAST_SIZE) { <br>
data[[id]][nr.data, 6]<- msg[4] <br>
} <br>
else if (tickType == .twsTickType$VOLUME) { <br>
data[[id]][nr.data, 7]<- msg[4] <br>
} <br>
eW$assign.Data("data", data) <br>
c(curMsg, msg) <br>
} <br>
return(eW) <br>
} <br>
<environment: namespace:IBrokers> <br>
<br>
You can of course do whatever you like to make it more
logical to you. <br>
Reading IBrokers source and the official Java source
(yikes) is the <br>
way to get to a different end if you so require. <br>
<br>
Best, <br>
Jeff <br>
<br>
<blockquote type="cite"> <br>
-- <br>
Stephen Choularton Ph.D., FIoD <br>
<br>
_______________________________________________ <br>
<a class="moz-txt-link-abbreviated"
href="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a>
mailing list <br>
<a class="moz-txt-link-freetext"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a>
<br>
-- Subscriber-posting only. If you want to post,
subscribe first. <br>
-- Also note that this is not the r-help list where
general R questions <br>
should go. <br>
<br>
</blockquote>
<br>
</blockquote>
_______________________________________________ <br>
<a class="moz-txt-link-abbreviated"
href="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a>
mailing list <br>
<a class="moz-txt-link-freetext"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a>
<br>
-- Subscriber-posting only. If you want to post, subscribe
first. <br>
-- Also note that this is not the r-help list where general
R questions <br>
should go. <br>
<br>
<br>
<br>
<br>
----- <br>
No virus found in this message. <br>
Checked by AVG - <a class="moz-txt-link-abbreviated"
href="http://www.avg.com">www.avg.com</a> <br>
Version: 10.0.1170 / Virus Database: 426/3301 - Release
Date: 12/06/10 <br>
<br>
<br>
</blockquote>
_______________________________________________ <br>
<a class="moz-txt-link-abbreviated"
href="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a>
mailing list <br>
<a class="moz-txt-link-freetext"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a>
<br>
-- Subscriber-posting only. If you want to post, subscribe
first. <br>
-- Also note that this is not the r-help list where general R
questions <br>
should go. <br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
_______________________________________________ <br>
<a class="moz-txt-link-abbreviated"
href="mailto:R-SIG-Finance@r-project.org">R-SIG-Finance@r-project.org</a>
mailing list <br>
<a class="moz-txt-link-freetext"
href="https://stat.ethz.ch/mailman/listinfo/r-sig-finance">https://stat.ethz.ch/mailman/listinfo/r-sig-finance</a>
<br>
-- Subscriber-posting only. If you want to post, subscribe first.
<br>
-- Also note that this is not the r-help list where general R
questions should go. <br>
<br>
<br>
<br>
<br>
----- <br>
No virus found in this message. <br>
Checked by AVG - <a class="moz-txt-link-abbreviated"
href="http://www.avg.com">www.avg.com</a> <br>
Version: 10.0.1170 / Virus Database: 426/3303 - Release Date:
12/07/10 <br>
<br>
<br>
</blockquote>
</body>
</html>