@@ -419,7 +419,7 @@ private bool LoadExistingHoldingsAndOrders(IBrokerage brokerage, IAlgorithm algo
419
419
// verify existing holding security type
420
420
if ( ! algorithm . Securities . TryGetValue ( holding . Symbol , out var security ) )
421
421
{
422
- if ( AddUnrequestedSecurity ( algorithm , holding . Symbol , holding . Type ) == null )
422
+ if ( ! AddUnrequestedSecurity ( algorithm , holding . Symbol , holding . Type ) )
423
423
{
424
424
continue ;
425
425
}
@@ -461,7 +461,7 @@ private bool LoadExistingHoldingsAndOrders(IBrokerage brokerage, IAlgorithm algo
461
461
return true ;
462
462
}
463
463
464
- private Security AddUnrequestedSecurity ( IAlgorithm algorithm , Symbol symbol , SecurityType securityType )
464
+ private bool AddUnrequestedSecurity ( IAlgorithm algorithm , Symbol symbol , SecurityType securityType )
465
465
{
466
466
if ( ! algorithm . Securities . TryGetValue ( symbol , out Security security ) )
467
467
{
@@ -470,7 +470,7 @@ private Security AddUnrequestedSecurity(IAlgorithm algorithm, Symbol symbol, Sec
470
470
Log . Error ( "BrokerageSetupHandler.Setup(): Unsupported security type: " + securityType + "-" + symbol . Value ) ;
471
471
AddInitializationError ( "Found unsupported security type in existing brokerage holdings: " + securityType + ". " +
472
472
"QuantConnect currently supports the following security types: " + string . Join ( "," , _supportedSecurityTypes ) ) ;
473
- return null ;
473
+ return false ;
474
474
}
475
475
476
476
var resolution = algorithm . UniverseSettings . Resolution ;
@@ -504,7 +504,7 @@ private Security AddUnrequestedSecurity(IAlgorithm algorithm, Symbol symbol, Sec
504
504
security = algorithm . AddSecurity ( symbol . SecurityType , symbol . Value , resolution , symbol . ID . Market , fillForward , leverage , extendedHours ) ;
505
505
}
506
506
}
507
- return security ;
507
+ return true ;
508
508
}
509
509
510
510
/// <summary>
@@ -525,18 +525,15 @@ protected void GetOpenOrders(IAlgorithm algorithm, IResultHandler resultHandler,
525
525
foreach ( var order in openOrders . OrderByDescending ( x => x . SecurityType ) )
526
526
{
527
527
// verify existing holding security type
528
- if ( ! supportedSecurityTypes . Contains ( order . SecurityType ) )
528
+ if ( ! algorithm . Securities . TryGetValue ( order . Symbol , out var security ) )
529
529
{
530
- Log . Error ( "BrokerageSetupHandler.Setup(): Unsupported security type: " + order . SecurityType + "-" + order . Symbol . Value ) ;
531
- AddInitializationError ( "Found unsupported security type in existing brokerage open orders: " + order . SecurityType + ". " +
532
- "QuantConnect currently supports the following security types: " + string . Join ( "," , supportedSecurityTypes ) ) ;
533
-
534
- // keep aggregating these errors
535
- continue ;
530
+ if ( ! AddUnrequestedSecurity ( algorithm , order . Symbol , order . SecurityType ) )
531
+ {
532
+ // keep aggregating these errors
533
+ continue ;
534
+ }
536
535
}
537
536
538
- // Add the security before adding the order to ensure the subscription exists
539
- var security = AddUnrequestedSecurity ( algorithm , order . Symbol , order . SecurityType ) ;
540
537
transactionHandler . AddOpenOrder ( order , algorithm ) ;
541
538
order . PriceCurrency = security ? . SymbolProperties . QuoteCurrency ;
542
539
0 commit comments