- ago
Hi,

I ran a test strategy on an IB paper account. After the At-Close run, the strategy deactivated itself and threw the following error message:

Exception: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

Here's the strategy and how I scheduled it. It's running on a small data set consisting of 10 stocks.








Here's the log:

28.01.2025 22:18:55: Status = LoadingData
28.01.2025 22:18:55: Start Polling Thread
28.01.2025 22:18:55: Populating Data
28.01.2025 22:18:55: Calling GetHistories Pass 1
28.01.2025 22:18:56: GetHistories returned with 10 symbols
28.01.2025 22:18:56: Calling GetHistories Pass 2
28.01.2025 22:18:56: GetHistories returned with 10 symbols
28.01.2025 22:18:56: BA:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BBY:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BAX:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BAC:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BK:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BDX:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BALL:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BIIB:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BG:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: BEN:100 bars to 20250127 0000|Yahoo! Finance
28.01.2025 22:18:56: NextRun set to 29.01.2025 21:10
28.01.2025 22:18:56: Status = Idle
29.01.2025 21:10:00: Status = Processing
29.01.2025 21:10:01: Ran Strategy on BIIB,BBY,BG,BEN,BAX,BALL,BK,BA,BDX,BAC: 10 Signals, Run Time=680ms
29.01.2025 21:10:01: NextRun set to 30.01.2025 15:15
29.01.2025 21:10:01: Status = Completed
29.01.2025 21:10:01: Processed all Symbols
29.01.2025 21:10:01: Exception: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
29.01.2025 21:10:01: Status = Deactivated
29.01.2025 21:10:01: Leaving Polling Thread


The exception occurs in the third-to-last line.

One other minor thing: After activating the strategy (28.01.2025 22:18:55), it scheduled the next run for 29.01.2025 21:10 (the At-Close run), but the regular pre-open run was skipped.

The strategy runs fine in the backtester, so this only happens in live execution.

Any ideas on what might be causing this?

Thanks!
0
337
Solved
9 Replies

Reply

Bookmark

Sort
Cone8
 ( 3.65% )
- ago
#1
QUOTE:
One other minor thing: After activating the strategy (28.01.2025 22:18:55), it scheduled the next run for 29.01.2025 21:10 (the At-Close run), but the regular pre-open run was skipped.
Thanks for this. It's not that minor. The case is that your "after market" run is scheduled the next day before the market open. We need to fix that case. For now, you'll need to "Run Now" before the open or schedule the after market run after 4pm.

Re: the exception
Which Data Providers are checked in your list of Historical Providers?

You need a provider capable of returning partial Daily bars. I think Y! should be able to, but you'd be better off using IB or another reliable Daily source for trading.
0
- ago
#2
Thanks, Cone, for your response!

(1) The 'minor' thing:
I've noticed this effect with other test strategies as well. It skips the pre-open run only the first time after scheduling, but on the following days, the pre-open run executes as expected. That’s why I considered it "minor." However, it does mean you lose one day each time you schedule it, which makes testing especially lengthy.

(2) The exception:
In the list of Historical Providers, IB is first, WealthData second, and Yahoo third. I'll try changing the order and/or using a different data provider in the strategy monitor to see if that helps.

By the way, why is it the Historical Providers and not the Streaming Providers that count here?
0
Cone8
 ( 3.65% )
- ago
#3
(1) The 'minor' thing:
Thanks for the details. That helps.
>> Fixed for Build 111

(2) The exception:
Hmmm, we'll try to duplicate it to see where the problem is.

QUOTE:
By the way, why is it the Historical Providers and not the Streaming Providers that count here?
Because At-Close Processing actually appends a full [but partial] Daily bar to the BarHistory.
0
Cone8
 ( 3.65% )
- ago
#4
Re: (2) The exception:
We've got a handle on this one. Will also be fixed for Build 111.

Hey, thanks for the reports!
0
Best Answer
- ago
#5
Thanks for looking into it. Appreciate the quick response!
0
- ago
#6
I also get similar index out of bound error in strategy monitor for a few strategies. They run fine if I just open the strategy and run backtest on them.
0
Cone8
 ( 3.65% )
- ago
#7
We've got this fixed for Build 111, but the problem is a bug dealing with NamedSeries for At-Close Processing.

If it's practical to temporarily switch to a Data Provider other than Yahoo!, then you won't have a problem. (Some Yahoo! symbols have NamedSeries "AdjustedClose" attached - and I'm not sure why some do and others don't.)

With a C# Coded strategy you can probably avoid this bug right now by adding this Remove statement to Initialize() -
CODE:
public override void Initialize(BarHistory bars) {          bars.NamedSeries?.Remove("AdjustedClose"); }
0
- ago
#8
@Cone I think I do not use Yahoo for the strategies, and they do not have at Close processing. I'll provide some info later, not with my computer rn.
0
Cone8
 ( 3.65% )
- ago
#9
Please start a different thread with your report then, because it's not the same as this one.
0

Reply

Bookmark

Sort