I'm a newbie and I have a strategy that needs to close any open positions at market close. I would figure that the OnEndOfDay() event would help make this happen, but after reading the post at the link below, I am confused about whether this is the proper way to close out all your positions at the end of the day.

https://www.quantconnect.com/forum/discussion/656

According to that post, it is unclear whether OnEndOfDay() fires at the actual market close (4pm) or midnight. Even if it closes at 4pm instead of midnight, the last unanswered reply to the post suggests that it fires after the last bar is generated and any request to sell a security would fire at open the next trading day.

I tried the following code, but despite that I am holding shares, it fails to sell even over a full month of backtesting:
public void OnEndOfDay(Symbol symbol)
{
Liquidate(symbol);
}


Some pointers in the right direction would be greatly appreciated. Thanks in advance!