[R-SIG-Finance] New to R and Finance, backtest etc.

Brian G. Peterson brian at braverock.com
Sun Jun 19 13:53:44 CEST 2011


The slide code should work, but the full Faber demo is available with
either

demo('faber')

or you can find the file in the demos directory or here:

https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/quantstrat/demo/faber.R?root=blotter

If you have problems with the demo code, we'll try to sort it out.

Regards,

   - Brian

On Sun, 2011-06-19 at 13:40 +0200, Alex Grund wrote:
> Hi Julien,
> 
> thank you for the link to Brian Peterson's work. I played around with
> the code, but some things do not work correctly.
> Maybe you know, how to fix them:
> 
> The main problem is caused by this line:
> 
> `  out <- try(applyStrategy(strategy='s' , portfolios='faber'))
> 
> which, obviously, is the most important line :-) The error message I get is:
> 
> `  Error in if (length(j) == 0 || (length(j) == 1 && j == 0)) { :
> `  Fehlender Wert, wo TRUE/FALSE nötig ist (translates to: "Missing
> value, where TRUE/FALSE is required")
> 
> Since I did not modify the code from the PDF I think this may be a bug
> in the software or a missing line of code in the PDF.
> However, help is really appreciated!
> 
> "tradeStats('faber')" of course, returns NULL.
> "chart.Posn('faber')" gives this error:
> `  Fehler in .Internal(get(x, envir, mode, inherits)) : 'x' fehlt
> (translates to: error in ~: 'x' missing)
> 
> However, I have a veriable called x in my workspace, which is
> displayed with "ls()", and it's non-empty:
> 
> `  > x[1]
> `             XLU.Open XLU.High XLU.Low XLU.Close XLU.Volume XLU.Adjusted
> `  1998-12-31    30.25    30.83   29.64     30.23     162900        20.12
> 
> 
> Thank you very much!
> 
> Alex.
> 
> 
> 2011/6/19 julien cuisinier <J_Cuisinier at hotmail.com>:
> > Hi Alex,
> >
> > www.rinfinance.com/agenda/2011/BrianPeterson.pdf
> >>> reference main packages you will ever need I think... & as mentioned in
> >>> previous feedback quantmod is excellent & think quantstrat better (i,e, more
> >>> widely used) than the "backtest" package that I personally do not know
> >>> and in general RFinance conference papers, could be good to throw a
> >>> glance at them...
> > http://www.statmethods.net/
> >>> very well done (in my humble opinion) website for intro into R, its main
> >>> data type etc..
> > HTH,
> > Julien
> >
> >
> >
> > On Jun 18, 2011, at 5:16 PM, Alex Grund wrote:
> >
> > Hi there,
> >
> > I am new to R and want to perform a few experiments with trading strategies
> > with R.
> >
> > However, I have experience in programming, but not in R (it's very similar
> > to what a programmer would expect).
> >
> > For now, I've parsed some data (Open, High, Low, Close) of a security via
> > read.table, which works fine.
> > What I want to do now, is to perform a backtest of a simple trading strategy
> > with R. Say, for example "buy on cross of MA(200) and MA(100)". Of course I
> > could write the backtest routine by myself, but I saw a package called
> > backtest. However, I do not really get the point how this may work. How
> > could I use backtest package to analyse a simple strategy as above?
> >
> > Additionally, I would like to know, if there are some websites, wikis etc.
> > which give a basic introduction to R in Finance "for dummies"? Anything I've
> > seen so far was more or less for professionals.
> >
> >
> > Thank you in advance
> > Alex
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > 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.
> >
> >
> >
> 
> _______________________________________________
> 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.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list