Add securities when trading non added securities (#9312)
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled

* Add securities when trading non added securities

* Minor tests fixes

* Minor test fix

* Minor test fixes

* Minor fixes

* Minor test fix

* Minor fix
This commit is contained in:
Jhonathan Abreu
2026-03-03 17:09:21 -04:00
committed by GitHub
parent 9573eea52e
commit 04993e2e2a
9 changed files with 454 additions and 40 deletions
@@ -31,8 +31,10 @@ class StringToSymbolImplicitConversionRegressionAlgorithm(QCAlgorithm):
Arguments:
data: Slice object keyed by symbol containing the stock data
'''
try:
self.market_order("PEPE", 1)
except Exception as exception:
if "PEPE was not found" in str(exception) and not self.portfolio.invested:
self.set_holdings("SPY", 1)
ticket = self.market_order("PEPE", 1)
if ticket.status != OrderStatus.Invalid:
raise Exception(f"Expected order to be invalid since PEPE is not a valid ticker, but was {ticket.status}")
if not self.portfolio.invested:
self.set_holdings("SPY", 1)