Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set-up Market Scanners #18

Open
JoeFernando opened this issue Nov 1, 2022 · 1 comment
Open

How to set-up Market Scanners #18

JoeFernando opened this issue Nov 1, 2022 · 1 comment

Comments

@JoeFernando
Copy link

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
Copy link
Owner

lbilli commented Nov 1, 2022

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:

  • filters are set in two places: fields of the ScannerSubscription structure and tag-value pairs in the last argument of ic$reqScannerSubscription()

  • to find out which codes and filters are available use reqScannerParameters() which returns what's available in XML format via scannerParameters()

  • this is a subscription: i.e. results are periodically updated until cancelScannerSubscription() is sent

  • further details can be found in the official IB documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants