Hi: I am trying the following code to incorporate positions in the time
series object. Can some please help me.

 

Data File Format:

 

SYMBOL|DATE|EX|TIME|PRICE|SIZE|COND|CORR|G127

IBM|11/03/2008|N|9:30:07|93.0800|73600|@|0|0

IBM|11/03/2008|N|9:30:07|92.9700|500|@|0|0

IBM|11/03/2008|N|9:30:07|93.1100|100|@|0|0

IBM|11/03/2008|N|9:30:07|92.9700|100|@|0|0

IBM|11/03/2008|N|9:30:07|92.8500|200|@|0|0

IBM|11/03/2008|N|9:30:07|92.8200|100|@|0|0

IBM|11/03/2008|N|9:30:08|92.7500|100|@|0|0

IBM|11/03/2008|N|9:30:08|92.7500|100|@|0|0

IBM|11/03/2008|N|9:30:08|92.7500|100|@|0|0

IBM|11/03/2008|N|9:30:08|92.7500|100|@|0|0

IBM|11/03/2008|N|9:30:08|92.7500|100|@|0|0

IBM|11/03/2008|N|9:30:08|93.0000|100|@|0|0

 

R script:

 

## Columns Names

fields.list =
list(Symbol="",Date="",Ex="",Time="",Price=0,Size=0,Cond="",Corr=0,G127=0)

#create a data frame

df =
as.data.frame(scan(file="c:/ibm_1.txt",what=fields.list,sep="|",skip=1,multi
.line=TRUE,strip.white=TRUE),stringsAsFactors=F)

dates.tmp = timeDate(charvec = df[, "Date"])

times.tmp = df[, "Time"]

td.tmp = paste(dates.tmp,times.tmp, sep=" ")

ans = timeSeries(data = df[, setdiff(colIds(df), c("Date","Time"))],pos =
td.tmp)

 

I am getting the following output when I am using the following command
ans[1:5, ]

 

       Symbol Ex  Price   Size      Cond Corr G127

     1 "IBM"  "N" "93.08" "  73600" "@"  "0"  "0" 

     2 "IBM"  "N" "92.97" "    500" "@"  "0"  "0" 

     3 "IBM"  "N" "93.11" "    100" "@"  "0"  "0" 

     4 "IBM"  "N" "92.97" "    100" "@"  "0"  "0" 

     5 "IBM"  "N" "92.85" "    200" "@"  "0"  "0"

 

I want to have the following output, how can I achieve it. Any help is
highly appreciated.

 

     Positions  Symbol Ex  Price   Size      Cond Corr G127

      "11/03/2008 9:30:07" "IBM"  "N" "93.08" "  73600" "@"  "0"  "0" 

     "11/03/2008 9:30:07" "IBM"  "N" "92.97" "    500" "@"  "0"  "0" 

     "11/03/2008 9:30:07" "IBM"  "N" "93.11" "    100" "@"  "0"  "0" 

     "11/03/2008 9:30:07" "IBM"  "N" "92.97" "    100" "@"  "0"  "0" 

     "11/03/2008 9:30:07" "IBM"  "N" "92.85" "    200" "@"  "0"  "0"

 


	[[alternative HTML version deleted]]

