lbilli / rib

An R implementation of Interactive Brokers API
GNU General Public License v3.0
34 stars 7 forks source link

How to set-up Market Scanners #18

Open JoeFernando opened 1 year ago

JoeFernando commented 1 year ago

Thank you so much for this library. It has helped me tremendously.

I am a bit stuck on how to set-up market scanners. Could you kindly point me to any resource that will help me.

Thanks in advance.

Kind regards Joe

lbilli commented 1 year ago

Here's an example of a scanner:

library(rib)
ew <- IBWrapSimple$new()
ic <- IBClient$new(ew)
ic$connect(port=4002, clientId=1)

reqId <- 123

ss <- ScannerSubscription
ss$numberOfRows <- 10
ss$instrument   <- "STK"
ss$locationCode <- "STK.US.MAJOR"
ss$scanCode     <- "MOST_ACTIVE"

filters <- c(avgVolumeAbove="1000000", marketCapAbove1e6="100")

ic$reqScannerSubscription(reqId, ss, character(), filters)

ic$checkMsg()
# Results are received and continuously updated

# Finally to cancel the subscription
ic$cancelScannerSubscription(reqId)

# To request the available scanner parameters
ic$reqScannerParameters()

ic$checkMsg()

# Result is a big XML blob found at ew$context$scannerParameters

Few observations: