I usually use Exhaustive optimization as it's much faster. Several days ago I switched to Non-parallel, as one of my strategies uses Pre-Execute. Then I returned the settings to the original Exhaustive.
I have Core i9 13980HX processor with 24 physical cores and 32 threads.
When I run the following simple strategy:
On SPY, 20 last years.
I get the following stats:
1. Non-parallel: 68 seconds
2. Parallel: 57 seconds.
So parallel calculations almost don't work. I tried to change the selection several times, no luck.
Task manager shows 2.5-3.5% CPU load by WL8 in parallel mode.
What can be wrong?
Thank you
I have Core i9 13980HX processor with 24 physical cores and 32 threads.
When I run the following simple strategy:
CODE:
public class TestParallel : UserStrategyBase { public TestParallel() { AddParameter("Fake param", ParameterType.Int32, 1, 1, 100, 1); } public override void Execute(BarHistory bars, int bar) { if (HasOpenPosition(bars, PositionType.Long)) PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose); if (!HasOpenPosition(bars, PositionType.Long)) PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose); } } }
On SPY, 20 last years.
I get the following stats:
1. Non-parallel: 68 seconds
2. Parallel: 57 seconds.
So parallel calculations almost don't work. I tried to change the selection several times, no luck.
Task manager shows 2.5-3.5% CPU load by WL8 in parallel mode.
What can be wrong?
Thank you
Rename
The Exhaustive Optimizer uses a .NET Parallel.ForEach using the following code:
The second parameter is an instance of ParallelOptions, which controls how many cores are used. We have a utility class called ParallelUtils that queries the OS to return the appropriate value. You can run a Strategy like this to examine the value, what does it print in the Debug output?
Note: You'll need to enable System.Threading.Tasks.Parallel in the WL8 Assembly References tool.
CODE:
Parallel.ForEach<List<double>>(pl.GetValuesEnumerator(), ParallelUtils.ParallelOptions, item => {
The second parameter is an instance of ParallelOptions, which controls how many cores are used. We have a utility class called ParallelUtils that queries the OS to return the appropriate value. You can run a Strategy like this to examine the value, what does it print in the Debug output?
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using System.Threading.Tasks; namespace WealthScript1 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) { ParallelOptions po = ParallelUtils.ParallelOptions; WriteToDebugLog("Cores=" + po.MaxDegreeOfParallelism); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here } } //declare private variables below } }
Note: You'll need to enable System.Threading.Tasks.Parallel in the WL8 Assembly References tool.
Thank you for the debugging instructions. I believe the problem was caused by some wrong Windows configuration and your solution would have identified the problem.
Unfortunatelly I couldn't repro the issue anymore.
Whole story: I have Win11, my laptop's Intel mainboard died, I moved SSDs to an old laptop with AMD, then my Intel laptop was fixed, I returned SSDs, and the problem appeared (but I didn't realize it was connected). As Win11 had AMD drivers installed, I believe that there were some problems with CPU parallel options. It didn't appear in any other apps, except for WL8. I restored Win11 from a backup prior to putting SSDs to the AMD laptop, so it's clean and fine now. With no other actions the same processing takes only 3-4 seconds.
Now the result is as expected:
Thank you very much!
Unfortunatelly I couldn't repro the issue anymore.
Whole story: I have Win11, my laptop's Intel mainboard died, I moved SSDs to an old laptop with AMD, then my Intel laptop was fixed, I returned SSDs, and the problem appeared (but I didn't realize it was connected). As Win11 had AMD drivers installed, I believe that there were some problems with CPU parallel options. It didn't appear in any other apps, except for WL8. I restored Win11 from a backup prior to putting SSDs to the AMD laptop, so it's clean and fine now. With no other actions the same processing takes only 3-4 seconds.
Now the result is as expected:
CODE:
---Symbol by Symbol Debug Logs--- ---SPY--- Cores=31
Thank you very much!
That's quite a difference, glad things are running smoothly now!
Your Response
Post
Edit Post
Login is required