I'd like to show you how to use R to get global stock prices.
it is freaking easy.
just enter following code to get S&P 500 index.
getSymbols('^GSPC', src='yahoo')
plot(GSPC)
It's too easy, isnt it?
If you trying to find out Nvida's stock price, then enter NVDA instead of ^GSPC.
nvda <- auto.assign="FALSE)</p" getsymbols="" src="yahoo">plot(nvda)
->
Sorted
*Additional information
Free financial data
1) R package quantmod
:yahoo(stock information) / google(stock data)
:FRED(economic indicators)
:Oanda(FX data)
example) Oanda
getSymbols("USD/EUR",src="oanda")
plot(USDEUR)
2) R package Quandl (not all free but some of them are free)
example) Quandl
Let's get oil price and draw a graph
install.packages("Quandl")
library(Quandl)data = Quandl("OPEC/ORB")
library(Quandl)data = Quandl("OPEC/ORB")
3) R package TFX which provides real time tick data
Sample)
install.packages("TFX")
QueryTrueFX()
yen <- span=""> ConnectTrueFX("USD/JPY,EUR/JPY,GBP/JPY,AUD/JPY,CAD/JPY,CHF/JPY",
username="ID", password="PW")
QueryTrueFX(yen)->
QueryTrueFX()
yen <- span=""> ConnectTrueFX("USD/JPY,EUR/JPY,GBP/JPY,AUD/JPY,CAD/JPY,CHF/JPY",
username="ID", password="PW")
QueryTrueFX(yen)->
4) R package pwt which provides global economic data
Sample)
install.packages("pwt8")
library("pwt8")
data("pwt8.0")
countries <- c="" div="">->
variables <- c="" country="" div="" isocode="" nbsp="" pop="" rgdpo="" year="">->
pwt <- countries="" in="" isocode="" pwt8.0="" select="variables)</div" subset="">->
summary(pwt)
country isocode
Spain :62 ESP :62
Italy :62 ITA :62
United States of America:62 USA :62
Angola : 0 AGO : 0
Albania : 0 ALB : 0
Argentina : 0 ARG : 0
(Other) : 0 (Other): 0
year rgdpo
Min. :1950 Min. : 85002
1st Qu.:1965 1st Qu.: 439149
Median :1980 Median : 1107030
Mean :1980 Mean : 2722070
3rd Qu.:1996 3rd Qu.: 3536036
Max. :2011 Max. :13193478
5) R package - rdatamarket
-reference-
http://blog.naver.com/htk1019/220902013375
http://blog.naver.com/htk1019/220902013375
0 Comment to "How to collect price in R"
Post a Comment