- Adding new regression test algorithm
- `SecurityPortfolioManager` will subscribe to the `CashBook.Updated`
event to invalidate the `TotalPortfolioValue
- `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`
- 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
- `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()`
- `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
- Adding _some_ of the missing PyObject.Dispose calls. In the cases
where C# is calling the Python side.
- Note that Python calls to C# code is correctly handling the
disposure of resources.
- This commit is related to PR 19 in QC/pythonnet
- C# decimal will be cast to C# double and converted into python
float
- Adding new `decimal.py` into the python algorithm project. This is
required for backwards compatibility with users performing operations
over expected decimal types (like `Price`)
- Updating two python regression test algorithms using custom python
execution models to be aware and ignore floating point precision errors
when handling order sizing.
Instead of letting `PyObject.AsManagedObject` throw an exception because the types do not match, we check whether the target type is assignable from the python object type.
This PR fixes PR #2102 that caused a bug in Symbol[] convertion.
Unit tests were added to test all changes.
Instead of letting `PyObject.AsManagedObject` throw an exception because the types do not match, we check whether the target type is assignable from the python object type.
When a python class is a subclass of a C# class, `Extensions.TryConvert` should return `false`. Currenty it was returnig true and the result was reduced to the parent class.
The exception in ignored because the generator isn't closed until it is being deleted (automatically in this case, when Python exits); the generator __del__ handler closes the generator, which triggers an exception of there is one.
We enable Logging and Debug methods to accept python objects to avoid the need of calling the str method.
Those objects are safely converted into string objects.
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.
If we make a prediction for 1 day in the future, we actually mean 1 trading day.
This change updates the alpha analysis logic to take into account the security's
market hours.
The properties in the default instance can be modified by users duing Initialize.
These properties are always copied into all new orders submitted with any method available (Order, SetHoldings, etc.)
- Created public property on ITransactionHandler that wraps the private OrderTicket dictionary. Allows BrokerageSetupHandler to add the order tickets
Refactored ToOrderTicket extension method to handle several types of order
In order to correctly determine the expiry for futures contracts, Lean
will programmatically determine the expiry date from the expiry year and
month. A general method is created in this PR for adding more expiry date
functions. The expiry dates have been tested against expiry dates listed
on the CME website.