[R-SIG-Finance] IBrokers

Joshua Ulrich josh.m.ulrich at gmail.com
Mon Dec 6 21:04:22 CET 2010


Stephen,

Please reply to your original thread when responding to it.  You've
created 3 threads in 3 days on the same topic...

--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.com



On Mon, Dec 6, 2010 at 1:46 PM, Stephen Choularton
<stephen at organicfoodmarkets.com.au> wrote:
> Well I was wrong. I have simplified the code:
>
> myCALLBACK <-
> function(twsCon, eWrapper, timestamp, file, playback = 1, ...) {
>
>    con <- twsCon[[1]]
>    traded <- FALSE
>    while (TRUE) {
>        socketSelect(list(con), FALSE, NULL)
>        #data
>    curMsg <- readBin(con, character(), 1)
>    if (!is.null(timestamp)) {
>        processMsg(curMsg, con, eWrapper, format(Sys.time(), timestamp),
> file, ...)
>    } else {
>        processMsg(curMsg, con, eWrapper, timestamp, file, ...)
>    }
>
>    # TRADE LOGIC HERE
>    curBID <- as.numeric(eWrapper$.Data$data[[1]][3])
>    print(c("the cur bid is ", curBID, "end"))
>    if(!traded  ) { # add back on open: && !is.na(curBID) && curBID > 141.00
>
>        print(c("inside the trading logic "))
>        # IBrokers:::.placeOrder(twsCon, twsEquity("CBA","ASX","AUD"),
> twsOrder(1053, "BUY", "0", "MKT"))
>        # traded <- TRUE
>    }
>    }
> }
>
>
>
> con = twsConnect()
>
> # contracts <-  list(twsSTK("MSFT"),twsSTK("AAPL")))
>
>
> reqMktData(con, twsEquity("GOOG"), CALLBACK=myCALLBACK)
>
> # reqMktData(con, twsEquity("CBA","ASX","AUD"), CALLBACK=myCALLBACK)
>
> closeAllConnections()
>
> but when I run it 'curBID <- as.numeric(eWrapper$.Data$data[[1]][3])' does
> not get me the current bid even though the callback is seeing it as this
> line from the output shows:
>
> <20101207 06:40:35.844000> id=1 symbol=GOOG bidPrice: 579.31  bidSize: 3
>
> Does any one know how to reference the data?   I have tried all sorts of
>  combinations of indices, etc but I'm not going to find it by chance and I
> cannot find anything in the lit.
>
>
> --
> Stephen Choularton Ph.D., FIoD
>
> _______________________________________________
> R-SIG-Finance at 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.
>



More information about the R-SIG-Finance mailing list