[R-SIG-Finance] positions in timeSeries object

spencerg spencer.graves at prodsyse.com
Tue May 19 02:43:56 CEST 2009


      You need first "install.packages('RSiteSearch')". 

      Then "library(RSiteSearch);  tD <- 
RSiteSearch.function('timeDate')" should work. 

      Spencer

Sarkar, Arup wrote:
> Spencer: If you could forward the solution to my problem I would be
> grateful. I am still stuck at the same problem.
>
> Regards
> Arup
>
> -----Original Message-----
> From: Sarkar, Arup [mailto:arupsarkar at yahoo.com] 
> Sent: Monday, May 11, 2009 11:05 PM
> To: 'spencerg'
> Cc: 'r-sig-finance at stat.math.ethz.ch'
> Subject: RE: [R-SIG-Finance] positions in timeSeries object
>
> Spencer: Thanks very much for the response, I did install RSiteSearch,
> however when I am trying out 
> tD <- RSiteSearch.function('timeDate') command I am getting the following
> error.
>
>   
>> tD <- RSiteSearch.function('timeDate')
>>     
> Error: could not find function "RSiteSearch.function"
>  Do I have to install anything else?
>
> Regards
> Arup
>
> -----Original Message-----
> From: spencerg [mailto:spencer.graves at prodsyse.com] 
> Sent: Saturday, May 09, 2009 4:17 PM
> To: Sarkar, Arup
> Cc: r-sig-finance at stat.math.ethz.ch
> Subject: Re: [R-SIG-Finance] positions in timeSeries object
>
>       First you need to examine the results of each step to isolate the 
> problem. 
>
>
>       When I tried to replicate your problem, I first replaced 
> "as.data.frame(scan(...))" with the following: 
>
>
> DF <- read.table('ibm1.txt', header=TRUE, sep='|')
>
>
>       I also replaced "df" by "DF", because "df" is the function for the 
> density of an F distribution, and I'd prefer not to mask that with a 
> data.frame. 
>
>
>       After that, I solved the problem by studying the examples in the 
> help file for "timeDate". 
>
>
>       To get there, however, I found that there were two functions 
> called "timeDate", in packages "timeDate" and "fCalendar".  I found this 
> as follows: 
>
>
> library(RSiteSearch)
> tD <- RSiteSearch.function('timeDate')
> sum(tD$Function=='timeDate')
> HTML(tD[tD$Function=='timeDate', ])
>
>
>      These two functions are probably identical, but I don't know that. 
>      
>       Hope this helps. 
>       Spencer Graves
>
> Sarkar, Arup wrote:
>   
>> 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]]
>>
>> _______________________________________________
>> R-SIG-Finance at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only.
>> -- If you want to post, subscribe first.
>>
>>   
>>     
>
>



More information about the R-SIG-Finance mailing list