Commit Graph

234 Commits

Author SHA1 Message Date
Stefano Raggi e39791ac6c Upgrade RestSharp library from v105.2.3 to v106.6.10 2019-07-17 10:28:35 +02:00
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
Martin Molinero f6b5e92a96 Add conditional optimization flag 2019-06-19 16:11:15 -03:00
Martin Molinero e8660d9f52 Address reviews 2019-06-17 23:40:56 -03:00
Martin Molinero 65201cb808 Adding StepTimeProvider for live
- Adding new `StepTimeProvider` that will advance time based on a
desired custom evaluator.
- Live trading `Options`, `Futures` and `Coarse` data will use a
`FrontierAwareEnumerator` + `StepTimeProvider`. This will allow to hold
the selection data until its the desired time
- `Universe.CanRemoveMember` will round the members time in the universe
based on the `UniverseSettings.MinimumTimeInUniverse`
2019-06-17 23:40:55 -03:00
Jared 10de77e600 Merge pull request #3307 from QuantConnect/bug-3286-live-data-delay-v2
Fix live data delay
2019-06-13 16:13:08 -07:00
Martin Molinero 19701461cc Fix live data delay
- C# `Timer` can sometimes be triggered before the expected due time.
Implementing `RealTimeScheduleEventService` that will guarantee a
scheduled event due time is respected and the event never happens before
time.
2019-06-13 17:52:29 -03:00
Gerardo Salazar 340cc3a330 Upgrade dependency DotNetZip to version 1.13.3 to fix security issue 2019-06-11 11:03:37 -07:00
Stefano Raggi 9d930c170e Add new LiveSynchronizer + update live unit tests 2019-04-29 15:16:22 +02:00
Stefano Raggi 08895c2c8a Reduce CPU usage in live equity enumerator stack 2019-03-26 21:10:28 +01:00
Martin Molinero 8f6ad4e3c8 Cache raw data points
- `TextSubscriptionDataSourceReader` will now cache raw price mode data
points for each requested local source file, per data type.
Caching will be handled by the `MemoryCache` class.
- `GetLastKnownPrice()` will not `RoundDown` end time. This was causing
it to fail to fetch a data point in some cases.
2019-02-28 16:56:35 -03:00
Martin Molinero ed5f7ab58c Moving price scale factoring to new enumerator
- Adding new `PriceScaleFactorEnumerator` that will scale raw prices
based on a provided `SubscriptionDataConfig` and update the
`SubscriptionDataConfig.PriceScaleFactor`. Adding unit tests.
- `BaseData` factories (`TradeBar.cs`, `QuoteBar.cs`, `Tick.cs`) will
no longer scale factor prices, they will generate data points in raw
mode.
- `SubscriptionDataReader` will no longer update the
`SuscriptionDataConfig.PriceScaleFactor`
- Fix `BrokerageTransactionHandlerTests` unit test that was having a
race condition.
2019-02-27 15:11:34 -03:00
Martin Molinero 177d786ac5 Removing internal currency subscriptions
- `UniverseSelection` class will now keep track and remove internal
currency subscriptions through the usage of new class
`CurrencySubscriptionDataConfigManager`
- Modifying existing regression tests to assert bug 2773.
- Adding new regression test that fixes the case where a new cash is set
after initialization. This could happen during cash sync performed by
the `BrokerageTransactionHandler`.
    - Adding new `CashAdded` event for the `CashBook` to solve the
    issue.
