<div dir="ltr"><div>Bom dia,</div><div><br></div><div>Os valores variam ainda que utilizada a mesma função. A razão para isso deve estar na programação da API do Yahoo. O fato é que os valores não são "errados" pois se relacionam à "timestamps" ligeiramente diferentes. Um mesmo "timestamp" terá o mesmo valor (veja na saída abaixo).</div><div><br></div><div>O "timestamp" nesse caso é a data convertida em segundos, tomando por origem "1970-01-01".</div><br><div><font face="monospace, monospace">### <code r></font></div><div><div><span style="font-family:monospace,monospace">url0 <- "<a href="http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv">http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv</a>"</span><br></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">page1 <- readLines(url0); t1 <- Sys.time()</font></div><div><font face="monospace, monospace">t1; head(read.csv(text=page1, skip = 17, header = FALSE), 3)</font></div><div><font face="monospace, monospace"># [1] "2015-03-25 08:45:49 AMT"</font></div><div><font face="monospace, monospace">#           V1     V2     V3      V4     V5     V6</font></div><div><font face="monospace, monospace"># 1 1427203800 127.15 127.26 127.000 127.23 654800</font></div><div><font face="monospace, monospace"># 2 1427203879 126.92 127.19 126.875 127.15 179100</font></div><div><font face="monospace, monospace"># 3 1427203979 126.90 127.06 126.870 126.91 198000</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">page2 <- readLines(url0); t2 <- Sys.time()</font></div><div><font face="monospace, monospace">t2; head(read.csv(text=page2, skip = 17, header = FALSE), 3)</font></div><div><font face="monospace, monospace"># [1] "2015-03-25 08:46:11 AMT"</font></div><div><font face="monospace, monospace">#           V1     V2     V3       V4     V5     V6</font></div><div><font face="monospace, monospace"># 1 1427203859 127.19 127.26 127.0796 127.20 622100</font></div><div><font face="monospace, monospace"># 2 1427203918 126.92 127.19 126.8750 127.18 205200</font></div><div><font face="monospace, monospace"># 3 1427203979 126.90 127.06 126.8700 126.91 204600</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">### Transformando timestamp em datas</font></div><div><font face="monospace, monospace">as.POSIXct(c(1427203800, 1427203859), origin="1970-01-01")</font></div><div><font face="monospace, monospace">as.POSIXct(c(1427203879, 1427203918), origin="1970-01-01")</font></div></div><div><font face="monospace, monospace">### </code></font></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">Éder Comunello <<a href="mailto:comunello.eder@gmail.com" target="_blank">c</a><a href="mailto:omunello.eder@gmail.com" target="_blank">omunello.eder@gmail.com</a>> <br>Dourados, MS - [22 16.5'S, 54 49'W]<br></div></div></div>
<br><div class="gmail_quote">Em 24 de março de 2015 13:40, Michelle Bau Graczyk <span dir="ltr"><<a href="mailto:mbgraczyk@gmail.com" target="_blank">mbgraczyk@gmail.com</a>></span> escreveu:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Boa tarde,<div><br></div><div>Eu estava verificando os diferentes modos de coletar dados intraday do yahoo e percebi que para cada função que eu uso, os dados obtidos são diferentes.</div><div><br></div><div>Por exemplo, se eu uso:</div><div><br></div><div>dados <- readLines('<a href="http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv" target="_blank">http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv</a>',sep = ",", dec = ".")<br></div><div><br></div><div>eu obtenho:</div><div><div>"18" "1427203800,127.1800,127.2600,127.0000,127.2300,631900"</div><div>"19" "1427203868,126.9200,127.1900,126.8750,127.1700,202000"</div><div>"20" "1427203920,126.9600,127.0600,126.8700,126.9100,189500"</div><div>"21" "1427203981,126.9500,126.9900,126.8800,126.8900,198200"</div><div>"22" "1427204099,126.7799,126.9900,126.7700,126.9500,217500"</div><div>"23" "1427204100,126.6700,126.9000,126.6401,126.7799,286300"</div><div>"24" "1427204219,126.7100,126.8000,126.6500,126.6800,222800"</div><div>"25" "1427204221,126.8300,126.8700,126.5600,126.7000,238500"</div><div>"26" "1427204280,126.7100,126.9200,126.6700,126.8200,167500"</div><div>"27" "1427204340,126.8300,126.9300,126.7000,126.7166,114900"</div><div>"28" "1427204457,126.6400,126.8300,126.6000,126.8100,156100"</div><div>"29" "1427204460,126.6500,126.7900,126.6385,126.6900,102800"</div></div><div><br></div><div>se eu uso:</div><div>dados <- getURL('<a href="http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv" target="_blank">http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv</a>',sep = ",", dec = ".")<br></div><div>obtenho:</div><div><br></div><div><div>1427203805,127.1900,127.2600,127.0796,127.2000,626100</div><div>1427203862,126.9200,127.1900,126.8750,127.1800,207800</div><div>1427203979,126.9000,127.0600,126.8700,126.9100,198000</div><div>1427203980,126.9500,126.9900,126.8800,126.9000,172200</div><div>1427204099,126.7799,126.9900,126.7700,126.9500,235000</div><div>1427204100,126.6700,126.9000,126.6401,126.7799,286300</div><div>1427204219,126.7100,126.8000,126.6500,126.6800,222800</div><div>1427204221,126.8300,126.8700,126.5600,126.7000,238500</div><div>1427204280,126.7100,126.9200,126.6700,126.8200,167500</div><div>1427204340,126.8300,126.9300,126.7000,126.7166,114900</div><div>1427204459,126.6915,126.8300,126.6100,126.8100,160900</div><div>1427204460,126.6500,126.7900,126.6385,126.6900,98000</div></div><div><br></div><div>Usando read.csv também dá dados diferentes de começo.</div><div><br></div><div>Alguem saberia me dizer o por que? E em qual devo confiar? Porque nenhuma é igualzinha ao que aparece quando você coloca esse endereço <a href="http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv" target="_blank">http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv</a> no navegador. O resultado deste é:</div><div><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">1427203800,127.1200,127.2300,127.0000,127.2300,631900
1427203900,127.0300,127.1900,127.0000,127.1700,87400
1427203978,126.9200,127.0400,126.8700,126.9050,309600
1427204038,126.9600,126.9900,126.8800,126.9399,174900
1427204099,126.7799,126.9900,126.7700,126.9600,235300
1427204100,126.6700,126.9000,126.6401,126.7799,286300
1427204219,126.7100,126.8000,126.6500,126.6800,222800
1427204221,126.8300,126.8700,126.5600,126.7000,238500
1427204280,126.7100,126.9200,126.6700,126.8200,167500
1427204340,126.8300,126.9300,126.7000,126.7166,114900
1427204459,126.6915,126.8300,126.6000,126.8100,160900
1427204460,126.6500,126.7900,126.6385,126.6900,98000
1427204520,126.7100,126.7200,126.6000,126.6500,108700
1427204581,126.7100,126.8400,126.6800,126.7100,129600
1427204641,126.7400,126.7700,126.6600,126.7300,98700</pre><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap"><br></pre><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">Obrigada,</pre><pre style="color:rgb(0,0,0);word-wrap:break-word;white-space:pre-wrap">Michelle</pre></div><div><br></div></div>
<br>_______________________________________________<br>
R-br mailing list<br>
<a href="mailto:R-br@listas.c3sl.ufpr.br">R-br@listas.c3sl.ufpr.br</a><br>
<a href="https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br" target="_blank">https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br</a><br>
Leia o guia de postagem (<a href="http://www.leg.ufpr.br/r-br-guia" target="_blank">http://www.leg.ufpr.br/r-br-guia</a>) e forneça código mínimo reproduzível.<br></blockquote></div><br></div>