Commit Graph

26 Commits

Author SHA1 Message Date
Martin Molinero 49abcd08b3 Normalize and improve Zero security price message 2020-05-13 21:19:37 -03:00
Martin Molinero 6eb45baa59 Refactor GetMaximumOrderQuantityForTargetBuyingPower
- Refactoring `GetMaximumOrderQuantityForTargetValue` into
`GetMaximumOrderQuantityForTargetBuyingPower` which algorithm uses
margin
- Reducing code duplication
- Adding unit tests
- Fixing futures margin model. Adding intra day logic.
2020-02-04 18:41:15 -03:00
Martin Molinero 2f9814f2f9 Add SetHoldings for collection of targets
- Adding `SetHoldings` implemenetation for a collection of portfolio
targets
- Adding regression test
- Some performance improvements
2019-11-05 13:47:42 -03:00
Martin Molinero 0e7c035329 Adding FreePortfolioValue
- Adding `FreePortfolioValue` to be set after algorithm initialize based
on the `TotalPortfolioValue` and the `FreePortfolioValuePercentage`
- Updating regression tests
- Adding new regression test
- Adding check for minimum order value at `BuyingPowerModel`
2019-10-23 13:56:35 -03:00
Martin Molinero 9ec1a41235 Performance improvements
- `PortfolioTargetCollection` avoid calling `Count` on
ConcurrentDictionary directly -> has to take all locks
- `SecurityChanges` change Union for Concat since constructor will call
HashSet
- Make `DynamicSecurityData` hold lazy data objects
- `RegisteredSecurityDataTypesProvider` avoid looping over all
registered types, adding `TryGetType`
- `Security.Update()` will no call group by on data since this data is
already grouped by type. Adding `ContainsFillForwardData` will allows to
be lazy and not re loop through the data unless necessary
- `DefaultAlphaHandler` will use the `static`
`Enumerable.Empty<Insight>` instance when possible
- `SubscriptionSynchronizer` will be lazy to construct the
`universeData` dictionary which is not used in most of the times. Will
use `Count` vs `Any` -> `Count` is known by the dictionary
- For python algorithms `JobQueue` will respect `AlgorithmLocation`, was
using unexisting `"algorithm-path-python"`
2019-10-17 10:26:37 -03:00
Michael Handschuh d709d1c4e0 Update Common to respect CA1304 and CA1305
Updates all occurrences of parsing/ToString-ing to go through the new
StringExtensions methods that use CultureInfo.InvariantCulture

See #3045
2019-09-12 14:13:24 -04: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
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
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 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
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
Stefano Raggi bd4c799d2b Rename parameter classes from Context to Parameters 2018-11-29 22:05:49 +01:00
Stefano Raggi 78f3b4b099 Refactor additional IBuyingPowerModel methods to use context objects 2018-11-27 22:50:15 +01:00
Martin Molinero 83897a7b88 Portfolio target percent respects FreePortfolioValuePercentage 2018-08-28 12:03:56 -03:00
Stefano Raggi f0e81155e8 Fix error message in PortfolioTarget.Percent 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
Martin Molinero 6da57a1e12 Improving GetMaximumOrderQuantityForTargetValue 2018-08-03 16:26:14 -03:00
Martin Molinero c73b7bb62f Adding smarter methods for PortfolioTargetCollection 2018-07-27 10:48:55 -03:00
Stefano Raggi 7bc991a621 Update execution models to execute trades ordered by margin impact 2018-06-22 18:07:13 +02:00
Michael Handschuh af9202952e PortfolioTarget.ToString - <symbol>: <quantity>
IMO, this was backwards from the beginning. This ordering makes for
better, more intuitive logs.
2018-04-06 16:48:49 -04:00
Michael Handschuh 92c5e64024 Adds VWAP and STD execution models
VWAP will submit market orders while the current price is more favorable than VWAP.
STD will submit market orders while the current price is a configured number of
standard deviations away from the mean in the favorable direction.
2018-04-06 16:30:26 -04:00
Michael Handschuh b1e624dfdc Fixes bug in PortfolioTarget.Percent
Buying power model's GetMaximumOrderQuantityForTargetValue returns the
delta quantity needed to reach a particular position, so we need add
back in the existing quantity to get the total quantity required.
2018-04-02 11:30:13 -04:00
Michael Handschuh 48c691c2bb Use buying power model in PortfolioTarget.Percent
Also adds convenience ToString override
2018-03-26 16:42:25 -04:00
Michael Handschuh f700bc0a6e Add Signal and Portoflio PercentChange convenience mehtods 2017-12-14 15:44:52 -05:00
Michael Handschuh 24cebd2aa1 Move signal/target data structures to common
Since these are really just data structures they belon in the common library. Also,
it stands to reason that we'll want to reuse them in other components, such as the
result handler.
2017-12-08 10:07:54 -05:00