2018-12-21 17:31:47 -03:00
Martin Molinero a26b3542bb Address reviews
- `ISetupHandler.Setup()` will now receive a parameters object
- Removing `SetupHandlerHelper` and adding new `BaseSetupHandler`
2018-12-19 16:15:28 -03:00
Martin Molinero af8e6bf85c Fix starting capital for non usd cash
- Moving `UniverseSelection.EnsureCurrencyDataFeeds` call into the
`IResultHandler` implementation through usage of the new `SetupHandlerHelper`
class, that will also set an initial conversion rate if none present.
- Adding regression test, that reproduces original issue
2018-12-19 16:15:28 -03:00
Jared 54fbf36be8 Merge pull request #2671 from Martin-Molinero/refactor-2429-corporate-events-own-enumerator
Move corporate events to new enumerators
2018-12-03 10:45:44 -08:00
Martin Molinero dea0fe2674 Implementing composition over inheritance
- Mappings, splits, delisting and dividends will be
`ITradableDateEventProvider` that will be handled by
the `AuxiliaryDataEnumerator`.
2018-11-20 16:17:44 -03:00
Martin Molinero a746dd0137 Move corporate events to enumerators
- Moving `Splits`, `Dividends`, `Mappings`, `Delistings`, from the
`SubscriptionDataReader` into there own enumerator, inheriting from
new `CorporateEventBaseEnumerator`
- Adding new helper `static class CorporateEventEnumeratorFactory` to
create the new enumerators
- Adding unit tests for new `CorporateEventBaseEnumerator`
- Adding some extra checks to `HourSplitRegressionAlgorithm` and
`DelistingEventsAlgorithm`
2018-11-20 15:50:19 -03:00
Martin Molinero 251071ee73 Remove Security from Subscription
- Removing unneeded `CashBook` instance to create a new `TimeSlice`
- Adding new `TimeSliceFactory`, an instance base class that will
provide methods to create a new `TimeSlice`. Will own the `DateTimeZone`
property.
- Adding new `ISecurityPrice` and `IOptionPrice` that will provide a
reduced interface for accessing price properties and methods used when
creating a new `TimeSlice`
2018-11-14 18:28:18 -03:00
Stefano Raggi dbacd57880 Update live option universe enumerator stack to refresh every day
The DataQueueOptionChainUniverseDataCollectionEnumerator now reloads the option chain from the IDataQueueUniverseProvider when the date changes.
2018-11-13 11:38:47 +01:00
Jared 988abaa0a4 Merge pull request #2662 from Martin-Molinero/refactor-2616-track-universes-requesting-subscription
Subscriptions will track Universe requests
2018-11-09 09:05:19 -08:00
Martin Molinero ee2dc32710 Subscriptions will track Universe requests
- The class `Subscription` will internally track each `Universe`
`SubscriptionRequest` added or removed
- Adding regression test in which two different `Universe` request the
same `SubscriptionDataConfig` and one of them removes/adds it in a
toggle fashion (fails on current master)
- `UniverseSelection` pending removals will also be tracked by
`Universe`
- `UniverseDecorator` will overwrite the `Universe` member of
`SubscriptionsRequests` at `GetSubscriptionRequests()`. This is due to
`this != this,Universe`
- Adding `Subscription` unit tests covering expected behavior
- Extracting pending removals logic from `UniverseSelection` class into
a new helper class `PendingRemovalsManager`. This new class will keep
track of the `universes` requesting to remove a security. Adding unit tests
2018-11-08 13:02:11 -03:00
Stefano Raggi de32c3aefd Update future universe enumerator stack to refresh every day
- The DataQueueFuturesChainUniverseDataCollectionEnumerator now reloads the future chain from the IDataQueueUniverseProvider when the date changes.
2018-11-08 15:00:43 +01:00
Martin Molinero 9bdf702c41 Creating new Synchronizer - TimeSlice streamer
- Creating new `Synchronizer` which will consolidate and combine `TimeSlice`
streaming for both live and backtests modes. Will live in front of the
`DataManager`
- `SubscriptionSynchronizer` will be the `FrontierTimeProvider` exposed,
and owned, by the new `Synchronizer`
- Updating existing tests
2018-10-19 15:36:08 -03:00
Stefano Raggi 44412f2273 Move HistoryProviderBase to QuantConnect.Common project 2018-10-14 23:07:09 +02:00
Stefano Raggi dbaf109c78 Post-review updates
- Renamed events in SubscriptionDataReader and IHistoryProvider
- Added HistoryProvider base class with events and event invocators
2018-10-14 22:29:06 +02:00
Martin Molinero b4dcd208e1 Addressing review. Adding null IDataFeed implementation. 2018-09-18 19:39:39 -03:00
Martin Molinero 0a82d16829 DataManager wraps IDataFeed. DataManager owns UniverseSelection instance 2018-09-17 20:45:16 -03:00
Martin Molinero ff2ef7962c SubscriptionSynchronizer will depend on a Time Provider for determining next frontier.
Adding new SubscriptionFrontierTimeProvider which updates current time based on the current data emit time of all subscriptions.
2018-09-06 15:48:07 -03:00
Martin Molinero 953cc48997 Addressing reviews. Some renames and setting new interface IDataFeedSubscriptionManager for future work 2018-08-31 16:06:41 -03:00
Martin Molinero 41873b2315 Fixing unit tests 2018-08-31 16:06:41 -03:00
Martin Molinero 2c7a0b0510 Fix cancelled order status setting location 2018-07-12 14:08:21 -03:00
Stefano Raggi e5ff575533 Update LiveTradingDataFeed to handle auxiliary data 2018-06-12 11:56:36 +02:00
Jared 258cb60d93 Merge pull request #1805 from AlexCatarino/feature-1798-python-alpha-models
Adds python versions of available Alpha Models
2018-04-11 14:22:53 -04:00
AlexCatarino 6799558d0d Adds SineHistoryProvider
This toy HistoryProvider implements a history provider that always return a IEnumerable of Slice with prices following a sine function.
2018-04-11 11:11:32 +01:00
Michael Handschuh cf7cd7e1fb Define ITimeTriggeredUniverse
Provides a common abstraction for UserDefinedUniverse and the
yet-to-be-impemented ScheduledUniverse. Categorized by the fact
that they don't operate on data, but instead a fixed schedule and
any data required is fetched through external means, such as a
web request.
2018-04-10 19:24:36 -04:00
Martin-Molinero 684ba1b25a remove missing files 2018-03-15 17:41:24 -07:00
Michael Handschuh 6b239674e2 Renames Alpha -> Insight
The term 'alpha' is used to describe the entire algorithm. Therefore, 'alpha'
produces insights. From this we have things like IAlphaModel, which is the model
defining how insights are produced. We have IAlphaHandler, which defines how the
insights from a single 'alpha' (the algorithm) are managed, analyzed, and stored.
Types closer to the individual prediction level, such as InsightDirection, or
InsightScore relate directly to exactly 1 insight. The distinction between the
two became more clear as we developed the insights API, and from that effort it
was decided to harmonize alpha/insight terminology across the various QC systems.
2018-03-09 16:12:56 -05:00
Michael Handschuh 60fd7eb304 Refactor ISetupHandler.Errors to List<Exception>
This will prevent loss of information by translating the exception to a
string message too early
2018-02-27 22:17:46 -05:00
Michael Handschuh e6e4e58eb9 Log all order events to dedicate file in regression
When inspecting regression differences, the first thing that should be looked at
are the fills. Some of the regression algorithms log this data making it possible
to inspect whie others do not. In addition, for algorithms with many securities the
log can quickly become fills with noise from scheduled event logging.

