Can somebody explain why the following algorithm blows up on weekends? It runs fine until midnight Sunday (00:00:00 Monday), then throws an error:

"2016-06-13 00:00:00 Runtime Error: An item with the same key has already been added."

I think it must have something to do with the dictionary that stores the day's opening price values. I'm lost because the algo deletes all of the entries in the dictionary at the end of each day and rebuilds it with new opening price values the next day, so it should be empty at midnight Sunday. Why is it even doing anything at all at midnight Sunday?

This was all an exercise to learn how to trade an algo with multiple stocks, so the strategy is pretty basic. Comments, criticism and suggestions are welcome, but the primary goal of this thread is to fix whatever problem is keeping it from continuing past the first weekend.   Thanks.