@@ -389,7 +389,7 @@ private bool LoadCashBalance(IBrokerage brokerage, IAlgorithm algorithm)
389
389
return true ;
390
390
}
391
391
392
- private bool LoadExistingHoldingsAndOrders ( IBrokerage brokerage , IAlgorithm algorithm , SetupHandlerParameters parameters )
392
+ protected bool LoadExistingHoldingsAndOrders ( IBrokerage brokerage , IAlgorithm algorithm , SetupHandlerParameters parameters )
393
393
{
394
394
Log . Trace ( "BrokerageSetupHandler.Setup(): Fetching open orders from brokerage..." ) ;
395
395
try
@@ -417,9 +417,10 @@ private bool LoadExistingHoldingsAndOrders(IBrokerage brokerage, IAlgorithm algo
417
417
Log . Trace ( "BrokerageSetupHandler.Setup(): Has existing holding: " + holding ) ;
418
418
419
419
// verify existing holding security type
420
- if ( ! algorithm . Securities . TryGetValue ( holding . Symbol , out var security ) )
420
+ Security security ;
421
+ if ( ! algorithm . Securities . TryGetValue ( holding . Symbol , out security ) )
421
422
{
422
- if ( ! AddUnrequestedSecurity ( algorithm , holding . Symbol , holding . Type ) )
423
+ if ( ! AddUnrequestedSecurity ( algorithm , holding . Symbol , holding . Type , out security ) )
423
424
{
424
425
continue ;
425
426
}
@@ -461,15 +462,16 @@ private bool LoadExistingHoldingsAndOrders(IBrokerage brokerage, IAlgorithm algo
461
462
return true ;
462
463
}
463
464
464
- private bool AddUnrequestedSecurity ( IAlgorithm algorithm , Symbol symbol , SecurityType securityType )
465
+ private bool AddUnrequestedSecurity ( IAlgorithm algorithm , Symbol symbol , SecurityType securityType , out Security security )
465
466
{
466
- if ( ! algorithm . Securities . TryGetValue ( symbol , out Security security ) )
467
+ if ( ! algorithm . Securities . TryGetValue ( symbol , out security ) )
467
468
{
468
469
if ( ! _supportedSecurityTypes . Contains ( ( SecurityType ) securityType ) )
469
470
{
470
471
Log . Error ( "BrokerageSetupHandler.Setup(): Unsupported security type: " + securityType + "-" + symbol . Value ) ;
471
472
AddInitializationError ( "Found unsupported security type in existing brokerage holdings: " + securityType + ". " +
472
473
"QuantConnect currently supports the following security types: " + string . Join ( "," , _supportedSecurityTypes ) ) ;
474
+ security = null ;
473
475
return false ;
474
476
}
475
477
@@ -525,9 +527,10 @@ protected void GetOpenOrders(IAlgorithm algorithm, IResultHandler resultHandler,
525
527
foreach ( var order in openOrders . OrderByDescending ( x => x . SecurityType ) )
526
528
{
527
529
// verify existing holding security type
528
- if ( ! algorithm . Securities . TryGetValue ( order . Symbol , out var security ) )
530
+ Security security ;
531
+ if ( ! algorithm . Securities . TryGetValue ( order . Symbol , out security ) )
529
532
{
530
- if ( ! AddUnrequestedSecurity ( algorithm , order . Symbol , order . SecurityType ) )
533
+ if ( ! AddUnrequestedSecurity ( algorithm , order . Symbol , order . SecurityType , out security ) )
531
534
{
532
535
// keep aggregating these errors
533
536
continue ;
0 commit comments