Maximize/minimize output of weighted inputs

조회 수: 7 (최근 30일)
Scott
Scott 2014년 5월 9일
편집: Matt J 2014년 5월 14일
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에서 Econometrics Toolbox에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by