R 中的金融交易
Ilya Kipnis
Professional Quantitative Analyst and R programmer
quantstrat 需要 initDate、from 和 to 三个日期。
YYYY-MM-DD,如 "2000-01-01"
initdate <- "1999-01-01"
from <- "2003-01-01"
to <- "2015-12-31"
# 设置系统时区:
Sys.setenv(TZ = "UTC")
# 设置货币(此处用 USD):
currency("USD")
# 获取金融数据:
getSymbols("LQD", from = from, to = to,
src = "yahoo", adjust = TRUE)
# 作为普通股票处理
stock("LQD", currency = "USD", multiplier = 1)
initDate = "1999-01-01"
from = "2003-01-01"
to = "2015-12-31"
Sys.setenv(TZ = "UTC")
currency("USD")
getSymbols("LQD", from = from, to = to, src = "yahoo",
adjust = TRUE)
R 中的金融交易