Commit Graph

303 Commits

Author SHA1 Message Date
Stefano Raggi 34152bbbcc Update IB cash sync to not be performed during server reset times
A new IBrokerageCashSynchronizer interface has been added to allow brokerage implementations to handle the cash sync process. Most of the cash sync logic has been moved from the BrokerageTransactionHandler to the base Brokerage class.
The IB brokerage will not attempt to perform cash sync during server reset times, respecting the different regional schedules (see also #3413).
2019-07-29 18:01:54 +02:00
AlexCatarino 618ecd76b7 Adds DuplicateKeyPortfolioConstructionModelTests
Adds `DuplicateKeyPortfolioConstructionModelTests` to evaluate duplicate keys exception on `ReturnsSymbolData.FormReturnsMatrix` method.
Removes `DuplicateKeyExceptionAlgorithm` as it is replaced by the unit test.
2019-07-29 15:10:34 +01:00
AlexCatarino 22723204ff Fixes VolumeWeightedAveragePriceExecutionModel.IntradayVwap
`VolumeWeightedAveragePriceExecutionModel.IntradayVwap.Update` did not return a boolean.
2019-07-29 11:28:06 +01:00
AlexCatarino 0b0a1b31ff Refactors PythonIndicator
In order to provide full Lean Indicator functionality to python custom indicators, they need to inherit from a C# class. `PythonIndicator` will serve for this purpose.
Algorithms can use the former version (no inheritance).
2019-07-26 00:35:57 +01:00
AlexCatarino 84d548b5f2 Adds Custom Python Indicator Support for QCAlgorithm.PlotIndicator
In order to add support custom python indicators for `QCAlgorithm.PlotIndicator`, we created a `PythonIndicator` class that wraps the custom python indicator. In `QCAlgorithm`, the reference of the wrapper is saved into a dictionary keyed by the python indicator handle.
2019-07-23 22:02:33 +01:00
Martin Molinero 38e8621bb9 Serialized Insight has default values 2019-07-10 11:33:42 -03:00
Martin Molinero 64d43c1487 Add Insight.ReferenceValueFinal 2019-07-09 17:53:58 -03:00
Martin Molinero 084353f182 Smart TotalPortfolioValue Calculation
- `SecurityPortfolioManager` will keep track of the current
`TotalPortfolioValue` and only re calculated when flagged as invalid.
2019-06-07 16:13:57 -03:00
Jared a2a63ae058 Merge pull request #3016 from QuantConnect/feature-3015-add-weight-to-insights
Add Insight optional Weight
2019-06-04 16:52:48 -07:00
Jared 3eaf522622 Merge pull request #3223 from Martin-Molinero/bug-3222-fix-test-algorithmrunner
Fix test AlgorithmRunner
2019-05-28 09:48:33 -07:00
Jared 167d5c348c Merge pull request #3230 from Martin-Molinero/bug-3154-overflow-exception-blacklitterman-meanvariance
Fix overflow exception
2019-05-28 08:17:38 -07:00
Martin Molinero fffaf8fc1f Fix algorithm download tests 2019-05-28 11:49:08 -03:00
Stefano Raggi 9d3c1df5f3 Fix execution models to handle partially filled orders 2019-05-24 11:50:31 +02:00
Martin Molinero e294b3c3e2 Fix overflow exception
- Adding new `AlgorithmSettings` Min and Max absolute portfolio target
percentage
- Adding new `PortfolioConstructionModel.FilterInvalidInsightMagnitude()`
helper method that will be used by the `BlackLitterman` and
`MeanVariance` optiomization portfolio construction models to skip
insights with extreme magnitudes that will cause exceptions
- `PortfolioTarget.Percentage()` will now verify requested percent is
withing the settings values
2019-05-23 20:30:44 -03:00
Martin Molinero f976ffa099 Removing BacktestingTransactionHandler thread
- For backtesting the algorithm thread will sequentially process pending
order requests
   - Adding new non blocking `BusyCollection`
- Updating `UpdateOrderRegressionAlgorithm` that suffered of a race
condition: it supposed `OnOrderEvent` would be called after the call to
`Transactions.AddOrder()` was finished
2019-05-10 16:15:24 -03:00
Gerardo Salazar 4af1967087 Reduce CopyTo in InsightCollection to a one-liner
Add unit tests for CopyTo
2019-05-07 18:47:19 -05:00
Jared bcfd0fbae6 Merge pull request #3040 from QuantConnect/bug-live-synchronizer-high-cpu-usage
Reduce CPU Usage in Live Synchronizer
2019-05-03 13:39:23 -07:00
Martin Molinero 3d52343799 Optimize stored result json
- `Alpha Assets` chart will only store last data point
- Adding new `JsonRoundingConverter` that will round to 4 (number of
digits currently used for comparing alpha statistics) fractional
digits.
   - Will be used for `Insights` and `ChartPoint`
2019-04-29 19:17:00 -03:00
Stefano Raggi 73b09d9d64 Fix merge conflicts 2019-04-29 15:34:36 +02:00
Stefano Raggi 513ef5d581 Fix DataManager live mode flag and failing unit tests 2019-04-29 15:26:50 +02:00
Stefano Raggi acb68fde28 Fix AddSecurity not adding security with same ticker but different market 2019-04-24 20:25:19 +02:00
Martin Molinero ac53e2a790 Rebase from master. Adding missing Python algo 2019-04-24 11:05:15 -03:00
Martin Molinero e21a8fec35 Address review, use inheritance
- New InsightWeightingPortfolioConstructionModel will inherit from EqualWeightingPortfolioConstructionModel
2019-04-24 11:05:15 -03:00
Martin Molinero 39ae3c6970 Addressing reviews
- Adding two new unit tests: 0 weight insight and null weight insight
- Fix bug in python `InsightWeightingPortfolioConstructionModel`
2019-04-24 11:05:14 -03:00
Martin Molinero 968adcea32 Adding InsightWeightingPortfolioConstructionModel
- Adding new `InsightWeightingPortfolioConstructionModel` that will
generate percent `Targets` based on the latest active `Insight` `Weight` per
`Symbol`.
   - Will ignore `Insights` that have no `Weight`.
   - If the sum of all the last active `Insight` per `Symbol` is bigger than 1, it
will factor down each target percent holdings proportionally so the sum is 1.
- Adding unit tests
- Adding a new regression test framework algorithm
- Note most of the code, including tests, are reused from the
`EqualWeightingPortfolioConstructionModel`
2019-04-24 11:05:14 -03:00
Martin Molinero 7af29e3697 Add Insight Portfolio Weight
- Adding optional portfolio Weight property for `Insights`
2019-04-24 10:58:45 -03:00
AlexCatarino 222ccf5ad0 Adds a Test that Reproduces the Bug 2019-04-18 17:22:12 +01:00
AlexCatarino b9f7b8fa52 Fixes StandardDeviationExecutionModel
This model was assuming that the history request used to warm up the indicators contains the 'close' column which is only valid for Equity.

The models were also refactored to update the indicators without a consolidator since the last data point from the history request was not pushed throught the indicators.
2019-04-18 16:38:45 +01:00
AlexCatarino 20f92b48d6 Adds Unit Test for Manual to Universe DataNormalizationMode Persistence 2019-04-17 23:08:28 +01:00
AlexCatarino e92a40192d Implements UniverseSettings.DataNormalizationMode
Implements `DataNormalizationMode` field in `UniverseSettings` to enable the settings of a desired `DataNormalizationMode` to the securities that are chosen in Universe Selection.
2019-04-17 15:18:03 +01:00
AlexCatarino dc4dd7dfcb Required Changes after Classic/Framework Merge 2019-04-08 20:30:14 +01:00
AlexCatarino c288e836eb Adds Unit Tests for UniverseSelectionModel
Adds unit tests for UniverseSelectionModel's that can be used to create new models with inheritance:
- ManualUniverseSelectionModel
- FundamentalUniverseSelectionModel
2019-04-05 23:16:55 +01:00
Martin Molinero 68d9f48c2d Address reviews
- Adding new `CompositeAlphaModel.AddAlphaModel()`
- Adding C#/Py regression algorithms using the new `QCAlgorith.AddAlphaModel()`
- Improving exception message
- Add python version of `QCAlgorith.AddAlphaModel()`
2019-04-05 18:34:18 -03:00
Martin Molinero 9cabd32d19 Add AddAlphaModel method 2019-04-04 13:36:07 -03:00
Martin Molinero cfa08a11fb Address reviews
- Removing `using QCAlgorithmFramework = QuantConnect.Algorithm.QCAlgorithm`
- Removing `QCAlgorithmFrameworkBridge`
- Removing `IsFrameworkAlgorithm`
- Making `EmitInsightBasedOnFill` private. Adding new
`IOrderEventProvider` exposing an `event` to which `QCAlgorithm` will
subscribe.
- `AccountType.Cash` algorithms will be allowed to manually trade and
emight insights manually or with alpha model.
2019-04-03 21:55:44 -03:00
Martin Molinero 32ac3146b4 Merge Framework and Classic Algorithms
- Merging Framework and Bridge algorithms into classic QCAlgorithm
class.
- Removing Framework project, VS17 and VS15
2019-04-03 21:54:32 -03:00
AlexCatarino 5931a42d48 Implements Insight Expiry Helper
Implement a new overload to `Insight` constructor that accepts a  `Func<DateTime, DateTime>` that is used to compute the `CloseTimeUtc` and `Period` after the `Insight` object is emitted (`SetPeriodAndCloseTime` method).

Adds the static Expiry class with functions that can be used to compute a future date/time (expiry) given a date/time.

Closes #3038
2019-04-03 21:46:14 +01:00
Martin Molinero 5b04cfe202 Emiting Insights based on Fills
- Classic Algorithms will emight insights based on order fills.
   - To be able to update generated insights closed time, we will not
   clone emitted insights.
   - `InsightAnalysisContext` will update `AnalysisEndTimeUtc` when the
   Insight period is closed and the period is `EndOfTimeTimeSpan`
- Adding new regression algorithm asserting on the new emitted insights
- Adding unit tests
- `LiveTradingResultHandler` will store `AlphaRunTimeStatistics`
- Making `DefaultAlphaHandler.ProcessAsynchronousEvents` virtual to
facilitate cloud changes
2019-03-26 16:09:22 -03:00
Stefano Raggi 4723301821 Fix AlphaRuntimeStatistics deserialization and missing null check 2019-01-23 20:05:08 +01:00
Martin Molinero c9e6268cbd Remove OrderFeeParameters.AccountCurrency
- Removing OrderFeeParameters.AccountCurrency. Where required replacing
for constructor parameter defaulting to USD.
- Updating IB fee model to use to correct fee currency
2018-12-28 15:57:53 -03:00
Martin Molinero 8e41371e19 Non-Usd brokerage support
- `GetCashBalance()` will return a `List<CashAmount>`, will not need to
set conversion rates, which requires knowing what the account currency is.
- Removing `Global.Holding` conversion rate field. It wasn't being used
and required knowing what the account currency is.
- Adding equality operators for `CashAmount`. Adding unit tests.
2018-12-27 12:13:43 -03:00
AlexCatarino 8d7e59a581 Adds unit test 2018-12-21 15:30:16 +00:00
Martin Molinero 0af7ba14f5 Address reviews
- `CashBook[NullCurrency] { get; }` will throw an exception
- Revert `Currencies.USD` changes in user facing algorithms
- Improve some documentation
- Revert some format changes
- Adding more asserts for regression test
- Adding new regression tests using a custom fee model which returns
`OrderFee.Zero`
- Adding a non-usd account currency test to the cash book tests
- Adding some unit tests for `NullCurrency` and `OrderFee.Zero`
2018-12-14 12:38:55 -03:00
Martin Molinero 0933da9303 Refactor previous commits
- Removing `AccountCurrency` from `Cash` and `Brokerage` classes.
`ICurrencyConverter` will now provide the `AccountCurrency`
- Adding new static `OrderFee.Zero` which will return a 0 order fee in
`NullCurrency`
- Adding static `Currencies.USD` value, replacing all "USD".
- Addin new static `Currencies.NullCurrency`
- Updating Bitfinex `FeeModel` so it return fees in quote currency.
Adding unit tests
2018-12-13 11:30:40 -03:00
Martin Molinero b7bcdbef04 Adding OrderFee to OrderEvent
- Replacing `decimal` for `OrderFee` at the `OrderEvent`.
- Adding `FeeModelNotUsingAccountCurrency` regression test
- Adding unit tests for `CashBuyingPowerModel` and `SecurityMarginModel`
with non account currency fees
2018-12-10 13:18:41 -03:00
Martin Molinero 75ffa300f1 Adding new IAlgorithm.AccountCurrency
- Adding new `IAlgorithm.AccountCurrency { get; }` that will point to the
`Portfolio.CashBook.AccountCurrency`. Setter will be added in a
following PR.
- Base `Brokerage` class will now have a `AccountCurrency { get }`
pointing to the `IAccountCurrencyProvider`. Will be used by the different
brokerages implementations.
2018-12-10 11:59:02 -03:00
Martin-Molinero 79d35333de Merge pull request #2720 from Martin-Molinero/refactor-2717-ifeelmodels
Refactor IFeeModel
2018-12-06 18:09:34 -03:00
Martin Molinero c5daf9ac9a Refactor IFeeModel
- Refactoring `IFeeModel`. *This is a breaking change* for implementations
inheriting directly from the interface. Deleting old and adding a new method
`OrderFee GetOrderFee(OrderFeeParameters parameters)` that will use a parameter
and a result object.
- Refactoring `CashAmount` so it does not embed a `ICurrencyConverter`
instance.
- Updating unit tests
- The `Security.QuoteCurrency`, a `Cash` instance, will provide access
to the `AccountCurrency` as a property.
- Will maintain backwards compatibility with old python custom
FeeModels, Adding unit test.

> Note that for now, consumers will ignore the currency, as before, and
directly consume the amount
2018-12-06 16:20:36 -03:00
Martin Molinero 7d7ad17883 Obsoleting Securities configurations properties
> This PR is a mechanical refactor, no behaviour changed

- Obsoleting `IsFillDataForward`, `Resolution`, `IsExtendedMarketHours`
`Security` configuration properties. Replacing there usages by
requesting the `SubscriptionDataConfigs` to the new
`SubscriptionDataConfigService`
2018-12-05 10:05:53 -03:00
Jared 299b467062 Merge pull request #2733 from Martin-Molinero/refactor-2728-buyingpowermodel-getinitialmarginrequiredfororder
BuyingPowerModel.GetInitialMarginRequiredForOrder will receive a Parameters object
2018-12-04 14:50:58 -08:00