RFinanceYJ Sample

library(xts)
## Loading required package: zoo
## Attaching package: 'zoo'
## 以下のオブジェクトはマスクされています (from 'package:base') :
## 
## as.Date, as.Date.numeric
library(XML)
library(ggplot2)
library(scales)
library(RFinanceYJ)

株価情報の取得

d <- quoteStockTsData("2432.t", "2012-01-01")
g <- quoteStockTsData("3632.t", "2012-01-01")
d$stock.code <- "2432.t"
g$stock.code <- "3632.t"
dg <- rbind(d, g)

y.limits <- c(0, max(dg$close))
ggplot(dg, aes(x = date, y = close, col = stock.code)) + geom_point() + geom_line() + 
    scale_y_continuous(label = comma, limits = y.limits) + theme_bw(16)

plot of chunk unnamed-chunk-2

FX情報の取得

fx <- quoteFXTsData("USDJPY=X")

y.limits <- c(0, max(fx$close))
ggplot(fx, aes(x = date, y = close)) + geom_point() + geom_line() + scale_y_continuous(label = comma, 
    limits = y.limits) + theme_bw(16)

plot of chunk unnamed-chunk-3

Fundの取得

fund <- quoteFundTsData("11311023")

y.limits <- c(0, max(fund$constant.value))
ggplot(fund, aes(x = date, y = constant.value)) + geom_point() + geom_line() + 
    scale_y_continuous(label = comma, limits = y.limits) + theme_bw(16)

plot of chunk unnamed-chunk-4