title: How to fetch 3-years historical price serie from Oanda with R?
body: <p>I would like to process Bitcoin price in R but I'm unable to download time serie from Yahoo and Google. </p>
  
  <p>From <a href="http://finance.yahoo.com/q?s=BTCUSD=X" rel="nofollow">Yahoo</a> the BTCUSD historical time serie is missing and the Google doesn't recognize the URL formated by <code>getSymbols</code> when symbol is "CURRENCY:EURUSD". I know R expect the ":" to be a list so I applied a workaround I found in Stakeoverflow to turn CURRENCY:EURUSD in CURRENCY.EURUSD but still Google cannot process the request.</p>
  
  <p>Download from Oanda works like a charm but request cannot exceed 500 days. I try this workaround to bypass the limitation but it fails to populate correctly the <code>prices</code> object in which I have others symbols :</p>
  
  <ul>
  <li>for some reason BTCUSD prices are missing for 2012 and part of 2013 </li>
  <li>also there are symbols from symbols's list that get NA with the wo.</li>
  </ul>
  
  <p><code>tail(prices)</code> (with the loop bellow)</p>
  
  <pre><code>             UUP    FXB    FXE    FXF   FXY   SLV    GLD     BTC
  2014-08-31    NA     NA     NA     NA    NA    NA     NA 506.809
  2014-09-30 22.87 159.33 124.48 102.26 88.80 16.35 116.21 375.386
  2014-10-31 23.09 157.20 123.49 101.45 86.65 15.50 112.66 341.852
  2014-11-30    NA     NA     NA     NA    NA    NA     NA 378.690
  2014-12-31 23.97 153.06 119.14  98.16 81.21 15.06 113.58 312.642
  2015-01-24    NA     NA     NA     NA    NA    NA     NA 229.813
  </code></pre>
  
  <p>Extract of <code>print(prices)</code> (with the loop bellow)</p>
  
  <pre><code>2013-06-28 22.56 150.17 128.93 103.92 98.63 18.97 119.11      NA
  2013-07-31 22.09 150.12 131.74 105.99 99.93 19.14 127.96      NA
  2013-08-30 22.19 152.93 130.84 105.45 99.63 22.60 134.62      NA
  2013-09-30 21.63 159.70 133.85 108.44 99.47 20.90 128.18 133.794
  2013-10-31 21.63 158.10 134.29 108.03 99.38 21.10 127.74 203.849
  2013-11-30    NA     NA     NA     NA    NA    NA     NA 1084.800
  2013-12-31 21.52 163.30 135.99 109.82 92.76 18.71 116.12 758.526
  2014-01-31 21.83 161.95 133.29 108.00 95.58 18.45 120.09 812.097
  </code></pre>
  
  <p><code>tail(prices)</code> (without the loop bellow)</p>
  
  <pre><code>             UUP    FXB    FXE    FXF   FXY   SLV    GLD
  2014-08-29 22.02 163.23 129.54 106.42 93.61 18.71 123.86
  2014-09-30 22.87 159.33 124.48 102.26 88.80 16.35 116.21
  2014-10-31 23.09 157.20 123.49 101.45 86.65 15.50 112.66
  2014-11-28 23.47 153.46 122.46 101.00 82.01 14.83 112.11
  2014-12-31 23.97 153.06 119.14  98.16 81.21 15.06 113.58
  2015-01-23 25.21 147.23 110.33 110.95 82.57 17.51 124.23
  </code></pre>
  
  <p>What is wrong with this code ? Tx !</p>
  
  <pre><code>require(quantmod)
  require(PerformanceAnalytics)
  
  symbols &lt;- c(
    "UUP",
    "FXB",
    "FXE",
    "FXF",
    "FXY",
    "SLV",
    "GLD"
  )
  
  getSymbols(symbols, from="2004-01-01")
  
  prices &lt;- list()
  for(i in 1:length(symbols)) {
    prices[[i]] &lt;- Cl(get(symbols[i]))  
  }
  
  BTC &lt;- list()
  for(i in 1:2) {
    BTC[[1]] &lt;- getFX("BTC/USD",
                         from = Sys.Date() -499 * (i + 1),
                         to = Sys.Date() - 499 * i,
                         env = parent.frame(),
                         auto.assign = FALSE)
  }
  BTC[[1]] &lt;- getFX("BTC/USD",
                    from = Sys.Date() -499,
                    to = Sys.Date(),
                    env = parent.frame(),
                    auto.assign = FALSE)
  
  prices[[length(symbols)+1]] &lt;- BTC[[1]]
  prices &lt;- do.call(cbind, prices)
  
  colnames(prices) &lt;- gsub("\\.[A-z]*", "", colnames(prices))
  ep &lt;- endpoints(prices, "months")
  
  prices &lt;- prices[ep,]
  prices &lt;- prices["1997-03::"]
  </code></pre>