This change aims to make it very easy to compare any regressions in orders/fills
against the most recent successful run of the specified regression algorithm.
2018-02-19 13:01:27 -05:00
Michael Handschuh cee7ff7766 Move clone and tz conversion operations to DF thread
A large percentage of synchronization time is spent performing time zone conversions.
Previously, it was possible that we may compute the same tz conversion multiple times
on the same piece of data until it's emitted. This change moves the time zone conversion
logic onto the data feed thread right before it puts the data into enqueueable enumerator.
In addition, we're not performing the clone operation at the same moment. This removes
unnecessary computation while moving the necessary computation to the data feed thread to
lighten the load on the synchronization/algorithm thread.
2018-02-13 15:59:56 -05:00
Michael Handschuh d3ec0facc3 Add ISubscriptionSynchronizer interface
Provides an abstraction point allowing us to easily substitute in a different
synchronization algorithm. This isn't 100% complete as I'm hopefully able to
remove the universe selection dependency from the synchronization implementation.
2018-02-06 19:52:31 -05:00
Michael Handschuh 69d3a10a93 Decompose DefaultAlphaHandler into IAlphaManagerExtension
The IAlphaManagerExtension defines a type that needs to react to events produced
by the AlphaManager. The actual events were removed in favor of a interface to
handle the events. This removes the need to wire events and instead just pass the
extensions to the alph manager and it will handle invoking the extensions at the
appropriate time.

This change removes all charting and statistics aggregation logic from the alpha
handler and moves it into dedicated types, AlphaChartingManagerExtension and
AlphaStatisticsManagerExtension. The resulting types are highly decoupled from the
LEAN ecosystem allowing them to be easily unit tested, whereas before the logic
was embedded in a handler with many many dependencies which would be very hard to
properly unit test.

As part of this change (and in preparation for moving scoring to the alpha thread)
the resolution of SecurityValues was removed from the alpha manager. In this new
pattern, the alpha manager is pushed generated alphas and security values at each
time step.
2018-01-12 12:08:40 -05:00
Michael Handschuh b4b3aae112 Rename Signal -> Alpha
Whoa... I think I got everything :)
2017-12-15 18:24:58 -05:00
Michael Handschuh 5910bc620f Add ISignalHandler
Handles signals generated by the algorithm. The default implementation
sends a SignalPacket to the messaging handler.
2017-12-12 08:56:19 -05:00
AlexCatarino dfffbd6953 Adds IFutureChainProvider interface with base implementations
- Move BacktestingFutureChainProvider provider to Lean.Engine.DataFeeds along with its options equivalent.

- EmptyFutureChainProvider: provider that returns an empty list of symbols
- CachingFutureChainProvider: implements caching by date
- BacktestingFutureChainProvider: provider that gets chain from local files
- LiveFutureChainProvider: provider that gets chain from external source (empty list of symbols for now)
2017-12-04 14:16:59 +00:00
Stefano Raggi 513c830677 Remove usage of SubscriptionLimiter from universe selection
Previously the number of symbols that could be selected was limited by estimates of RAM usage calculated using the resolution of subscription, now it will only be limited by the physical RAM available.
2017-11-16 23:52:10 +01:00
Michael Handschuh ea01252cf2 Add LiveCustomDataSubscriptionEnumeratorFactory
Defines an enumerator factory for live custom data. This is a refactoring
and bugfix over the previous implementation. This implementation now checks
the transport medium of each refresh of the stack to see if it's a file or
a rest server and provides the appropriate fast forward/rate limiting behavior.
2017-10-17 12:15:58 -04:00
Stefano Raggi e4509d1a5c Add QuoteBarFillForwardEnumerator 2017-08-15 12:22:41 +02:00
Andrew d893bd7398 Renamed ILeanManagement to ILeanManager
Renamed this interface and all associated classes and content to be more
in line with Lean naming conventions.
2017-08-09 16:15:52 -04:00