About strategy execution times
Author: akuzn
Creation Date: 4/9/2012 7:18 AM
profile picture

akuzn

#1
Good day!
I use intraday 1 minute stragies and they are sensitive to execution time.
Unfortunately if i use 200 bars data range strategies execution time takes about 400 ms.
At the middle of the day strategy execution takes already 1900 ms and it s already big timeout.
I can see already 430 bars showed in strategy window. Use of strategy monitor is very useful but doesnt solve this problem of slowing speed of strategy execution.
But if i press button "Go" below strategy time frame, position etc preferences i admit that wealth lab starts to recompute series in 200 data range. That's what i need and expect from it.
So the question is - is there any method to use to set up wealth to compute only desired data range?
Thanks in advance.
profile picture

Eugene

#2
The difference that pressing the Go button makes is that your Strategy isn't recompiled (class level variables aren't reset etc). A better idea is to find the bottleneck in your code, i.e. what makes it slow down in geometrical progression when more bars are added.

There are visual tools called profilers, some of them are free. You might want to check this FAQ out: Is there a way to profile Wealth-Lab 6 Strategies i.e. measure application/script performance?
profile picture

Cone

#3
1. For live trading you need to run your strategy only on the number of bars required to enter your last "live" position. In other words, if your live account is holding a position, the script needs to have entered that Position in order to exit it.

2. If, for example, you only want the strategy to always run on the last 200 bars, then the for loop would simply be this:
CODE:
Please log in to see this code.

That said, a strategy that takes 400ms to run on 200 bars sounds like a problem, or at a minimum, the code could probably be speed optimized.
profile picture

akuzn

#4
Thanks.
I understand this difference.
I ve optimized many methods in my code but i realised adaptive rules - they need to do some limited cycles and they dont exceed 170 bars. ( really 170 * N * M calculations - here starts the real power of WealthLab with C#).
Certainly i will refuse later to calculate some Math.Pow and other statistics. Without them i have about 5-8% of speed improvement.
But if press "Go" that means i reset something and and my strategy without recompiling starts to use only these 200 bars. Is there any possibility to setup to compute only specified data range without additional bars?

I mean bars wich are stored in DataSeries object(variable) like
DataSeries atr ATR.Series (...) etc

Certainly i can press Go twice or 4 times a day but it sounds like 1000 years before new age)
profile picture

Cone

#5
Right. Striking F5, clicking Go, or changing Scale, Position Size, etc. will reload the chart data, re-initializing to the data loading settings.

QUOTE:
Is there any possibility to setup to compute only specified data range without additional bars?
You can use the Value method (not the Series method) for the indicators that offer it. ATR, for example, would not have a Value method because it's basically an IIR filter that needs to be calculated from the beginning of the series for it to be accurate.
profile picture

akuzn

#6
Thank you for help - i revised my cycle and found how to improve speed but not to much.

Always wanted to ask but didnt have convenient situation.
Just to confirm - If i understand You right if i use value method that means i ll have computing only for period and other parameters range if needed - not full DataSeries range?
profile picture

Cone

#7
That's correct (provided that the Value method is implemented as intended).
profile picture

festipower

#8
Hi.

If you want to drastically improve your Wealth-Lab strategies execution time and optimize its parameters HUNDRED OF TIMES faster than with Wealth-Lab native method, please, check our BTUtils for Wealth-Lab toolset.

BTUtils for Wealth-Lab speed-ups strategy execution without the need to modify your code.


Carlos pérez
https://www.domintia.com
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).