get_quote.IB: Download current instrument quote using IBrokers...

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Download current instrument quote using IBrokers

Usage

1
2
3
4
5
get_quote(Symbols, src = "IB", ...)

get_quote.IB(Symbols, verbose = FALSE, tws = NULL, ...)

getQuote.IB(Symbols, verbose = FALSE, tws = NULL, ...)

Arguments

Symbols

Can be a vector of instrument names, or a character string of symbols, separated by semi-colons.

src

method to use to get the quote. Only "IB" and "yahoo" supported

verbose

boolean. If TRUE, user will be informed that connection is established, and what is being downloaded.

tws

Currently not implemented.

...

other arguments such as ‘eWrapper’

Details

get_quote can be called with src="yahoo" or src="IB".

get_quote.IB is an adaptation of code that Jeff sent to the r-sig-finance mailing list. This function will connect to IBrokers and download recent market data for one or many instruments. It will try to connect with clientId 1000. If unsuccessful, it will try again with clientId 1001, and finally, clientId 9999. (the clientIds are arbitrary.) Once connected, it will request market data and then disconnect. IB does not give values for ‘Last’, ‘LastSize’, or ‘Volume’ for exchange_rates (twsCASH), so those columns will not be included if any of the instruments for which you are requesting a quote are exchange_rates.

All instruments should be defined before requesting quotes with src="IB", but if any of the requested symbols are not names of previously defined instruments, they will be treated as stocks denominated in ‘USD’. Internally, the stock instrument will be temporarily created to make the request, and subsequently removed.

Value

data.frame with columns: ‘BidSize’, ‘BidPrice’, ‘AskPrice’, ‘AskSize’. If none of the quotes are for exchange_rates, it will also contain the columns ‘Last’, ‘LastSize’, and ‘Volume’

Author(s)

Garrett See, but the bulk of this comes from Jeff Ryan. See references.

References

http://www.mail-archive.com/r-sig-finance@stat.math.ethz.ch/msg00927.html

See Also

get_quote.yahoo

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
define_stocks(c("SPY","DIA"))
fut <- front_future(c("ES","YM"))
get_quote(ls_twsInstruments())
get_quote(ls_stocks(),src='yahoo')
define_FX('EURUSD')
get_quote(ls_twsInstruments()) #will not include trade related data because EURUSD doesn't have it

## End(Not run)

gsee/twsInstrument documentation built on May 17, 2019, 8:55 a.m.