- ago
Hi Team,

I’ve encountered a significant performance issue after adding an intraday strategy to my MetaStrategy. The MetaStrategy previously comprised multiple daily strategies and ran relatively quickly, approximately 3-5 times slower than the sum of individual strategy durations when run separately. However, after introducing an intraday strategy that operates on 1-minute intervals and executes very infrequently (around 50 trades in 20 years), the MetaStrategy execution times became extremely slow. It eventually hanged, requiring me to terminate WealthLab through the Dispatcher Server after several hours.

Here are the details of my setup:

Strategies:
DailyStrategy (SPY, daily)
IntradayStrategy (SPY, 1 min)

Test Period: 20 years of SPY data

Trades: Both strategies perform only one trade.

The code:

CODE:
   public class MyStrategy : UserStrategyBase    {       public MyStrategy()             {       }       public override void Initialize(BarHistory bars)       {       }       public override void Execute(BarHistory bars, int bar)       {          ClosePosition(LastPosition, OrderType.MarketClose);          if (bar == 1)             PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose);       }    }


I ran the following tests to isolate the issue, and here are the results for the second and subsequent runs in the same WealthLab instance (loading times excluded):

Individual DailyStrategy: <1 sec
Individual IntradayStrategy: 11 sec
Total for both separately: 12 secs

However, when combining them in a MetaStrategy, the performance degrades significantly:

MetaStrategy (1 x DailyStrategy, 1 x IntradayStrategy): 86 sec
MetaStrategy (2 x DailyStrategy, 1 x IntradayStrategy): 150 sec
MetaStrategy (3 x DailyStrategy, 1 x IntradayStrategy): 260 sec
MetaStrategy (4 x DailyStrategy, 1 x IntradayStrategy): 368 sec
MetaStrategy (5 x DailyStrategy, 1 x IntradayStrategy): 548 sec

The computational overhead seems to increase disproportionately, suggesting a potential inefficiency in how MetaStrategy handles the combination of daily and intraday data.

Could you please investigate this issue?

Thank you for your assistance!

UPDATE: if you combine 5 intrday strategies the performance is also dismal, if combine 5 daily strategies - everything is fine.
0
279
Solved
4 Replies

Reply

Bookmark

Sort
Glitch8
 ( 12.53% )
- ago
#1
It doesn't look out of the ordinary. It has to do allot of synchronization of intraday and daily data at that point, and a one-minute Strategy has MANY bars of data. I can't investigate now because recovering from a hurricane.
0
- ago
#2
Thank you for your response.

I completely understand the challenges you're facing, especially after a hurricane, and appreciate you taking the time to reply.

Based on my previous experience with performance optimization as a developer, I see two potential synchronization points:

* Synchronization of bars
* Synchronization of signals/trades

Given that we're dealing with only 6 trades across 5 daily strategies and 1 intraday strategy, it seems unlikely that syncing the trades alone would cause such a significant delay. This leads me to believe that the primary performance issue might be related to the synchronization of bars.

In theory, if bars are being synchronized via a structure like a hashtable or dictionary (with DateTime as a key), instances of the same strategy (e.g., multiple Daily strategies) should reference the same bars, which should make synchronization relatively fast. However, based on the results, it appears that the synchronization process grows non-linearly in complexity, consuming the majority of processing time.

From my experience, profiling can usually pinpoint the suboptimal function quickly, often within seconds. This suggests that optimizing the synchronization process could lead to significant performance improvements, potentially by orders of magnitude, even if it requires some trade-offs in memory usage.

Thank you again for your time and efforts, especially given the difficult circumstances. I hope everything recovers smoothly after the hurricane.

Wishing you all the best!
0
Glitch8
 ( 12.53% )
- ago
#3
Thanks for understanding Pavel.

Good news is that our power was restored last night so things are getting back to normal.

Back to the topic, could the performance of daily + intraday Strategies in the MetaStrategy somehow be optimized and improved? I'm thinking maybe. But I don't think the performance now is so bad that it justifies ripping up the architecture of WL8. I think this is something we keep in mind for an eventual larger scale overhaul that we periodically do. So, I think it makes sense to spend resources on this once we start the larger scale move to WL9.
0
Best Answer
- ago
#4
Understood, thank you very much Glitch! If you require any support on the issue (reproduction, testing and so on), just let me know.

I hope you and your loved ones are safe, and that life returns to normal as soon as possible. Wishing you strength and a smooth recovery after the hurricane.
0

Reply

Bookmark

Sort