Created
March 4, 2013 16:36
-
-
Save kevin3/5083555 to your computer and use it in GitHub Desktop.
R code to retrieve the trading range for a stock on a historical date using quantmod library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library('quantmod') | |
#loadSymbols of the stock codes you are interested in | |
loadSymbols(c('K17.SI','BN4.SI')) | |
#retrieves the values for a single date | |
BN4.SI['2013-01-25'] | |
#K17.SI['2013-03-04'] | |
#Convert the matrix retrieved as a data.frame for easier data usage | |
=kep=as.data.frame(BN4.SI['2013-01-25']) | |
#Calculates the Trading Range for the specified date | |
TradingRange=kep['BN4.SI.High']-kep['BN4.SI.Low'] | |
TradingRange |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment