Skip to content

data generation fails because SecurityService now requires _algorithm to be non-null #9186

@grantr

Description

@grantr

Expected Behavior

lean data generate generates market data

Actual Behavior

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at QuantConnect.Securities.SecurityService.InitializeSecurity(Boolean initializeSecurity, Security security, Boolean seedSecurity) in
/LeanCloud/CI.Builder/bin/Release/src/QuantConnect/Lean/Common/Securities/SecurityService.cs:line 346

Potential Solution

This was introduced in #9045. The line if (seedSecurity && _algorithm.Settings.SeedInitialPrices) needs to check if _algorithm is null before using its Settings value.

I confirmed this fix worked by building lean locally and running lean data generate:

if (seedSecurity && _algorithm != null && _algorithm.Settings.SeedInitialPrices)

Reproducing the Problem

lean data generate --start=20260101 --symbol-count=1

Or any lean data generate call will do it.

System Information

Ubuntu 20.04.1 from inside WSL2

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions