Commit Graph

303 Commits

Author SHA1 Message Date
Martin Molinero 6bbc8a304e BuyingPowerModel.GetInitialMarginRequiredForOrder
- `BuyingPowerModel.GetInitialMarginRequiredForOrder` will now receive
the new `InitialMarginRequiredForOrderParameters` object containing an
`ICurrencyConverter` instance.
2018-12-04 17:50:00 -03:00
Martin Molinero 95af5f8877 SecurityHolding has a ref to an ICurrencyConverter
- `SecurityHolding` will now have a reference to a `ICurrencyConverter`
instance, provided as a constructor argument, called by the owning `Security`.
2018-12-04 17:06:56 -03:00
Stefano Raggi bd4c799d2b Rename parameter classes from Context to Parameters 2018-11-29 22:05:49 +01:00
Stefano Raggi cb98955901 Fix failing unit tests 2018-11-27 22:50:17 +01:00
Martin Molinero 7ab6a374cf Addressing reviews
- `TimeSliceFactory` `TimeZone` will now be a constructor parameter
2018-11-14 19:12:45 -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
Martin Molinero ac7a2601f2 Remove obsolete ISecurityTransactionModel
This commit will allow an easier `FillModel` refactor:
- Removing `ISecurityTransactionModel` and its implementations
- Merging identicall tests from `EquityTransactionModelTests`,
`ForexTransactionModelTests` and `SecurityTransactionModelTests` under
`ImmediateFillModelTests`. This was possible because the mentioned
`TransactionModels` implementations used `ImmediateFillModel`
2018-11-09 15:22:37 -03:00
Martin Molinero f1ecfd5784 Move DataManager in front of DataFeed
- Completly move `DataManager` in front of `DataFeed`. Specifically
`AddSubscription()` and `RemoveSubscription()` implementations. Also
removing IDataFeed.Subscriptions
2018-10-29 16:13:27 -03:00
Martin Molinero a288648929 Creating new ISecurityService
- Adding new ISecurityService and its implementation SecurityService.
Expose by SecurityManager.
This class will expose a method for creating new securities. The
SecurityManager is exposing this new interface, calling _securityService
internally, so Future/OptionUniverseSelectionModel.cs can use it
- Replacing all usages of SecurityManager.CreateSecurity for new
ISecurityService
- Modifying `Cash.cs` and `CashBook.cs` `EnsureCurrencyDataFeeds()` to
return newly added `SubscriptionDataConfig` instead of `Security`. This
will avoid using `Security.Subscriptions` at call site.
- Moving old SecurityManager.CreateSecurity into new
SecurityServiceTests.cs
2018-10-18 16:25:32 -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
Stefano Raggi 9fad26bc8f Add events to IHistoryProvider and SubscriptionDataReader
The SubscriptionDataReaderHistoryProvider was using StubResultHandler, so no error messages were being shown or logged. By adding events to IHistoryProvider and SubscriptionDataReader, the dependency on IResultHandler could be removed completely and error messages are now pushed up the stack.
2018-10-14 22:29:04 +02:00
Stefano Raggi 77b37f4dfd Update IHistoryProvider.Initialize to use HistoryProviderInitializeParameters
This is only a mechanical refactor for the updated IHistoryProvider.Initialize method in all IHistoryProvider implementations, call sites and unit tests.
2018-10-14 22:29:02 +02:00
Michael Handschuh 8ddd65393a Merge pull request #2598 from Martin-Molinero/bug-2596-duplicate-effort-manualuniverse
Fix ManualUniverse duplicate effort
2018-10-13 03:59:42 -04:00
Martin Molinero eaba3ab24e Fix ManualUniverse duplicate effort
- Removed usages of algorithm.Securities.key as a parameter for the
`ManualUniverseSelectionModel()` since those securities, added through
`AddXXXX` calls will be managed by the `UserDefinedUniverse`. This was
causing for Universes to try to add the same subscription requests
- Adding new empty constructor for ManualUniverseSelectionModel,
required for Python
- ManualUniverse will return any existing SDC for the
symbol. This is for maintaining existing behavior and
preventing breaking changes: Specifically motivated by usages of
Algorithm.Securities.Keys as constructor parameter of the
ManualUniverseSelectionModel, since those Symbols added by Addxxx()
calls will already be managed by the UserDefinedUniverse
- Making some format modifications to aling with used Lean formatting
2018-10-12 18:30:04 -03:00
Michael Handschuh 20133d40d1 Add ICurrencyConverter to Security constructors
Security instances will require private access to this value in order to
compute close profit.

