My first comment is excellent work! I am new to QuantConnect and have been using this project to learn. I have a question however: What is the utility of the variable _assignedOption?
It is being used only 3 times.
1x in the class declaration:
private bool _assignedOption = false;
And 2x in the OnData function:
if (_assignedOption)
{
// can't figure out Linq Portfolio.Where(x => x.Value.Invested).Foreach(x => {}) ??
foreach (Securities.SecurityHolding holding in Portfolio.Values)
{
if (holding.Invested)
{
Liquidate(holding.Symbol);
}
}
_assignedOption = false;
}
So, my question is, how is the code segment in OnData that is executed when _assignedOption is true ever triggered?
It seems this is a bug. And what is happening is that instead of liquidating the symbol here, all of the stock position is being liquidated in the close_options:
if (Portfolio[this.equity_symbol].Invested)
{
Liquidate(equity.Symbol);
}
I am not sure of the effect, but I don't think this is the behavior that is expected.