[R-SIG-Finance] Monthly Midpoint return

Phil Steel steelsteel25 at outlook.com
Wed Jun 17 16:23:02 CEST 2015




Hi Brian and everybody else, 
its downloaded stock prices I want to transform to middle of month stock price.
endpoints give end of month doesn't it?if Im using endpoints I get a really strange result with a lot of NA:s My Data starts with the 15:th som my idea it transforming the data to.monthly somehow
My function is ("provided" by Ulrich): 
monthly = function(x){  sym <- sub("\\..*$", "", names(x)[1])  Ad(to.monthly(x, indexAt = 'lastof', drop.time = TRUE, name = sym))}

best regards,Phillip
> Subject: Re: [R-SIG-Finance] Monthly Midpoint return
> From: brian at braverock.com
> To: steelsteel25 at outlook.com
> CC: r-sig-finance at r-project.org
> Date: Wed, 17 Jun 2015 07:37:31 -0500
> 
> On Wed, 2015-06-17 at 12:10 +0000, Phil Steel wrote:
> > Sorry for bothering you all with this idiotic question but I can't find a simple way to go forward.
> > I can't manage to get the midpoint monthly returns from an daily price xts object.I know how to get monthly endpoints by using "to.monthly()"  but I can't figure how to transform the daily object to monthly midpoint. Lets say the midpoint is the first day trading day around the 15:th in a month or every 30:th day.
> > Anybody have encounter this "problem" and/or have a solution.
> 
> I'm not entirely sure I understand your question.  
> 
> If you want the mean/median of the monthly series, or any other
> calculable stat, you can use period.apply.
> 
> If you want a particular point in time, like the 15th of each month,
> then use 'endpoints' or subset the index to get the points you're
> looking for.
> 
> Regards,
> 
> Brian
> 
> 
> -- 
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock
> 

 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list