NOTE: The extent of these changes for simply adding a constructor argument
insinuates that we're missing an abstraction to manage the construction of
these objects, such as a factor object for Security. This will need some
careful TLC in the near future.
2018-10-10 11:17:12 -04:00
Michael Handschuh 0cf637f654 Merge pull request #2577 from Martin-Molinero/bug-2575-infinite-loop-tick-historyrequest
Add check to avoid FillForward for Resolution.Tick
2018-10-08 11:54:46 -04:00
Martin Molinero 47a946f607 Add check to avoid FillForward for Resolution.Tick
- Adding an internal check to the HistoryRequest.FillForwardResolution {get}
that will return null when resolution is set to Resolution.Tick
- Adding unit tests which reproduce the original issue
2018-10-04 17:10:10 -03:00
Stefano Raggi 5c9b81cef1 Fix Python initialization and imports for multiple tests 2018-10-02 20:28:13 +02:00
Martin Molinero 008c9ca873 Fixing unit tests 2018-09-28 15:44:05 -03:00
Martin Molinero 1c7e519776 Rebase from master - Refactor to reduce coupling
Refactoring previous commit so DataManager only keeps and receives a
reference to IAlgorithmSettigs, with the objective of reducing tight
coupling

Note: Investigate if IAlgorithmSettings.DataSubscriptionLimit should limit subscriptions or unique securities.
Today its using SubscriptionManagerSubscriptions.Where(x => !x.Symbol.IsCanonical()).DistinctBy(x => x.Symbol.Value).Count() @DataManager
2018-09-26 16:19:59 -03:00
Martin Molinero 94449149b9 DataManager receives UniverseSelection instance
DataManager will now receive UniverseSelection instance as a constructor
parameter. With the objective of avoiding tight coupling.
2018-09-26 10:00:10 -03:00
Michael Handschuh bc3bc893f4 Merge pull request #2520 from Martin-Molinero/refactor-2516-datamanager-wraps-idatafeed
DataManager wraps IDataFeed
2018-09-20 11:44:10 -04:00
Martin Molinero 1997197f47 Fix failing unit tests 2018-09-18 12:10:42 -03:00
Stefano Raggi 31fa8d628c Remove AlgorithmDownload tests from Travis CI build 2018-09-18 11:31:46 +02:00
Martin Molinero 41873b2315 Fixing unit tests 2018-08-31 16:06:41 -03:00
Martin Molinero 165f6fa43e Adjusting unit and regression tests 2018-08-28 12:27:21 -03:00
Martin Molinero 83897a7b88 Portfolio target percent respects FreePortfolioValuePercentage 2018-08-28 12:03:56 -03:00
Stefano Raggi c694e9faae Post merge fixes 2018-08-21 18:10:52 +02:00
Stefano Raggi cead4e608e Update EqualWeightingPortfolioConstructionModel to check for null targets 2018-08-21 18:10:52 +02:00
Stefano Raggi b37fd75f59 Fix failing unit test 2018-08-21 18:10:51 +02:00
Stefano Raggi 4abc525a38 PortfolioTarget.Percent returns null if error 2018-08-21 18:10:51 +02:00
AlexCatarino 76cc75006c Refactors BlackLittermanOptimizationPortfolioConstructionModel
1. Apply the pattern used in `EqualWeightingPortfolioConstructionModel`
2. Change the logic to compute the views from the insights.
3. Change the logis to compute the posterior mean and covariance

Use `UnconstrainedMeanVariancePortfolioOptimizer` in `BlackLittermanPortfolioOptimizationFrameworkAlgorithm` to bypass the difference in regression tests with `IPortfolioOptimizer` that rely on different algorithms in C# and python.

