[R-SIG-Finance] Screeningn with IBrokers
Jeff Ryan
jeff.a.ryan at gmail.com
Mon Dec 28 17:19:07 CET 2009
Hi Peter,
Since you are passing in a list, use lapply to build it from a
character string (read from your file via scan/read.table/etc (R-help
question if you need to know how to do that ..)
> reqMktData(tws, lapply(c("AAPL","BBY","MSFT"),twsSTK), snapshot=TRUE)
lastTimeStamp symbol bidSize bidPrice askPrice askSize lastPrice Volume
1 2009-12-28 10:00:26 AAPL 1 213.18 213.19 3 213.17 84944
2 2009-12-28 10:08:48 BBY 3 40.89 40.90 1 40.90 0
3 2009-12-28 10:07:12 MSFT 1452 30.99 31.00 12344 31.00 0
Open High Low Close
1 211.15 213.95 211.10 209.04
2 40.85 41.20 40.80 40.70
3 31.00 31.00 30.97 31.00
Note that snapshot=TRUE tends to be 1) slow and 2) delayed from
real-time. You would be better off pulling chunks of data with some
sort of custom eWrapper object passed to reqMktData or
reqRealTimeBars. A further limit is that IB imposes (on data calls) a
limit of 100 concurrent symbols (+/-, depending on account).
With respect to #2, IB can't provide that any better than Yahoo or a
local database.
See:
library(quantmod)
?getSymbols
?getQuote
?Cl
HTH
Jeff
On Sun, Dec 27, 2009 at 8:10 AM, Peter Rote <r.rote12 at googlemail.com> wrote:
> Dear All,
>
> I would like to check a large list of stocks Tickers (300) if the open
> today is greater then yesterdays high (gap up).
> As result i would like to have a variable with symbols which meet the
> condition. My Ticker list is a csv file.
>
> my start point is reqMktData(tws, list(twsSTK("AAPL"),twsSTK("SBUX")),
> snapshot=TRUE)
>
> 1. but how do I put the Tickers in the reqMktData without having to
> type all 300 tickers.
> 2. how do I get the Yesterday High and compare that too today open.
>
> Does anyone have any ideas about that, please?
>
> Thanks for any help,
> Sincerely,
> Peter
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at 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.
>
--
Jeffrey Ryan
jeffrey.ryan at insightalgo.com
ia: insight algorithmics
www.insightalgo.com
More information about the R-SIG-Finance
mailing list