Description Usage Arguments Details Value Note Author(s) References See Also Examples
View source: R/getQuote.BATS.R
getQuote.BATS
is a
getQuote
"method" for BATS,
although it may be called directly.
1 2 3 4 5 6 7 8 9 10 11 12 13 | getQuote.BATS(Symbols,
what = c("bats", "bbo", "ladder", "depth", "trades"),
exch = c("bzx", "byx", "opt"))
getQuote.bats(Symbols,
what = c("bats", "bbo", "ladder", "depth", "trades"),
exch = c("bzx", "byx", "opt"))
ladder(x)
trades(x)
depth(x, ...)
|
Symbols |
a vector of ticker symbols. If length is
greater than 1, a list will be returned unless
|
what |
character. What to return. See details |
exch |
character. "bzx" or "byx". ("opt" is completely untested and most likely does not work) |
x |
a bats object |
... |
pass through arguments |
This downloads data from BATS for a given stock and
exchange and parses it into a list using
fromJSON
. By default
(what="bats"
), this list is given a class of
bats
and returned. Currently, the other values for
what
just specify how to reformat/subset the data.
With what="bbo"
, a data.frame
will be
returned with a row for each of the Symbols
and
columns "BidSize", "BidPrice", "AskPrice", "AskSize",
"Last", "LastSize" (any of those columns that are all NA
are omitted; e.g. when the market is closed the returned
data.frame
will likely only have the "TradeTime",
"Last" and "LastSize" columns.
If what="ladder"
, an object of class ladder
is returned. It will be a matrix
at its core with
3 columns: BidQty, Price, AskQty. The Price column is
from highest to lowest. There should only be a BidQty or
an AskQty at a given price, and the other will be NA
(otherwise, the market would be crossed). An object of
class ladder
will also have the following
attributes: "timestamp", "company", "volume",
"last.price", and "last.qty"
When called with what="depth"
, an object of class
depth
will be returned which is very similar to a
ladder
object except it has 4 columns and
(usually) no NAs. Instead of stacking the prices on top
of each other, they are side-by-side. A depth
object is a matrix
at its core and has 4 columns:
"BidQty", "BidPrice", "AskPrice", "AskQty". Under usual
market conditions it will have 5 rows. It also has all
the attributes that a ladder
object has.
If what="trades"
, an xts object is returned that
has the "Qty" and "Price" of the last 10 trades.
There are print
methods for bats
,
ladder
, and depth
that make use of
pander::pandoc.table
There are also plot
methods for bats
,
ladder
, and depth
. These make it
incredibly easy to make a nice looking shiny app.
market data. The type of object returned depends on the
value of what
. See Details. If Symbols
is
of length greater than 1 and type is not "bbo", a list
will be returned.
"opt" exch has NOT been TESTED AT ALL
Garrett See
http://www.batstrading.com/market_data/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ## Not run: # can't run the examples because they require internet access
## These should be run while the U.S. stock market is open
getQuote("SPY", src="BATS")
getQuote("SPY", src="BATS", exch="byx")
getQuote("SPY", src="BATS", what="bbo")
getQuote("SPY", src="BATS", what="ladder")
print(getQuote("SPY", src="BATS", what="ladder"), header=FALSE)
getQuote("SPY", src="BATS", what="depth")
getQuote("SPY", src="BATS", what="trades")
plot(getQuote("SPY", src="BATS"))
plot(getQuote("SPY", src="BATS", what="ladder"))
plot(getQuote("SPY", src="BATS", what="depth"))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.