Adds unit tests for BLOPCV to test the implementation against Black and Litterman 1999 paper.
2018-08-20 21:01:14 +01:00
Martin Molinero fda1183222 Fix underlying security seeding at OnEndOfStep 2018-08-15 14:54:43 -03:00
AlexCatarino 239a5a909e Fixes EqualWeightingPortfolioConstructionModel not flattening expired insights
- When there are or aren'tt new insights, the EqualWeightingPortfolioConstructionModel will creates a target to flatten delisted securities from the universe of expired insights.
- Helper methods were added to deal with removing expired insights and getting active ones and used in `EqualWeightingPortfolioConstructionModel`
- Adds unit test
- Updates framework algorithms
2018-08-13 19:45:25 +01:00
Martin Molinero 78742e5df6 Adding cash buffer for IB Cash Accounts 2018-08-10 17:21:50 -03:00
Michael Handschuh d5f88c6bb7 Add Insight.IsActive and Insight.IsExpired methods
Easily check if an insight is active or expired
2018-08-10 13:52:17 -04:00
Jared 709c1e969a Merge branch 'master' into testing-2360-vwap-execution-model-tests 2018-08-09 10:13:44 -04:00
Jared 68f0d3d608 Merge pull request #2364 from QuantConnect/testing-2361-travis-include-python-tests
Enable Python unit tests ignored with TravisExclude
2018-08-09 10:07:54 -04:00
Stefano Raggi fadda32e08 Enable ignored/excluded Python unit tests 2018-08-09 11:51:53 +02:00
Stefano Raggi 95dc7c711b Add unit tests for VolumeWeightedAveragePriceExecutionModel 2018-08-08 18:22:37 +02:00
Stefano Raggi 039c065be8 Add unit tests for ImmediateExecutionModel 2018-08-08 17:47:04 +02:00
Michael f59d9754dc Merge pull request #2343 from QuantConnect/feature-2339-stdev-execution-model-tests
Add unit tests for StandardDeviationExecutionModel
2018-08-07 17:07:42 -04:00
Stefano Raggi d2252412d1 Moved PythonHelper to PythonSetup as NUnit SetUpFixture
- also made a few minor changes in StandardDeviationExecutionModelTests
2018-08-07 17:36:38 +02:00
Michael Handschuh 4fd16f6daf Fix resolution of insight close times, allow user defined close times
Fixes a bug where we were using the security's data resolution to compute
the insight's close time. This led a case such as insight.Period == 20days
to step 20days worth of tradable minutes (assuming minute data resolution),
yielding a close time that was very far in the future.

We also add different means of specifying an insight's period/close time:
1. Specify insight period as a TimeSpan and we compute close time
2. Specify insight period and a resolution and bar count and we compute close time
3. Specify insight close time local directly and we compute the insight period

The key here is maintaining consistency between the three different approaches
which is heavily validated with the corresponding unit tests.

Edits also made to trust the insight's close time as the analysis end time in
the case where the analysis period == insight period (extra analysis period = 0).
Given the current setup (extra analysis period == 0), this guarantees that close
and analysis end times are equivalent.

Regression statistics were updated and expectedly we get many more insights that
have completed analysis, and as such, average scores have also changed.
2018-08-07 11:21:11 -04:00
Michael a366063aed Merge pull request #2354 from AlexCatarino/bug-2353-fix-equal-weighting-pcm
Fixes EqualWeightingPortfolioConstructionModel
2018-08-07 10:54:37 -04:00
Michael 67bd47948e Merge pull request #2331 from Martin-Molinero/bug-2318-fix-for-getmaximumorderquantityfortargetvalue
Improving GetMaximumOrderQuantityForTargetValue
2018-08-07 10:52:29 -04:00
AlexCatarino e0c380d08c Fixes EqualWeightingPortfolioConstructionModel
Adds targets with direction zero to remove invested securities that do not have active insights.
2018-08-06 13:19:03 +01:00
Stefano Raggi 265e18a3c4 Fix PYTHONPATH for all existing framework model unit tests 2018-08-04 00:24:28 +02:00
Stefano Raggi 1dbc5bfb49 Add default folders to PYTHONPATH environment variable 2018-08-03 21:33:03 +02:00