Hi
Thank you all for a great and very useful thread. Do you know if there is
a package that can help to access the same type of information than
stockSymbols fort the London stock exchange ? i.e download of price and
market caps ? I am working on a Black & Litterman project and would like to
somehow automatise a reverse optimisation of the expected returns for each
sectors For this, I need to download the market caps per stock/sector as
well as the closing price...any help / pointer would be appreciated.
Thks
Pierre
-----Original Message-----
From: R-SIG-Finance [mailto:r-sig-finance-bounces at r-project.org] On
Behalf Of Marco Sun
Sent: 24 February 2015 13:55
To: Isak Engdahl
Cc: r-sig-finance at r-project.org
Subject: Re: [R-SIG-Finance] Quantmod Yahoo ticker download error
Hi Isak,
I have checked your scripts and there is no error reported on my platform.
getSymbols correctly downloads historical prices for `ZB-PA`
library(quantstrat)
all.symbols <-
stockSymbols(c("NYSE"),sort.by=c("MarketCap","Exchange"),quiet=TRUE)
biggest.symbols <- tail(all.symbols,n=5) clean.symbols <-
subset(biggest.symbols, select =
c("Symbol","Name","LastSale","MarketCap","Sector"))
row.names(clean.symbols) <- NULL
i=1 #trying i=1 instead of doing the entire loop symbol <-
clean.symbols[i,]$Symbol try (getSymbols(symbol, verbose=FALSE,
warnings=FALSE, from='2015-01-01'))
[1] "ZB-PA
And a dataframe named `df` can also be constructed via your script
df = data.frame(Date=index(get(symbol)), coredata(get(symbol)))
I would recommend you to update `quantmod` package if it is not the latest
released version on your console.
Best,
Marco
On 24 Feb 2015, at 08:33 pm, Isak Engdahl <isak.engdahl at gmail.com> wrote:
it will work both with ZB-PA and ZBK.
Maybe this forum is not the correct place to suggest this improvement,
please point me in right direction.
Maybe someone can help me out to fix this script error?
My script stop writing to the database if one of these tickers get this
error described above (no data exist for symbol ZB-PA to be stored in the
database. Anyone know how to ignore tickers that get this error so the
script can continue to load all tickers that has downloaded data?
Please find attached scripts.
Error when trying to download ticker data from Yahoo Finance for ZB-PA.
=================================
"Downloading ZB-PA
Error in download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=",
In addition: Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
InternetOpenUrl failed: 'The operation timed out'
, error - did not download (likely due to rate limiting Downloading
ZBK Warning message:
In download.file(paste(yahoo.URL, "s=", Symbols.name, "&a=", from.m, :
downloaded length 1653 != reported length 200
=============================
========================================
# Save data to MySQL
library(RMySQL)
con <- dbConnect(RMySQL::MySQL(), host="localhost",
user="donedge",password="p at ssw0rd", dbname= "daily")
# Loop through each symbol
for (i in 1:nrow(clean.symbols)){
+ symbol <- clean.symbols[i,]$Symbol
+ df = data.frame(Date=index(get(symbol)), coredata(get(symbol)))
+
+ setNames(df,c("Date","Open","High","Low","Close","Volume","Adjusted"
+ ))
+
+ cat("Storing",symbol,"\n")
+
+ if(dbExistsTable(con, symbol)){
+ dbRemoveTable(con, symbol)
+ }
+
+ dbWriteTable(con, name=symbol, value=df, row.names=FALSE,
+ overwrite = TRUE)
+
+ }
Error in get(symbol) : object 'ZB-PA' not found
========================================
Kind Regards
Isak
<downloadData.R><mysqlData.R><init.R>_________________________________