Similar to another post I read, this exercise fails even if I view the solution and copy/paste into my answer and submit. I see the following errors in my log file.
1880 | 16:29:21: Boot Camp: Looks like you aren't allocating securities and liquidating appropriately...
1881 | 16:29:22: Boot Camp: Exercise failed. Please try again..
This is the key event handler for security changes.
public override void OnSecuritiesChanged(SecurityChanges changes)
{
_changes = changes;
Log($"OnSecuritiesChanged({UtcTime}):: {changes}");
foreach (var security in changes.RemovedSecurities)
{
if (security.Invested)
{
Liquidate(security.Symbol);
}
}
//2. Now that we have more leverage, set the allocation to set the allocation to 18% each instead of 10%
foreach (var security in changes.AddedSecurities)
{
SetHoldings(security.Symbol, 0.18m);
}
}