Converting a loop into vector operation - trading strategy
조회 수: 3 (최근 30일)
이전 댓글 표시
I am writing a trading strategy in MATLAB. At certain points dictated by an input array the trades are to be closed/opened. Also there is a stop loss parameter that can only close the trade. Currently I am using a while loop to go through each entry of the array which takes a lot of time for larger data sets. Are there any MATLAB functions that can speed up the process or there is any way I can convert the loop to vector operations speeding up the process?
댓글 수: 1
AC
2012년 7월 4일
Hi, I am not sure I get your question, would you please add a sample of your code along with more explanation of what you are trying to do?
답변 (1개)
Daniel Shub
2012년 7월 4일
In general MATLAB loops are no longer "slow". You need to figure out what is taking the time in your loop. The profiler can help with this, but you might also want to use tic/toc. Once you figure out what is taking the most time, you can optimize that.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!