Commit Graph

31 Commits

Author SHA1 Message Date
Martin Molinero a92bee5bf1 Fix OnEndOfDay not fired
- 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
2019-06-20 17:35:28 -03:00
AlexCatarino 27d14d047f Fixes missing inner exception information in ScheduledEventException
When a `ScheduledEventException` was thrown, `IAlgorithm.RunTimeError` was not set as `ScheduledEventException` , but as `Exception` with the orginal exception message and no inner exception.
2018-04-13 19:23:45 +01:00
Stefano Raggi 91ba63529b Remove Guid string from ScheduledEvent.Name
Fixes #1674
2018-03-07 21:33:33 +01:00
AlexCatarino 136ca90f6c Fixes message input in ScheduledEventException instance creation
Passes exception to Log.Error in RealTimeHandlers in order to include stack information
2018-02-20 17:39:03 +00:00
AlexCatarino af7b592dda Passes inner exception to ScheduleEvent 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.
2018-02-19 19:11:55 +00:00
Stefano Raggi 20a325276e Fix scheduled event firing order in backtesting
When backtesting with multiple scheduled events, these were fired in unpredictable order, not respecting the expected sequence sorted by time.
2018-01-03 14:27:08 +01:00
Stefano Raggi f37d0cc962 Optimize loops for performance on cashbook and securities 2017-12-20 21:58:59 +01:00
Stefano Raggi c6aba7bfec Reduce full locking on ConcurrentDictionary objects
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/
2017-12-20 17:18:54 +01:00
Michael Handschuh 7068a5aeba Fix scheduled event scheduling
Scheduled events were seemingly only being submitted for internal feed
securities -- the opposite of what we're looking for.
2017-10-20 13:49:56 -04:00
Andrew 2c156ce04a Add schedule event exception logic to BacktestingRealTimeHandler
Catching the exception in BacktestingRealTimeHandler prevents unhandled errors in backtesting and provides more specific logging to make debugging easier for users
2017-09-25 11:04:13 -04:00
Stefano Raggi 4149aba9d7 Fixed scheduled event firing time in backtesting
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.
2017-02-23 20:25:49 +01:00
Michael Handschuh 42465ffd52 Clean up IsInternalFeed usages 2016-04-12 19:06:49 -04:00
snugs 8374b99e18 Don't fire EOD events for internal feeds 2015-09-28 13:28:09 -04:00
snugs e1938baafe Clean up using directives 2015-09-01 22:17:35 -04:00
snugs 730430b1bb Adds scheduling feature
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
2015-08-10 10:56:14 -04:00
snugs 844a040be5 Initial impl of coarse universe selection
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
2015-08-06 17:52:23 -04:00
snugs 7fa9a4b1be Implements self re-scheduling events
A ScheduledEvent can be defined using an enumerator of event times and a callback
2015-08-05 13:13:08 -04:00
QuantConnect cc3f0c76e1 Reduced logging from backtesting realtime handler 2015-06-29 11:55:25 -04:00
Jared 7e71f24f33 Merge pull request #124 from AnObfuscator/master
Fix time issue preventing OnEndOfDay() event from firing.
2015-06-25 18:57:38 -04:00
Jonathan Evans 84bfaf129c Fix time issue preventing OnEndOfDay() event from firing. Remove redundant ScanEvents() call. 2015-06-25 17:44:54 -05:00
snugs 4de2ec4070 Make Engine an instance
Updated all interfaces to accept dependencies via Initialize methods
2015-06-18 13:50:11 -04:00
snugs c1736571cc Load real time handlers via MEF configuration 2015-06-17 22:34:01 -04:00
QuantConnect fde0cbed3a Strip out block quote section header comments 2015-06-13 16:04:27 -04:00
snugs 89b6e98af8 Fixes warnings mostly relating to xml comments
Also cleans up some block comments

Via PR#72 - thanks @ammachado!
2015-05-13 10:56:47 -04:00
snugs 33f4046fb9 Several random fixes
Made ObjectActivator.Clone 4x faster
Updated deltaCharts in live trading results using order events
2015-04-30 15:31:57 -04:00
snugs d80b1733a9 Pre ib launch review 2015-04-24 19:12:16 -04:00
Adriano Marcondes Machado b2229e8968 Fixed a few compilation warnings 2015-03-09 16:28:17 -03:00
QuantConnect 5be77cbaaf Large shuffle to move MarketToday clock into RealTime handler and out of DataFeed. Added public accessor for market today hours. Simplify and tidy live real time handler 2015-02-25 15:33:10 -03:00
Jared Broad df00cc1f3a Fixed access to modified closure bug with wrong EOD event symbol 2015-02-19 00:40:10 -03:00
Jared Broad 90b162b85d Rework RealtimeEvent class to use datetime - fix #11, simplified live realtime event handler, eliminate backtest realtime thread 2015-02-18 16:49:42 -03:00
Jared Broad b3de520915 Initial commit 2015-01-12 12:03:33 -03:00