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

Patrick Burns patrick at burns-stat.com
Thu Mar 8 19:51:57 CET 2012


Comments inline.

On 08/03/2012 18:16, Michael wrote:
> 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?

I wouldn't think so, but there might be
a way to manage it.

>
> 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?

That may be a good thing, if you are
willing to use it.

In what I've done on backtesting:

http://www.portfolioprobe.com/2010/11/05/backtesting-almost-wordless/

I show how to assess whether the strategy
is better than luck by using random trades.

The standard thing to assume (as I do in
that piece) is that the optimization is
noiseless.  But really the optimization
depends on a multitude of subtle influences.
Even if you always got the exact global
optimum, if a variance or expected return
were slightly different, you could get a
very different path.  The "optimal" path
is fuzzy in actuality.

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

Yes.  But the inputs are random so even
non-stochastic optimizers give you a
random strategy in a sense.

>
> 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?

Yes, that is different.

In https://stat.ethz.ch/pipermail/r-sig-finance/2010q4/007033.html
you can find Josh quoting me quoting Lao-Tzu
on why you are unlikely to find much useful
on that subject.

Pat

>
>
>
>
> 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!
>>>>
>>>>         [[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.
>>>>
>>>
>>>         [[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.
>>>
>>
>>
>
> 	[[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.
>

-- 
Patrick Burns
patrick at burns-stat.com
http://www.burns-stat.com
http://www.portfolioprobe.com/blog
twitter: @portfolioprobe



More information about the R-SIG-Finance mailing list