Maximize/minimize output of weighted inputs

2 次查看(过去 30 天)
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...

采纳的回答

Matt J
Matt J 2014-5-9
编辑:Matt J 2014-5-9
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 个评论
Scott
Scott 2014-5-14
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 2014-5-14
编辑:Matt J 2014-5-14
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Genetic Algorithm 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by