I have been trying to get information on how to use local files to create candlecharts but most of them refer to yahoo and google files.
I have a CSV file
i<-"A"
library(quantmod)
A<-read.csv("D:\\DATA.csv",header=T)
A$Close<-as.numeric(A$Close)
A$High<-as.numeric(A$High)
A$Low<-as.numeric(A$Low)
A$Open<-as.numeric(A$Open)
A$Volume<-as.numeric(A$Volume)
#Select appropriate dataset
A<-A[which(A$CODE==i),]
A<-A[,(5:10)]
A$DATE<-as.Date(A$DATE,"%Y/%d/%Y")
A<-xts(A,order.by=as.POSIXct(A$DATE))
A<-A[,(1:5)]
My original DATASET is as below:
head(A)
CODE NAME YR2 YR2 Low High Close Open Volume DATE
49620 A A 10.25 21 112 120 116 101,500 9/11/2006
49621 A A 10.25 21 112 120 118 116 790,700 9/12/2006
49622 A A 10.25 21 117 124 119 118 445,300 9/13/2006
49623 A A 10.25 21 119 127 123 119 120,200 9/14/2006
49624 A A 10.25 21 120 127 124 123 448,700 9/15/2006
49625 A A 10.25 21 120 130 128 124 494,600 9/18/2006
##NOTE THAT THE FIRST COLUMNS DOES NOT HAVE A NAME(IT IS THE OBS NO.)
After running the above commands the dataset is as shown below.
head(A)
Low High Close Open Volume
2006-12-01 03:00:00 " 206" " 231" " 228" " 232" "1159"
2006-12-01 03:00:00 " 204" " 230" " 206" " 229" "5711"
2006-12-02 03:00:00 " 259" " 261" " 259" " 260" "1072"
2006-12-02 03:00:00 " 200" " 229" " 207" " 229" "1505"
2006-12-03 03:00:00 " 262" " 264" " 262" " 260" "5416"
2006-12-03 03:00:00 " 204" " 227" " 206" " 208" " 676"
I then created modified the colnames to the required formats My dataset after all modification is as shown below.
A.Low A.High A.Close A.Open A.Volume
2006-12-01 03:00:00 " 206" " 231" " 228" " 232" "1159"
2006-12-01 03:00:00 " 204" " 230" " 206" " 229" "5711"
2006-12-02 03:00:00 " 259" " 261" " 259" " 260" "1072"
2006-12-02 03:00:00 " 200" " 229" " 207" " 229" "1505"
2006-12-03 03:00:00 " 262" " 264" " 262" " 260" "5416"
2006-12-03 03:00:00 " 204" " 227" " 206" " 208" " 676"
I am stuck here because when I save it the dataset changes completely such that when I try to read it I get:
Index.A.Low.A.High.A.Close.A.Open.A.Volume
1 2006-12-01 03:00:00 206 231 228 232 1159
2 2006-12-01 03:00:00 204 230 206 229 5711
3 2006-12-02 03:00:00 259 261 259 260 1072
4 2006-12-02 03:00:00 200 229 207 229 1505
5 2006-12-03 03:00:00 262 264 262 260 5416
6 2006-12-03 03:00:00 204 227 206 208 676
My problems are:
- Dates are not original dates in the dataset
- I am unable to get what I needed to do (draw the candlecharts)