Maximize/minimize output of weighted inputs

2 visualizaciones (últimos 30 días)
Scott
Scott el 9 de Mayo de 2014
Editada: Matt J el 14 de Mayo de 2014
I am trying to find an efficient method to "optimize" a result given a set if inputs and weights e.g. a stock trading strategy. I can use brute force to test every possible combination of weights for the inputs, but the processing is intense and slow. I have heard of genetic algorithms, neural networks and optimisation but really don't know too much more about them. I am not trading the stock market myself, but using this as learning example.
My example "system": I have four numeric inputs (i) from "technical indicators" of the price time series data normalized [0, 1], I weight (w) each input [-1, 1] and then sum the values: Y = (w1*i1) + (w2*i2) + (w3*i3) + (w4*i4);
For "trading": If Y>0 then BUY, otherwise SELL. The result of this trading will yield a return R; the idea for now is to find what weights return the highest R. I also have other metrics which describe the "success" of the system that I would also like to test, such as maxmizing profit/loss, minimizing drawdown etc, but I'll start here for now.
If I set up the problem:
tic
for w1=-1:0.1:1
for w2=-1:0.1:1
for w3=-1:0.1:1
for w4=-1:0.1:1
% evaluate results of trading
% compare to previous results
% if "better" then store w1,w2,w3,w4 else discard result
end
end
end
end
toc
On my computer this processing will take about 8 hours; is there a better way? Of course, if I add more inputs, the scale of the problem and the processing time will become unmanageable.
Optimisation newbie, so please be gentle...

Respuesta aceptada

Matt J
Matt J el 9 de Mayo de 2014
Editada: Matt J el 9 de Mayo de 2014
Depends a lot on what R as a function of w looks like. LINPROG might be appropriate if the dependence of R on w is linear.
  8 comentarios
Scott
Scott el 14 de Mayo de 2014
Sorry about the delay in thanking you for the answer (computer died!)
The solution you offered didn't exactly solve my issue, but it gave me a big shove in the right direction! Thanks. I'm still working on figuring why the outputs are different from my code, but that is something I can work on in my own time. I also run into a memory issue if I try to use an input data set longer than 300 points, but again, I can work on these issues in my own time.
Matt J
Matt J el 14 de Mayo de 2014
Editada: Matt J el 14 de Mayo de 2014
I'm still working on figuring why the outputs are different from my code
Possibly because there are multiple/infinite solutions, see the 2nd last paragraph in my last comment. Where the maxR's the same? If not, who's was higher?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by