Learn R Programming

dang (version 0.0.16)

intradayMarketMonitor: Intra-day market monitor

Description

Intra-day Market Monitor for Security Prices

Usage

intradayMarketMonitor(symbol = "^GSPC", defaultTZ = "America/Chicago",
  sleep = 10)

Value

Nothing is returned, but a display of the current price and the recent history is updated, and the loops loops ‘forever’.

Arguments

symbol

A character variable with symbol understood by getQuote from package quantmod, default value is “^GSPC”.

defaultTZ

A character variable with the (local) timezone used for displaying the data, default value is “America/Chicagp”.

sleep

An optional numerical value for the delay between updates, default is 10.

Author

Dirk Eddelbuettel extending and refactoring the original code by Josh Ulrich

Details

This function periodically queries a public data source for a current price of given symbol and updates an intra-daily chart for that security. A working example is symbol “^GSPC” for the S&P500 index which can be obtained in real-time during (New York) trading hours. Other symbols may work.

An alternate version offering 24-hour coverage, for example for futures on Globex, is being prepared.

The function could be further generalized in numerous way and should be considered ‘alpha’. Current default values are a 15 second sleep, and fixed cut-off times for market open/close states corresponding to NYSE hours. The data history is reset to the two most recent days at the close, amd the data is snapshot to file (with the filename derived from the symbol, and the path given by tools::R_user_dir). These parameters might become configuration parameters in the future.

See Also

Examples

Run this code
if (requireNamespace("quantmod", quietly)) {           # only suggested packages used
   suppressMessages({library(xts);library(quantmod)})  # dampen noise, add dang as needed
   intradayMarketMonitor()
}

Run the code above in your browser using DataLab