[R-SIG-Finance] Downloading historical prices

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Fri Nov 22 18:39:59 CET 2024


On 22 November 2024 at 12:13, Anatoly Schmidt wrote:
| I had to delete the screenshot as my message below violates the size constraint
| imposed by r-sig-finance. It can be seen on the yahoo finance website. 

Yep. And we are not fan of screen shots either.
 
| On Fri, Nov 22, 2024 at 12:07 PM Anatoly Schmidt <as8098 using nyu.edu> wrote:
| 
|     Thank you Dirk,
|     I concluded that yahoo requires premium service after seeing the lock on
|     the download  link. Here is a screenshot. When I click on the lock, yahoo
|     invites me to subscribe a premium service:
| 
| 
|     When I run your example
|     X <- getSymbols("SPY", from="2024-11-01"), 

You can't do the assignment unless you set the option I showed in my initial email.

|     I have the following output:
| 
|     Warning: SPY download failed; trying again.
|     Error in getSymbols.yahoo(Symbols = "SPY", env = <environment>, verbose = FALSE,  :
|       Unable to import “SPY”.
|     SPY download failed after two attempts. Error message: 
| 
|     HTTP error 401.

So we need to debug this.

For kicks, I just installed quantmod and its five depedencies on a fresh r2u
container running Ubuntu 24.04.  No options, no nothing:

  root using d17b04bef87d:/# R -q
  > library(quantmod)
  Loading required package: xts
  Loading required package: zoo
  
  Attaching package: ‘zoo’
  
  The following objects are masked from ‘package:base’:
  
      as.Date, as.Date.numeric
  
  Loading required package: TTR
  Registered S3 method overwritten by 'quantmod':
    method            from
    as.zoo.data.frame zoo 
  > getSymbols("SPY", from="2024-11-01")
  [1] "SPY"
  > SPY
             SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
  2024-11-01   571.32   575.55  570.62    571.04   45667500       571.04
  2024-11-04   571.18   572.50  567.89    569.81   38217000       569.81
  2024-11-05   570.74   576.74  570.52    576.70   39478300       576.70
  2024-11-06   589.20   591.93  585.39    591.04   68182000       591.04
  2024-11-07   593.08   596.65  593.00    595.61   47233200       595.61
  2024-11-08   596.17   599.64  596.17    598.19   46444900       598.19
  2024-11-11   599.81   600.17  597.00    598.76   37586800       598.76
  2024-11-12   598.68   599.29  594.37    596.90   43006100       596.90
  2024-11-13   597.37   599.23  594.96    597.19   47388600       597.19
  2024-11-14   597.32   597.81  592.65    593.35   38904100       593.35
  2024-11-15   589.72   590.20  583.86    585.75   75988800       585.75
  2024-11-18   586.22   589.49  585.34    588.15   37084100       588.15
  2024-11-19   584.71   591.04  584.03    590.30   49412000       590.30
  2024-11-20   590.38   590.79  584.63    590.50   50032600       590.50
  2024-11-21   593.40   595.12  587.45    593.67   46565100       593.67
  > 

So the arrow still points at your setup. 

Dirk


-- 
dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the R-SIG-Finance mailing list