[R-SIG-Finance] Are there genetic algorithm for trading strategy evolution in R?

Enrico Schumann enricoschumann at yahoo.de
Fri Mar 9 07:33:54 CET 2012



Am 08.03.2012 19:16, schrieb Michael:
> Thanks folks!
>
> After digging further on the Internet, I have the following
> questions:
>
> Q1: I read the following article:
>
> http://cran.r-project.org/web/packages/DEoptim/vignettes/DEoptimPortfolioOptimization.pdf
>
>  It seems that there are a bunch of parameters in this optimizer and
> the results are sensitive to these parameters.
>
> So there is another layer of optimization with respect to these
> optimizer parameters.
>
> Is the "tweaking" of these optimizer parameters data-mining, which
> will lead to data-snooping bias?

No. You need to distinguish between your optimisation model on the one 
hand, and the numerical technique you use to solve the model on the 
other. And Differential Evolution (DE) is a numerical technique. If your 
model overfits, it is because of the model, not the optimisation 
technique. Suppose you wanted to estimate a linear regression, with the 
mean squared residual as the criterion of fit. Now you can compute a 
solution via QR; or if you use DE *properly*. it will give you exactly 
the same fit (up to numerical precision). Whether the model overfits, 
depends on how you set up the model, how you select the data in the 
model -- it has nothing to do with the numerical technique.

>
> Q2: Due to the random nature of the optimizer, each time you run the
> backtest, you will have different performance.
>
> What do you do in that case?

There is only one way to find out: run experiments. Put an outer loop 
around your backtest in which repeat your analysis; then you can see how 
the stochastic nature of the optimisation affects your results. In my 
view, it's not a problem: see for instance this paper

http://ssrn.com/abstract=1420058

And experiments are also the only reliable way to find out if your 
optimisation technique works properly. All described in detail in this 
book (of which I happen to be a co-author)

@BOOK{Gilli2011b,
   title = {Numerical Methods and Optimization in Finance},
   publisher = {Academic Press},
   year = {2011},
   author = {Gilli, Manfred and Maringer, Dietmar and Schumann, Enrico}
}


>
> So for out-of-sample real-trading, we are trading a random strategy?

No, again: model vs optimisation. Eventually, you have to accept some 
set of parameters for your optimisation and use these to trade.

>
> Q3: It's pretty easy to understand using Genetic Algorithms to serve
> as a replacement for regular optimizers;
>
> but using Genetic Algorithms to evolve trading strategies seem to be
> different. Anywhere we could find such an example in R?
>

What you probably mean is Genetic Programming, not Genetic Algorithms.



Regards,
Enrico

-- 
Enrico Schumann
Lucerne, Switzerland
http://nmof.net


>
>
>
> On Thu, Mar 8, 2012 at 8:25 AM, Zachary Mayer<zach.mayer at gmail.com>
> wrote:
>
>> There is the
>> DEoptim<http://cran.r-project.org/web/packages/DEoptim/index.html>library
>> in r, which is an excellent library for differential evolution.
>> If you can define your trading strategy in terms of a bunch of
>> parameters to adjust and an objective function (i.e. turn it into
>> an optimization problem), DEoptim will help you find the minimum
>> (or maximum).
>>
>> DEoptim works well on non-differentiable problems with many local
>> minima. Here is an example of using it to solve a portfolio
>> optimization problem:
>>
>> http://cran.r-project.org/web/packages/DEoptim/vignettes/DEoptimPortfolioOptimization.pdf
>>
>>
>>
>>
>>
On Thu, Mar 8, 2012 at 12:43 AM, Sofian 
Hadiwijaya<reztinpeace at gmail.com>wrote:
>>
>>> how about quantmod library..
>>>
>>> On Wed, Mar 7, 2012 at 10:30 PM, Michael<comtech.usa at gmail.com>
>>> wrote:
>>>
>>>> Hi all, Good morning, good afternoon and good evening!
>>>>
>>>> Could anybody please kindly point me to resources in R which
>>>> shows about how to use Genetic algorithm to evolve trading
>>>> strategies?
>>>>
>>>> I did a lot search on Google these days and certainly it's a
>>> well-covered
>>>> and popular topic, but I don't see anywhere in R...
>>>>
>>>> Thanks a lot!
>>>>
>



More information about the R-SIG-Finance mailing list