[R-SIG-Finance] Trouble with getSymbols.csv
G See
gsee000 at gmail.com
Tue Sep 18 00:26:30 CEST 2012
This function should really have more formal arguments -- especially
the format argument.
As it is, the `format` will be set to "". You should be able to pass
`format` through the dots, but there's a syntax bug preventing that
from working (`list(...)[["format"]] <- NULL`).
As it is, the only way to load your data using getSymbols.csv is to
set the `format` argument in the Symbol Lookup table. (I saved the
text from your e-mail in a file at "~/tmp/worik.txt")
setSymbolLookup(worik=list(src='csv', format='%Y-%m-%d'))
getSymbols('worik', dir='~/tmp', auto.assign=FALSE, extension='txt')
WORIK.Open WORIK.High WORIK.Low WORIK.Close WORIK.Volume
2011-12-28 1.5968 1.5987 1.5762 1.5827 0
2011-12-29 1.5831 1.5846 1.5695 1.5724 0
2011-12-30 1.5726 1.5877 1.5704 1.5861 0
2011-12-31 1.5850 1.5861 1.5850 1.5861 0
2012-01-01 1.5850 1.5861 1.5820 1.5861 0
2012-01-02 1.5871 1.5875 1.5768 1.5802 0
2012-01-03 1.5800 1.5837 1.5726 1.5818 0
2012-01-04 1.5819 1.5865 1.5796 1.5813 0
2012-01-05 1.5812 1.5854 1.5730 1.5795 0
2012-01-06 1.5796 1.5871 1.5745 1.5859 0
2012-01-07 1.5854 1.5854 1.5782 1.5782 0
2012-01-08 1.5808 1.5866 1.5808 1.5866 0
2012-01-09 1.5867 1.5910 1.5807 1.5815 0
WORIK.Adjusted
2011-12-28 1.58745
2011-12-29 1.57705
2011-12-30 1.57905
2011-12-31 1.58555
2012-01-01 1.58405
2012-01-02 1.58215
2012-01-03 1.57815
2012-01-04 1.58305
2012-01-05 1.57920
2012-01-06 1.58080
2012-01-07 1.58180
2012-01-08 1.58370
2012-01-09 1.58585
HTH,
Garrett
On Mon, Sep 17, 2012 at 4:12 PM, Worik Stanton <worik.stanton at gmail.com> wrote:
> Friends
>
> I have a file of data:
>
> "Date","Open","High","Low","Close","Volume","Adjusted"
> "2011-12-28",1.5968,1.5987,1.5762,1.5827,0,1.58745
> "2011-12-29",1.5831,1.5846,1.5695,1.5724,0,1.57705
> "2011-12-30",1.5726,1.5877,1.5704,1.5861,0,1.57905
> "2011-12-31",1.585,1.5861,1.585,1.5861,0,1.58555
> "2012-01-01",1.585,1.5861,1.582,1.5861,0,1.58405
> "2012-01-02",1.5871,1.5875,1.5768,1.5802,0,1.58215
> "2012-01-03",1.58,1.5837,1.5726,1.5818,0,1.57815
> "2012-01-04",1.5819,1.5865,1.5796,1.5813,0,1.58305
> "2012-01-05",1.5812,1.5854,1.573,1.5795,0,1.5792
> "2012-01-06",1.5796,1.5871,1.5745,1.5859,0,1.5808
> "2012-01-07",1.5854,1.5854,1.5782,1.5782,0,1.5818
> "2012-01-08",1.5808,1.5866,1.5808,1.5866,0,1.5837
> "2012-01-09",1.5867,1.591,1.5807,1.5815,0,1.58585
>
> When I use getSymbols(.., src="csv")
>
> The dates are incorrect. The first date is "2012-09-18"
>
> It seems that in getSymbols.csv uses:
>
> as.Date(fr[, 1], format = format, ..., origin = "1970-01-01")
>
> Looking more closely...
>
>> as.Date("2011-12-28", origin="1970-01-01", format="")
> [1] "2012-09-18"
>
> That is what I see.
>
> But either of...
>> as.Date("2011-12-28", origin="1970-01-01")
> [1] "2011-12-28"
>> as.Date("2011-12-28")
> [1] "2011-12-28"
>>
>
> give me what I expect.
>
> What am I doing wrong?
>
> cheers
> Worik
>
> --
> it does not matter I think that I shall never see
> how much I dig and dig A billboard lovely as a tree
> this hole just Indeed, unless the billboards fall
> keeps getting deeper I'll never see a tree at all
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
More information about the R-SIG-Finance
mailing list