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
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user