- Adding `IRealTimeHandler.OnSecurityChanged()` will be used to update
the `OnEndOfDay` security related scheduled events
- Adding `BaseRealTimeHandler.cs` to reduce code duplication in the
`Backtesting` and `LiveTrading` `RealTimeHandlers`
- Adding CSharp and Python regression tests
- Deprecating `OnEndOfDay()` callback because of two reasons, mainly
because Python does not support two methods with the same name, but also
because different assets have different market close times.
- `ScheduledEvents` set at the same time will now be deterministic
When a `ScheduledEventException` was thrown, `IAlgorithm.RunTimeError` was not set as `ScheduledEventException` , but as `Exception` with the orginal exception message and no inner exception.
Without the inner exception, information on the user exception is lost. In python algorithm, the stack trace is completely lost.
Removes ScheduledEventExceptionMessage property as it is redundant to Message property inherited from parent class.
This PR is an attempt to reduce contention in concurrent dictionaries, replacing method calls using full locks with lock-free equivalents:
- dictionary.Count -> dictionary.Skip(0).Count()
- dictionary.Keys -> dictionary.Select(x => x.Key)
- dictionary.Values -> dictionary.Select(x => x.Value)
The most frequent usages of these methods are: CashBook, SecurityManager, UniverseManager and indirectly, SecurityPortfolioManager.
The reasons for this update are explained very clearly in this article:
https://arbel.net/2013/02/03/best-practices-for-using-concurrentdictionary/
Catching the exception in BacktestingRealTimeHandler prevents unhandled errors in backtesting and provides more specific logging to make debugging easier for users
If backtesting, we need to check if there are realtime events in the past
which didn't fire because at the scheduled times there was no data (i.e. markets closed) and fire them with the correct date/time.
In live mode, no changes are needed.
Adds the ScheduleManager which allows an algorithm to add/remove scheduled events
Check out the ScheduledEventsAlgorithm for syntax
ScheduledEvents are at their core an IEnumerator<DateTime> that defines the event times coupled with a callback
IDateRule defines dates for events
ITimeRule defines time(s) on a given date for events
Adds concept of Subscription to contain everything a data feed needs in order to process single data feed item
Moves preparation of all data to data feed thread, algo thread receives data in format it needs
QCAlgorithm.SetUniverse( func ) allows selection based on market/symbol/dollar volume/price
Remove laziness from Slice as optimization, no order by in real time handler