Commit Graph

721 Commits

Author SHA1 Message Date
Martin Molinero ec1d410907 Performance improvements
- `SecurityIdentifier` will calculate `StrikePrice` just once. Replacing
`!=` for a direct call to `Equals()` preventing unnecessary checks.
- Slightly improving Linq queries at `OptionFilterUniverse`
- Replace `OpenReader().CopyTo` for `Extract(stream)` avoids copying the
data twice.
- Replace `DateTime.Now` for `DateTime.UtcNow`
2019-06-10 22:40:19 -03:00
Jared 9ee7075034 Merge pull request #3275 from QuantConnect/performance-smart-totalportfoliovalue-calculation
Smart TotalPortfolioValue Calculation
2019-06-07 14:08:14 -07:00
Martin Molinero 2c1cf0fa93 Address reviews
- Adding new regression test algorithm
- `SecurityPortfolioManager` will subscribe to the `CashBook.Updated`
event to invalidate the `TotalPortfolioValue
2019-06-07 17:51:30 -03:00
Jared ac9e3dd432 Merge pull request #3282 from Martin-Molinero/feature-3281-add-cash-cashbook-updated-event
Adding Updated event for Cash and CashBook
2019-06-07 12:34:35 -07: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
Martin Molinero 90a8f23d98 Address reviews 2019-06-07 16:02:53 -03:00
Martin Molinero f5a28ff829 Adding Updated event Cash and CashBook
- Adding new `Updated` event for `Cash` and `CashBook`. Adding unit
tests.
- `CashBook.Update` event will also be called for updates in the `Cash`
instances he holds.
2019-06-07 13:43:41 -03:00
Gerardo Salazar b0406ba9eb Adds the following symbols to futures database: EI, EMD, ...
EN, EPN, ESK, EVC, EWG, EWN, EXR, F1U, FO, FRC, FSS, GCU, GD, GDK,
GNF, HCL, HG, HH, HP, HRC, HTT, IBV, J7

Add new utility functions in FuturesExpiryUtillityFunctions
2019-06-07 08:49:56 -07:00
Jared adf4dba49b Merge pull request #3271 from QuantConnect/overall-performance-improvements-v2
More Overall performance improvements
2019-06-07 07:08:48 -07:00
Martin Molinero 168fb98e20 Fix Turnover Ratio for Futures/CFDs
- `Futures` and `CFDs` sales value will use `ContractMultiplier` as the
rest of the securities.
- `FitnessScore` values will be truncated, not rounded, to 3 decimal places.
- Reducing code duplication for calculating the
`CompoundingAnnualPerformance`
2019-06-06 20:06:54 -03:00
Martin Molinero 08b72c5907 Overall performance improvements v2
- Adding `LazyToUpper()` implementation, that will avoid the call to
`ToUpper` if the string is already upper.
- Reduce the timezone conversions at `Time.EachTradeableDayInTimeZone`
- `TotalPortfolioValue` will iterate over all securities once
- Adding new `SecurityIdentifier` cache, significant impact for
algorithms using coarse/fine data
2019-06-05 17:06:59 -03:00
Jared 26f4a0a490 Merge pull request #3000 from Adalyat/bug-2874/custom-currency-length
Support custom currency length
2019-06-04 16:35:54 -07:00
Martin Molinero ee4f8fee82 Overall performance improvements
- `TimeSliceFactory` will avoid creating empty collections
- `ExecutionModels` will check target collection count before trying to
enumerate
- Reduce calls to .`TotalPortfolioValue`
- `SecurityValues` will only be created when required
- `TimeKeeper` will use TimeZone unique Id as dictionary key. The
TimeZone hash is expensive.
- `AlgorithmManager` will avoid calling `DateTime.UtcNow`,
`ConvertFromUtc()` and `RoundDownInTimeZone()`
2019-06-03 15:09:02 -03:00
Adalyat Nazirov 66a027c24f requested changes: change exception message 2019-06-01 20:27:30 +03:00
Adalyat Nazirov 069d632737 requested changes: extract Crypto.DecomposeCurrencyPair method 2019-06-01 20:27:30 +03:00
Adalyat Nazirov 5d335143e4 requested changes: use MarketHoursDatabase.GetDatabaseSymbolKey 2019-06-01 20:27:30 +03:00
Adalyat Nazirov 0fc894de81 decompose the crypto into each currency pair 2019-06-01 20:27:29 +03:00
Adalyat Nazirov 279e8128fa parse Crypto pair based on symbol props 2019-06-01 20:27:29 +03:00
Adalyat Nazirov 590b80cf84 allow account currency custom length 2019-06-01 20:27:29 +03:00
Stefano Raggi 9d3c1df5f3 Fix execution models to handle partially filled orders 2019-05-24 11:50:31 +02:00
Jared 87f03e68ca Merge pull request #3185 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-4
Add Various Symbols to Futures Database (Part 4 / 11)
2019-05-17 07:16:54 -07:00
Gerardo Salazar 074dbbfe2f Add dairy publication dates dating back to contract month 2012-03-01 2019-05-15 08:48:17 -07:00
Gerardo Salazar 298ee1e504 Replace invalid characters 2019-05-14 16:37:41 -07:00
Gerardo Salazar ce9664a2dd Add comment explaining use of two holiday lists for calculating nth business day 2019-05-14 10:52:15 -07:00
Gerardo Salazar fbc725d8dc Remove TODOs on completed futures expiry functions 2019-05-14 10:14:22 -07:00
Gerardo Salazar 44a4451ea3 Adds the following futures to futures database: BTC, ...
BWF, BZ, CB, CJY, CNH, CRB, CSC, CSW, CSX, CU, D1N, DC,
DCB, DY, E6, E7, EAD, ECD, EDP, EH
2019-05-10 17:39:51 -05:00
Stefano Raggi f7e06510d4 Fix missing front month contract in energy futures backtesting
Energy futures (CL, HO, RB, NG) expire in the month before the contract month.

To handle these properly, the following changes have been implemented:
- the AlgoSeekFuturesReader has been updated to create the future symbol with the correct expiry date
- the zip entry names in futures data files now contain the full expiry date (in addition to the contract month)
- the sample data files have been updated to use the new zip entry names
- new unit tests have been added and existing ones updated
2019-04-29 09:40:59 +02:00
Jared 806fd1ed4e Merge pull request #3094 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-3
Add Various Symbols To Futures Database (Part 3 / 11)
2019-04-23 17:34:05 -07:00
Stefano Raggi e5028e087f Remove usage of DateTime.UtcNow in buying power models (#3115)
Remove usage of DateTime.UtcNow in buying power models

In PR#3013 we added support for fee models with history, so the new changes to the GDAXFeeModel exposed this bug, breaking a couple of regression tests (issue #3044)

Update regression stats for EmitInsightCryptoCashAccountType

* Fix typos

Add missing time keeper in CashBuyingPowerModelTests
2019-04-23 07:38:39 -07:00
Gerardo Salazar 35b0d84247 Add the following futures to futures database: AGA, AJL, AJS, ...
AJY, AKL, AKZ, ANE, APS, AR0, ARE, AUP, AVZ, AW, AYV, AYX, AZ1, B0, B7H, BCF, BIO, BK, BOO, BR7

Correct wrong entry for symbol ZT in symbol-properties-database

Add missing holidays or early closes for energies and fx in mhdb
2019-04-22 17:16:47 -05:00
Martin Molinero 93479ca253 Reduce calls to TotalPortfolioValue
- For performance reduce the amount of call to `TotalPortfolioValue`
2019-04-22 16:40:37 -03:00
Martin Molinero c39638668c Overall performance improvements
- `FactorFile` will keep an ordered reversed list with the dates.
Calling `Reverse()` on the `SortedList` is expensive.
- `MapFiles` will keep first and last date, so we don't need to call
`First()` and `Last()` multiple times.
- `Liquidate` will go through all the algorithms securities only if
necessary
- `TradeBar` parsing will not call `new T` for pure `TradeBar` which is
expensive
- Removing `Lazy` hash code and security type for the
`SecurityIdentifier`, replacing for direct initialization. Accessing the
`Lazy` value adds an overhead.
- Replacing `Enum` to string for hardcoded switch statement. `Enum.ToString` is expensive.
- `DataManager` will be lazy for counting the subscriptions for
determining if its above the limit
- Adding `AlgorithmSecurityValuesProvider.GetAllValues()`, removes the
need to fetch all the security keys twice.
- During universe selection, will not try to re add already added symbol
2019-04-22 10:47:27 -03: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
Martin Molinero b7930aff67 Performance improvements
- Using `Aggregate(lambda)` vs `Sum(lambda)` since the later is slower
due to performing an extra `Select`
- For `QCAlgorithm.Framework.OnFrameworkData()` will avoid calling
`ToArray()` on empty `Enumerables` due to its cost * the number of
calls. If the `Enumerable` is the empty instance, which is static,
will create a new empty array and return it instead.
- Replacing `SecurityIdentifier` `SecurityType` and `GetHashCode`
implementations for `Lazy` versions, that are performed just once, since
these values do not change and are used multiple times.
- For the different `DataDictionary<T>` implementations adding `this[
Symbol] get; set` since existing overload `this [string]` produces an
extra round operations `Symbol->string->Symbol` with a significant
impact.
- Adding `PortfolioTargetCollection.AddRange()` overload using an array
to avoid unnecessary convertions.
2019-04-11 19:01:27 -03:00
Jared 6bf6c7c0e3 Merge pull request #3060 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-2
Add Various Symbols To Futures Database (Part 2 / 11)
2019-04-10 16:31:40 -07:00
Gerardo Salazar 26c2f2e36a Adds The Following Symbols To Futures Database: 6Z, A0D, A0F, A1L, ...
A1M, A1R, A32, A3G, A7E, A7I, A7Q, A8J, A8K, A8O, A91,
A9N, AA6, AA8, ABS, ABT, AC0, ACD, AD0, ADB, AE5
2019-04-04 17:03:57 -07: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
Jared 890ed36d0c Merge pull request #3014 from gsalaz98/feature-2991-add-expirations-to-futures-database-part-1
Add 1S, 22, 6L, 6R, 6M to Futures Database
2019-03-27 17:07:02 -07:00
Jared a0abd00fb2 Update SecurityTransactionManager.cs 2019-03-27 17:06:08 -07:00
AlexCatarino d7073f2f88 Adds Parameterless Overload to SecurityTransactionManager.CancelOpenOrders() 2019-03-22 22:35:42 +00:00
Gerardo Salazar 5e562c07c0 Use market hours database instead of custom FuturesExpiryCalendar
Added additional test cases for symbols 6L and 6M
2019-03-20 13:45:29 -07:00
Gerardo Salazar ea6d8ee088 Merge branch 'master' into feature-2991-add-expirations-to-futures-database-part-1 2019-03-18 19:52:47 -07:00
Gerardo Salazar 4d4f27f027 Add 1S, 22, 6L, 6M, 6R to futures database 2019-03-18 17:06:35 -07:00
AlexCatarino f4d5f0e458 Adds RTY, NKD, and YO to Future's Database
Adds Russell 2000 E-Mini (RTY), Nikkei 225 Dollar (NKD) and Sugar 11 CME Globex (YO) to future data: entails update entries in market hours and symbol properties databases.
Updates `FutureExpiryFunction` to handle these contracts expiration date.
2019-03-15 17:22:10 +00:00
Stefano Raggi d790830e78 Fix cashbook settlement for Oanda/FXCM CFD trades 2019-02-26 16:30:20 +01:00
Stefano Raggi 2428790704 Fix handling of CFD fills and positions 2019-02-22 11:56:57 +01:00
Martin Molinero 1b0bdd9b0b Adding SetAccountCurrency for backtesting
- Adding new `SetAccountCurrency()` for backtesting. Has to be called
before adding any `Security` or calling `SetCash()`, else will throw.
- Adding new Non account currency unit tests for `CashBuyingPower`,
`SecurityPortfolioModel`, `SecurityMarginModel`,
`SecurityPortfolioManager`, `Future/OptionMarginBuyingPowerModels`
- Adding new C# regression test using `SetAccountCurrency()`, one for
`CashBuyingPowerModel` and one for `SecurityMarginModel`
- Adding new Py and C# basic regression algorithms using
`SetAccountCurrency()`
- `Options` and `Futures` will use not use `AccountCurrency` as quote
Cash.
- `SecurityBenchmark` value will be in account currency
2019-01-25 14:54:43 -03: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 dbddeded9b Address reviews
- Add missing documentation on `CashAmount` equality operators
- Make `Holding.ConversionRate` nullable
2018-12-27 17:41:47 -03:00