Build & Test Lean / build (push) Has been cancelled
* Apply changes from #2146 on current master
Credit for most of these changes goes to https://github.com/viliwonka.
Rebasing three years of changes didn't go so well, so I manually
applied the changes in #2146 on the current master branch.
This commit attempts to represent the changes in #2146 as closely as
possible, no cleanup has been performed yet. Despite this, some changes
were inevitable because part of #2146 has been implemented another way
in the past three years.
* Clean up
* Process review comments
* Add tests
* symbol -> potentialConversionRateSymbol
* Ensure regression tests run/get data
* Fix broken test
* Process review comments
* Process review comments
* Simplify currency conversion logic
* Performance improvement, doc updates and test rename
* Rebase fixes
* Remove obsolete properties
Co-authored-by: Martin-Molinero <martin@quantconnect.com>
Build & Test Lean / build (push) Has been cancelled
* Use UniverseSettings.DataNormalizationMode for securities added in Algorithm
* Stop SubscriptionUtils from forcing Adjusted mode
* Return behavior to original and add comments
* nit typo
* Add regression
* Add unit test that verifies DataNormalizationMode can be altered manually by security
* Cleanup and add Py version of regression
* Update projects to use .NET 5.0, the successor to .NET Core
* Fix ambiguous errors. Add IBAutomator net5
* Remove FXCM
* Upgrade IBAutomater to v1.0.51
ignored, and an empty message aborts the commit.
* Fix rebase
- Fix ambiguous Index
- Remove StrategyCapacity.cs
- Update System.Threading.Tasks.Extensionsy
* Remove unrequired references
* Fixes
- Travis will use dotnet, not nunit nor mono
- Remove mono from foundation image
- Fix python setup in research
- Fix unit tests
* Don't call ReadKey when input is redirected
* Fix ConsoleLeanOptimizer
* Research fixes
* Update comment
* Add vsdbg to Dockerfile
* Fixes
- Revert dockerfile FROM custom changes
- Adjust and fix regression algorithms
- Option assignment will be deterministic in the order
- 'Rolling Averaged Population' is calculated using doubles, updating
expected values.
- Update readme, removing references to mono
- Add missing Py.Gil lock
* Replace ICSharp with .NET Interactive
* Fixes after rebase
* CSharp research fixes
- Adding new Initialize.csx that pre loads all assemblies
- Adjusting template research file
- Moving steps in dockerfilejupyter
- Fix unit tests and regression tests after rebase
Co-authored-by: Gerardo Salazar <gsalaz9800@gmail.com>
Co-authored-by: Stefano Raggi <stefano.raggi67@gmail.com>
Co-authored-by: Jasper van Merle <jaspervmerle@gmail.com>
* Refactor HasSufficientBuyingPowerForOrder implementations
Adds Sufficient and Insufficient helper methods to HashSufficientbuyingPowerForOrderParameters
enabling syntax like:
return paraeeters.Sufficient()
returnparameters.Insufficient(reason)
The next change will add the initial margin required which will simply require
updating both of these helper methods to accept the value.
* IBuyingPowerModel: Add margin functions Maintenance/Initial/ForOrder
These were originally hidden in an effort to only expose what's necessary
for the engine to perform its work. Additionally, we encapsulated all of
the method arguments into parameters classes to prevent having to break
anyone in the future. Not including these foundational methods turns out to
be an oversight. These methods are not required by the engine, but rather by
other models. Another possible solution here is to add an additional abstraction
and include these methods on this new abstraction. BuyingPowerModel would then
explicitly implement these methods and models that depend on them would require
two code paths, one for when the buying power model implements this interface
and another for when it doesn't.
Tests were additionally updated to remove test model implementations created for
the sole purpose of exposing these private methods.
* Add ConstantBuyingPowerModel
Provides an implementation of IBuyingPowerModel that returns the same
constant value
* Update BuyingPowerModelPythonWrapper to use reflection for method names
Having a bunch of hard-coded strings is a sure fire way for someone to
overlook when changing methods. This change ensures that noone needs to
remember that this code exists :)
Cleans up the syntax around verifying a python object implements a particular
C# interface via the ValidateImplementationOf<T> method by having it return a
value since the only use cases are in constructors when setting the models.
I was initially going to update ALL python wrappers to validate the passed
in models, but such a change could break many things that are 'working' right
now. Such an effort should be saved for its own dedicated PR.
* Add Parameters/Result types for new buying power model methods
* Support computing maintenance margin for arbitrary quantities
The existing GetMaintenanceMargin function assumes that we're only interested
in the maintenance margin for the entirety of the provided security's holdings.
This makes it impossible to perform what-if analysis or to even ask how much
maintenance margin is devoted to a particular subset of the security's holdings.
This change adds the quantity to the MaintenanceMarginParameters class. Futures
and Options models also depend on holdings cost and holdings value, so they have
also been added to the parameters type. Finally, static factory methods were
added to improve discernment of intent: ForCurrentHoldings provides the existing
behavior and then ForQuantityAtCurrentPrice to support what-if scenarios where
we're looking for the change in maintenance margin if we were to execute an order
for the securiy at the current time step. Obviously a constructor is provided to
set all of the values explicitly, using any price metric the caller desires.
* Address review
- Fix BPM xml documentation
- Fix python unit tests and PythonWrapper validate method
* Add SecurityHolding.QuantityChanged event
Adding event handlers will allow us to orchestrate complex
events from distant parts of the codebase through wiring
them up. If we continue down this path, it will move us away
from the current, very 'mechanical' data flows expressed in
LEAN and towards a more modern, event processing based system.
This is but a baby step in that direction and the initial use
case is using this QuantityChanged event to trigger resolution
of the algoritm's positions groups. This is part of an effort
to improve the fidelity of options margin modeling where we'll
model an OptionStrategy as an IPositionGroup. This will allow
us to compute the margin requirements of an OptionStrategy as
a unit instead of computing margin of each security individually
in isolation.
See #4065
* PortfolioManager: Group fields and remove unused field
This codebase generally places fields as the first members, but
this class had some fields at the top, then some properties, and
then some more fields. This change brings all the fields together
at the top of the file and also removes pointless comments placed
directly above some of the fields. Additionally, an unused field
was removed.
* Remove unused _currencyConverter from Security
Looks like at some point the only code using this member variable was removed
and the necessary clean up was overlooked.
* Add Parse.Enum functions
* Support disabling regression algorithms by language via config.json
Adds 'regression-test-languages' to config.json and filters regerssion algorithms to
run based on this value. When cycling on a particular feature, it's nice to be able
to run the entire regression set while ignoring the python algorithms. Once the C#
algorithms are all passing, one can then go back and run C# and Python in a final run,
since 99% of feature work doesn't impact python specifically.
* Implement IComparable in SecurityIdentitfier
This can be used to deterministically sort securities and symbols
* Add .editorconfig to enforce common formatting for json/sh files
* Fix typo in IBuyingPowerModel.GetBuyingPower xml docs
* Add ListEquals/GetListHashCode and OrderDirection.Closes(PositionSide)
ListEquals and GetListHashCode are designed to be used together as they
complement each other according to C#'s requirements for Equals and
GetHashCode functions.
PositionSide.ToOrderDirection() extension simply converts a PositionSide
to its logical equivalent OrderDirection. Long->Buy, Short->Sell, None->Hold
OrderDirection.Closes(PositionSide) determines if a particular OrderDirection
would have the effect of reducing a position's absolute size. This function
greatly improves the readability of buying power functions that must provide
adjustments when an order/contemplated trade reduces/closes an existing position.
OrderDirection.Buy.Closes(PositionSide.Short)
OrderDirection.Sell.Closes(PositionSide.Long)
All other combinations return false
Adds ToArray/ToImmutableArray convenience functions that combine a call
to Select followed by To(Immutable)Array all in one function call.
* Add decimal.DiscretelyRoundBy extension method
Supports rounding a decimal value by an arbitrarily chosen maximum precision,
or 'quanta'
* Update FutureMarginBuyingPowerModelTests to respect the security's lot size
* Add core position group classes and abstractions
* Add initial/maintenance margin support, buying power model consistency tests
* Add SufficientBuyingPower and GetReservedBuyingPower to position group model
Includes update to BrokerageTransactionHandler to use position group BPM for
sufficient buying power checks.
* Resolve position groups on each fill
We need to update the state of our position groups on each fill so that
we can properly handle multiple orders within the same time step. We
also limit the number of positions sent into the resolver by removing
securities without any holdings.
* fixup! Add SufficientBuyingPower and GetReservedBuyingPower to position group model
* Add GetMaximumLotsFor{Target|Delta}BuyingPower
Instead of computing order quantity, these functions compute the
maximum number of position group lots, which is the position group
quantity, and is guaranteed to be a whole number, for the provided
target/delta buying power parameters.
The SecurityPositionGroupBuyingPowerModel delegates to the security's
IBuyingPowerModel by applying a scaling factor equal to the security's
lot size.
This change also updates references to IBuyingPowerModel.GetMaximum...
to use the new position group model methods.
* Convert remaining IBuyingPowerModel call sites to position groups
* Rename PositionManasger.CreateDefaultGroup -> GetOrCreateDefaultGroup
Better describes its behavior
* Add Position Groups readme.md
* Add Option Strategy BuyingPowerModel
- Adding CompositePrositionGroupResolver and
OptionStrategyPositionGroupResolver
- Adding OptionStrategyPositionGroupBuyingPowerModel handling option
strategies based on IBs margin table. Adding regression algorithms
- Few changes so that option strategies executed by multiple orders are
detected
- Adjust OptionStrategyDefinitionMatch to include equity legs in the
matching result
- Minor tweaks fixing previous rebase
- Minor fixes for existing option strategies definitions, adding new
missing strategies.
- Fixing minor bugs in option strategy matcher. Adding more unit tests
* Address self reviews
- Fixing bug in 'PositionGroupCollection'
- Few minor simplificaitons
- Adding BasicTemplateOptionEquityStrategyAlgorithm
* Address reviews
- Improve regression algorithms margin remaining and used assert logic to be exact. Taking into account spread and fees
Co-authored-by: Michael Handschuh <mhandschuh@gmail.com>
* Improves greeks configurability and defaults for all option asset types
* Makes `StandardDeviationOfReturns` configurable by users, so that
greeks can be loaded according to user expectations and the series
of returns that they'd like to compute for `n` periods and timespan
of `T`, as well as resolution of the data in live mode.
* Changes resolution to max resolution available for the default
volatility model created for the security. Usually this only applies
to live mode, but if creating an instance of the
`StandardDeviationOfReturns` volatility model and no `updateFrequency`
is provided, the resolution's time span will be used as the default
value. Backwards compatibility for equities is maintained.
* Changes defaults for `StandardDeviationOfReturnsVolatilityModel`
to warmup greeks faster for other derivative asset types
* Improves comments on `StandardDeviationOfReturns` for clarity on how
to use the volatility model for end users
* Fixes bug where TradeBar could not have proper Symbol set when getting
max resolution
* Applies to QCAlgorithm.Universe and StandardDeviationOfReturnsVolatilityModel
* Adds tests to check volatility model is updated at specified config intervals
* Address review: add shared method for (Relative)StandardDeviation
volatility models
* Adjusts logic to determine bar type
* Address review: order by TickType when getting configs inside volatility models
- Testing net5 uncovered these algorithms to be undeterministic
- Adjusting AllShortableSymbolsCoarseSelectionRegressionAlgorithm
internal implementation
- Order removal of universe members will be deterministic, when the
entire universe is removed.
* Fixes Double to Decimal Cast in GetAnnualPerformance
`GetAnnualPerformance` raises an exception if the `AnnualPerformance` calculation returns a double that cannot be cast to decimal (smaller than `decimal.MinValue` or bigger than `decimal.MaxValue`).
See `ProbabilisticSharpeRatio` where the same solution was applied.
* Updates SPY Market Data
SPY is a key asset since it is the default benchmark, and any change can lead to different `Alpha` and `Beta`
* Updates Unit Tests to Reflect Data Update
* Updates Regression Tests to Reflect Data Update I
Most of the regression tests change because of updated data (market and factors) of SPY (default benchmark) while the total trade remain the same.
* Updates Regression Tests to Reflect Data Update II
The following regression tests were changed to adapt to adjusted prices and keep the total trades:
- `BacktestingBrokerageRegressionAlgorithm`
- `LimitIfTouchedRegressionAlgorithm`
- `PortfolioRebalanceOnCustomFuncRegressionAlgorithm`
- `SetAccountCurrencySecurityMarginModelRegressionAlgorithm`
- `StopLossOnOrderEventRegressionAlgorithm`
- `TimeInForceAlgorithm`
The following regression tests have more trades since adjusted prices allowed more 1-2 shares trades that were rounded down to zero before:
- `FreePortfolioValueRegressionAlgorithm` 2 -> 3
- `PortfolioRebalanceOnDateRulesRegressionAlgorithm` 291 -> 298
- `TrailingStopRiskFrameworkAlgorithm` 5 -> 7
Especial cases:
- `AutoRegressiveIntegratedMovingAverageRegressionAlgorithm` 65 -> 52
- ARIMA model sensibility
- `BlackLittermanPortfolioOptimizationFrameworkAlgorithm` 18 -> 19
- BLM model sensibility
- `ExtendedMarketHoursHistoryRegressionAlgorithm` 20 -> 18
- Less minute bars before market opens
* Addresses Peer-Review
Fix `BacktestingBrokerageRegressionAlgorithm` to use `CalculateOrderQuantity` and round down `quantity` to an even number to pass a value assertion and update the expected value from 50 to 52.
The quantity calculated by `CalculateOrderQuantity` has changed from 50 to 53 because of factor file update.
* Remove and replace OnEndOfDay() ref
* Restore functionality of obsolete EOD, waiting for deprecation in August 2021
* Cleanup
* Adjustments to only post message when using obsolete EOD
* nit, extra space
* Address review
* Adjust test to reflect new behaviour
* Move GetPythonArgCount to an extension method
* Add unit test
* nit accidental import
* Refactor broken test
* Use Py.GIL() state for extension
* Remove regression references to non-existant Python versions
* Adjust regressions estimated capacity not adjusted by #5389
* Adjusts regression algorithms so that they pass (Index/Index Options)
* Changes start/end date on BasicTemplateIndexAlgorithm
* Changes option pricing model to BlackScholes in
IndexOptionCallITMGreeksExpiryRegressionAlgorithm
- The root cause of why there are no greeks at times for these
options was identified. It is most likely due to the underlying's
VolatilityModel not having had enough data to be "warmed up",
which means it will return a standard deviation of zero to the
option pricing model, rendering most metrics as NaN.
* Adds missing index/index options regression algorithms
- Regression algorithms are now 1-1 between C# and Python for
Indexes/Index options. All regression tests are now passing
* Fixes broken BasicTemplateIndex regression algorithm
* Previously traded SPY, but because we have no SPY data in Lean
master, I instead opted for index options, since data for those
dates is already included
* Deal with weekend for breaking test case
* Adjust DefaultEndDate test to always pass
* Check todays date for open
Co-authored-by: Gerardo Salazar <gsalaz9800@gmail.com>
* Update to new QC PythonNet
* Update readme
* Remove Python.Runtime config, replaced by env var
* Allow local packages testing in repo
* Address Review
* Add the LocalPackages readme
* Update Jupyter Image
* Update Research ReadMe
* Filter values that are before subscription start time; also adjust starttime for OpenInterest
* Use data EndTime for comparison
* Allow Auxiliary data through
* Fix OpenInterest DataReader Logic
* Add regression
* Address review
* Ignore open interest for time slice
- TimeSliceFactory will directly ignore open interest for determining if
the slice has data or not. Open interest will still be available
through the Tick collection. Reverting some of the previous commits
changes since they are no longer required.
- HistoryRequests and SubscriptionRequest will use AlwaysOpen exchange
for open interest requests. Adding unit test reproducing issue
- Adding `BaseDataRequest` to avoid duplication logic.
* Make OpenInterest an internal feed and ignored by default in history
- Adding unit tests
* Revert SubscriptionFilterEnumerator Start time addition
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
* Adds LimitIfTouched order.
TODO:
-- Add tests.
-- Add into existing regression algorithms.
-- Refactors (?)
* Fixes
- Remove unrequired space changes
- Fix EquityFillModel min/max limit price fill
- Add TriggerPrice for UpdateOrderRequest.
Quote info used w.r.t. comparing against Limit prices for LIT
FillModel.cs implementation is fixed to use quotes when comparing against set limit prices.
Also changes test implementations to assert which of quotes/trade-bars are being used
Reviewer-suggested fixes
------------
Merge remote-tracking branch 'origin/limiftouched' into limiftouched
Styling
Adds missing null check for quotebar
Styling
Adds missing null check for quotebar
Merge remote-tracking branch 'origin/limiftouched' into limiftouched
High/Low w.r.t. trigger price for determining if TriggerTouched changed to Current price
https://github.com/QuantConnect/Lean/pull/5164/files/0462ad668a5fe65e771122165f36c72d56b92df6#r569832380
fill fixes:
FillModel.cs: Fills exactly at the limit
EquityFillModel.cs: https://www1.interactivebrokers.com/en/index.php?f=608
Equity fill now uses quotebars
Revert - use new constructor which emulates former SubmitOrderRequest
Style changes
Reverts order model to original by means if new constructor
High/Low w.r.t. trigger price for determining if TriggerTouched changed to Current price
https://github.com/QuantConnect/Lean/pull/5164/files/0462ad668a5fe65e771122165f36c72d56b92df6#r569832380
fill fixes:
FillModel.cs: Fills exactly at the limit
EquityFillModel.cs: https://www1.interactivebrokers.com/en/index.php?f=608
Equity fill now uses quotebars
Revert - use new constructor which emulates former SubmitOrderRequest
Style changes
Reverts order model to original by means if new constructor
Merge commit 'bf4c96d2a055ea808fa4293662528c11a89b72c7'
* Suggested style fixes
* Review fixes
-------------------
- Suggested style fixes
- Changes LIT regression to better incorporate order modifications
- TODO: orderlisthash must be fixed
Fixed LIT regression algo
-----------------------
- Includes asserts in OnOrderEvent
* Fix OrderListHash
OrderListHash -> -292689487
* Re-adds quote nullchecks
* EquityFillModelTests fixes asserts
* Reordering FillModel.cs
* Fixes quote logic, adds methods in FillModel.cs
* Refactoring + LIT regression fixes
-- revert unneeded changes
* Fixes list hash
* Rebase -- catch up upstream
* OrderListHash fix
* Various fixes by reviewer
* Final requested changes
* tagged time -> utcinvariant
* Fixes listorderhash
* Time changed to UtcTime.ToString(DateFormat.US, CultureInfo.InvariantCulture)
* Adds Python LimitIfTouchedRegressionAlgorithm
* adds LimitIfTouchedRegressionAlgorithm.py
* adds LimitIfTouchedRegressionAlgorithm.py
* Minor changes to LIT regression algorithms
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
* Some app.config files were kept to either enable features
that are only enable-able via the config files, or binding redirects
for DLLs that are not packaged with NuGet (i.e. VisualStudio
package, required to run tests successfully @ 15.0.0.0)
* Cleans history for ArimaIndicator/TimeSeriesIndicator.
-- removes commits from a tracked, already merged branch
-- removes artifacts from debugging sessions
* Removes AR/MA method as a user-specifiable method.
-- Prevents need to reference dll for MathNet in Tests (and potentially elsewhere).
-- Wrapper can be implemented around this functionality.
* Removes AR/MA method as a user-specifiable method.
-- Prevents need to reference dll for MathNet in Tests (and potentially elsewhere).
-- Wrapper can be implemented around this functionality.
* Better adherence to established code style
* Makes _intercept = true by default in constructor where it is not parameter
* WIP -- addressing reviews
* Passing tests following prior refactor
* Rearranged code, access modifiers adjusted
* Fixed indexing of _mafits, adds example algorithm
* Adds regression algo in python + addresses some refactors
* Addresses review
* Adds regression stats
* Fixes missing value signs
* Removes redundant code
* style changes
* style changes
* style: "err" -> "error"
* Minor tweaks
* Fixes python arima regression test
* Refactors AutoregressiveIntegratedMovingAverageTests.cs
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
* Include MortgageRateVolatilityAlpha and fixes
* Include PlaceHolder PythonAlgorithm.cs
* Delete BinanceUtil
* Remove unused Regression Algorithms
* Minor tweaks
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
* Adjust delisting liquidation time
- Adjust delisting liquidation time to 15 min before market closes.
Adding unit tests. Updating existing.
- Handle `Statistics.CompoundingAnnualPerformance` invalid calculation
to avoid exception.
- AlgorithmManager will not handle delisting events in live trading
- Fix bug where due to a split driven liquidation matching delisting
date a position in the option would remain open. Reproduced by
`BasicTemplateOptionsFrameworkAlgorithm`
* Address review
- Address review add documentation on delisting offset span
* Have BrokerageModel determine default benchmark
* Add DefaultBenchmark to Python wrapper
* Handle Null benchmark case
* Add NullBenchmarkRegressionAlgorithm
* Refactor solution to have BrokerageModel return IBenchmark; also refactor QCAlgorithm benchmark handling
* Always create a new security for benchmark
* Drop security overload, Always create a new security for benchmark
* Check our securities for a symbol matching the ticker before creating a new one
* No Python version of this regression
* Address review
* Create shared SecurityBenchmark creator function
* Add Python regression and needed FuncBenchmark constructor
* Fix delisted liquidation orders being cancelled
- Place delisted liquidation orders 10 min before market closes of 10
min before the end of the delisting warning date. Adding regression
test and unit tests. Updating existing tests.
* Fix failing python option unit tests
* Fix bug where positions would be open delisting liquidation
* Fix universe selection and delisting
- Delisting will happen ASAP for all types. Giving priority to close
positions on derivates first
- Fix bug in universe selection where OptionChain would remove
underlying even if holding a position in derivate.
- Updating regression tests statistics
* Add unit test, fix unit test expected stats
* Fixes ETB/shortable regression algorithms that were previously failing
* Addresses review and fixes bug
* Fixes bug where orders would be denied regardless of direction
whenever they exceeded the absolute value of the shortable quantity
* Updates regression algorithm + statistics + simplifies test
* Fixes python regression algorithm
* Addresses review: removes comments and unneeded imports
* Migrate to newer CSProj format; build succesful
Rebase onto master
* Maintain binaries directory
* Reinstate FSharp default condition
* Remove reference to packages.config
* Test project fixes
* Remove nuget.config and "Solution Items"
* Remove repetitive assembly info
* Reinstate default compiles and cleanup redundant settings
* Reinstate any specific settings that defaults are unclear for
* Reinstate Framework.nuspec
* Make test internal classes public for composer use; undo assembly change
Rebase onto master part 2
* Address review; restore some settings
* Restore RootNamespace and AssemblyName attributes
* Use NugetPackageRoot instead of NugetPackageFolders
* Reinstate "RestorePackages" setting
* Transfer compilied Python files to launcher and tests bin
* Remove conflicting settings
* Fix WebSocketSharpFork references
* Fix FSharp Core reference
* Upgrade TestPlatform.ObjectModel to 16.8.3, and redirect V11 binding
* Add Mono.Cecil package
* Address review
* Add interface to allow custom security entries for MHDB and SPD
* Simplify adding custom Properties and MarketHours via AddData overload
* Refactor
* Remove AddData and GetDatabaseSymbolKey overloads
* Add unit tests
* Remove AddData overload, for real.
* Nit changes
* Set CustomDataBitcoinAlgorithm back to original
* Add Python and C# Regression
* nit typo
* nit typo actual
* Reset symbol property to default
* Reflect last change to py regression
* Revert "Remove AddData overload, for real."
This reverts commit dc877495c079f17dda1695494ffe36886b1c117e.
* Implement AddData solution fully
* Function nit fix
* Address review
* nit - remove param comment
* Address review
* Adds FuturesOptionsUnderlyingMapper
This adds a mapper for Futures options that have a different
contract month between the FOP and the underlying future, as is
observed in the contracts ZB, ZC, ZS, ZT, ZW, HG, SI, GC.
An example of this is GC (e.g. OGH21 -> GCJ21). Other contracts follow
different rules, which have been included as part of this commit.
* Adds unit tests for FuturesOptionsUnderlyingMapper
* Adds unit and regresssion tests for underlying Futures mapping for FOPs
* Addresses review and adds FuturesListings
* Removes dependency on IFuturesChainProvider in
FuturesOptionsUnderlyingMapper
* Fixes bugs related to FuturesOptionsUnderlyingMapper and incorrect
results
* Modifies misc. code to handle new results correctly from FOPs
underlying mapper
* Makes FOPs underlying mapper static, and makes other methods private
* Adds new tests for FuturesListings
* Addresses review: code cleanup
* Address review: Makes arrays to List in FuturesListing private methods
* fill forward data points until expiry date
* wip: test non Delisting
* handle Aux not-Delisting dp; keep order while ff'ing
* simplify test checks
* wip
* fix liquidation expected date
* change statistics
* check EndTime, because it's used for time synchronization
* clean up code; remove duplicated test
* Fixes intraday delistings not occurring for Futures and FOPs
* Previously, we would wait until the next market open to
liquidate futures and futures options contracts. Since these
contracts can not be traded at the next market open and require
intraday delisting, changes were made to liquidate at the first
available place where we know the market is open. This means
we now liquidate futures and FOPs intraday as a market order.
* Maintains backwards compatability with equities and equity options
delisting behavior
* Addresses review: adds additional protections for ProcessDelistedSymbols
* We choose to adjust the delisting date to the next market open only
if the market is not open at the current time, otherwise the time
would have been adjusted to the market open of the next trading day
* Addresses review: reverts changes and fixes error message in regression algo
* Fixed Python runtime issue that was occurring when trying to generate reports locally on OSX/mono, but assume the issue impacts all configurations.
* Move Python.Runtime config to common
* Remove duplicate files
* Update readme
* Typo
* Change destination in build directory
Co-authored-by: Charles Naccio <cnaccio@gmail.com>
* Adds preliminary universe selection for Future Options
* Fixes scaling issues with Future Options
* Fixes scaling multiplying by 10000x instead of using _scaleFactor
* Fixes scaling for Tick
* Revert changes to Tick since it divides the scaling factor
* Changes stale method name to new method name after rebase
* Fixes selection bugs, adds new methods, and adds unit tests
* Fixes bug where Equity Symbol was created for an underlying
non-equity Symbol, resulting in equity data trying to be loaded
* Adds unit tests covering changes to Tick, QuoteBar, TradeBar and
LeanData
* Adds regression test for AddUniverseOption filter contract selection
for Future Options
* Addresses review - modifies the AddFutureOption signature
* Adds new AddUniverseOptions method overload
* Removes and adds a new unit test
* Misc. modifications to account for new changes
* Fixes bug where futures were loaded using default SID Date
* Refactors and removes unnecessary work
* Fixes regression algorithm, which previously made no trades
* Adds future option data
* Adds the corresponding underlying data, in this case, futures data
to enable usage of future options data
* Replaces data with new data (ES18Z20)
* Improves Future chain filtering and updates regression stats
* Add AddFutureOptionContract API
* Expands regression and unit tests to test in finer detail
* Adds Python regression algorithms for AddFutureOption[Contract] methods
* Adds new unit test for BacktestingOptionChainProvider
* Fixes bug with BacktesingOptionChainProvider where we
attempted to load the Trades option chain first, resulting
in breakage of backwards compatibility and limitation of the
option chain.
* Adds new regression algorithms (Py) to Algorithm.Python project
* Adds FutureOptionMarginBuyingPowerModel
* Modifies code paths used to select margin model
* Adds related unit tests for margin model
* Fixes issue with unit test and MHDB/SPDB lookup for Future Options
* Preliminary regression algorithm testing ITM call/put option buying
* Fixes bug where fee model used did not find non-US market
options fee model. We now use the futures fee model for future
options because IB charges the same commissions per contract
between futures and futures options
* Adds proper regression algorithm for ITM future options expiration
* Pushing broken algorithm for review
* Currently, algorithm does not fill forward, causing
a single future option to not get exercised when it is delisted.
* Adds FutureOptionPutITMExpiryRegressionAlgorithm
* Improves existing regression algorithm for call side
* Fixes bug in existing regression algorithm
* Adds AAPL daily data to advance enumerator for ^^^ fix
* Adds additional future option regression algorithms
* Adds Buy OTM expiration regression algorithms
* Adds Sell ITM/OTM expiration regression algorithms
* Adds missing Python regression algorithms
* Adds remaining Python regression algorithms and fixes issues
* Fixes naming issues and statistics
* Adds short option OTM regression algorithms (Py)
* Add license header and class comments to python algorithms
* Cleans up comments and docstrings
* Create Buy/Sell call intraday regression algo
* Redirects future options symbol properties to futures symbol properties
* Asserts exercise/assignment price and updates stats in regression algos
* Adds new unit test covering changes to SecurityService
* Adds comments and fixes failing test
* Partially fixes future option mis-calculated profit/loss
* Adjusts portfolio model to calculate FOP as a no upfront pay asset class
* Updates regression algorithm statistics
* Begin IB FOP support
* Initial support for FOP IB data streaming, live í¾
* Adds additional functionality to LiveOptionChainProvider
- Allows querying CME API to retrieve option chains for CME products
- Ultimately, it's also the groundwork for the CME
LiveFutureChainProvider
* Edits IDataQueueUniverseProvider interface to provide greater
control to implementors of it
* Misc. bug fixes required to get FOP data streaming through IB
* Adds comments, adds missing rategate call, and cleans up code
* Force exchange for FOP and Futures when no exchange is provided
* Fixes bug with Portfolio modeling across all asset classes
* Adds LiveOptionChainProvider tests for Future Options
* IB brokerage option symbol bug fixes and improvements
* Fixes contract multiplier lookup bug
* Fixes issue where we attempted to subscribe to IB data feed with canonical security
* Adds ES MHDB entry
* Reverts portfolio modeling changes for Futures Options
* Since IB eats into our account's cash balance when
a new FOP contract is purchased, we must model by applying funds
to our cash whenever a new purchase/sell occurs.
If we choose to model FOPs exactly as we do with futures, we
will end up with an invalid TotalPortfolioValue on algorithm
restart. By all means and purposes, FOPs are modeled exactly
the same as equity options with respect to the portfolio.
* Adds comments clarifying portfolio modeling and clarifies
existing portfolio modeling comments with additional context.
* Fixes IB symbol lookup for future options
* Fixes LiveOptionChainProvider looping 5 times per option chain
request, even on success
* Sets OptionChainedUniverseSelectionModel to produce a canonical
future/future option/option Symbol to avoid creating two Symbols
* Adds GLOBEX future option symbol mapping from future -> fop
* Fixes LiveOptionChainProvider loading wrong contract option chains
* Fixes loading of futures options ZIP files when backtesting
* Adds a string -> decimal JSON converter
* Additional fixes/refactoring to the LiveOptionChainProvider
* Adds tests for changes to Symbol and LeanData
* Reverts changes to IB-symbol-map
* Fixes Value for mapped future options tickers
* Fixes Symbol test
* Changes path of future options to future's expiry date
* Extra changes made to remove scaling from writing CSV
* Added method to map from FOP Globex -> FUT Globex
* Fixes MOO and MOC orders for future options
* Note: this order type might not be supported by IB or CME.
* Bug fixes and updates unit tests
* Update regression tests and data format
* Rebase changes
* 1. Multiple bug fixes for LiveOptionChainProvider, reverts IQFeed changes
2. Address review (partial): Code reuse and cleanup
1.
* Modifies check in
`AddFutureOptionShort(Call|Put)ITMExpiryRegressionAlgorithm`
to ensure no buys have negative quantity
* Code reuse changes in IB brokerage
* Bug fix in IB brokerage where we assigned the FOP expiry
as the futures expiry (requires verification)
* Doc changes and adds missing summaries/license banners
* Disposes of HTTP client resources in LiveOptionChainProvider
* Renames classes and adds FutureOption folder in Common/Securities
2.
* We revert back to the quotes API for the option chain,
since the settlement API sometimes had missing strikes.
* Fixes future option expiry being set as future's expiry
in LiveOptionChainProvider
* Fixes bug where wrong option chain was selected because of bad
expiry lookup in the futures expiries returned from CME
* Fixes multiple looping bug in LiveOptionChainProvider
* Adds strike price scaling for LiveOptionChainProvider
* Reverts IQFeed changes and simplifies interface upgrade changes
Some additional challenges we'll have to solve as part of FOPs:
- The `OptionSymbol.IsStandard` method makes the assumption that
weeklies contracts follow the pattern equities follows, which
does not apply to Futures Options
- The Subscription created in:
`OptionChainUniverseSubscriptionEnumeratorFactory`
...adds a Trade config. For illiquid contracts, this
will delay universe selection for the option symbol
until we get a trade. However, if we add a quote config,
the data would instead be loaded based on the first quote
we received from the brokerage.
But since we're currently using a trade config, illiquid
contracts won't start streaming data until it receives a trade.
NOTE: this commit is a WIP to addressing the reviews received in the PR,
but has been committed early for efficiency in the review process
* Fixes regression algorithms and misc. bugs
* Fixes map file lookup for non-equity options
* Adds extra assertion at end of algorithm to ensure no holdings are
left when the algorithm ends.
* Adds FutureOptionSymbol, allowing all contracts through as standard
* Changes SPDB to allow defaulting to underlying future symbol
properties if no entry is found for the given FOP
* Fixes calls to SPDB in SecurityService, IBBrokerage
* Reverts AAPL daily ZIP file to fix majority of regression algorithms
* Adds FOPs symbol properties
* Fixes existing symbol properties for a few futures
* Adds tests for changes to Symbol Properties Database
* Removes string SPDB lookup method
* Updates tests and misc callees of previous method
* Updates all regression tests to use data of already expired contracts
* Adds Futures Options Expiry Functions tests
* Adds required futures data for 2020-01-05
* Address review (partial): Expands test coverage and fixes tests
* Set option chain tests parallelism to fixture only
* Fixes broken test for contract month delta for FuturesOptionsExpiryFunctions
* Changes delisting date logic for Futures Options
* Address review: removes duplicate code, misc code fixes
* Bug fix in MarketHoursDatabase.GetDatabaseSymbolKey() where
we would use the underlying's Symbol for lookup in the MHDB
* Adds missing license banner
* Removes Futures Options entries from MHDB
* Adds new tests
* Adds SecurityType.FutureOption
* Converts any underlying comparisons and uses SecurityType directly
instead for FOP specific behavior
* Extra code modifications to acommodate new SecurityType
* Addresses review: fixes order fee bug on exercise
* Additional bug fixes and adding of SecurityType.FutureOption
* Updates regression algorithms OrderListHash
* Fixes various bugs in IB live implementation
* Fixes bug setting the right contract expiration date for FOP
generated by LiveOptionChainProvider
* Adds new function to FuturesOptionsExpiryFunctions
* Clarifies parameter names better in some functions/methods
* Fixes bugs in IB brokerage for FOPs
* Address review - code cleanup and refactor
* Remove MappingEventProvider, SplitEventProvider, and
DividendEventProvider for Futures Options in
CorporateEventEnumeratorFactory
* Address review: Use MHDB key resolver in SPDB
* Makes regression tests pass and adds comment for expiry issue
* Fixes MHDB lookup on string symbol method
* Adds Futures Options greeks regression algorithm (C# only)
* Adds explanitory comment on MHDB FOP lookup
* Remove python from FutureOptionCallITMGreeksExpiryRegressionAlgorithm
* Remove python stubs directory
- Removing python stubs directory since after https://github.com/QuantConnect/Lean/pull/4899
it was been replaced by a python package `quantconnect-stubs`.
- Reverting IDE settings using the stubs folder PR https://github.com/QuantConnect/Lean/pull/4657
* Revert "Adds Python stubs location definition for PyCharm and Visual Studio Code (#4657)"
This reverts commit aded66ec5b.
* Address self-review: Provide list of imports and refactor python readme
Co-authored-by: Gerardo Salazar <gsalaz9800@gmail.com>
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Delete QuiverHouseDataDownloader.cs
* Delete QuiverSenateDataDownloader.cs
* Delete QuiverPoliticalBetaDataDownloader.cs
* Add files via upload
* Delete QuiverHouse.cs
* Delete QuiverSenate.cs
* Delete QuiverPoliticalBeta.cs
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Add files via upload
* Delete QuiverDataAlgorithm.cs
* Add files via upload
* Add files via upload
* Add files via upload
* Addresses self review: Cleans up code and adds new unit tests
* Adds Quiver* C# files to project
* Adds new unit test for QuiverCongress
* Adds Python algorithm example
* Address self reviews
- Adding some missing xml docs
- Removing unrequired imports.
- Minor rename from Date to ReportDate
- Live trading will throw InvalidOperationException
* Fixes for example algorithms
Co-authored-by: Gerardo Salazar <gsalaz9800@gmail.com>
Co-authored-by: Martin Molinero <martin.molinero1@gmail.com>
* Adds CustomBuyingPowerModelAlgorithm
This algorithms is an example on how to implement a custom buying power model.
In this particular case, it shows how to override `HasSufficientBuyingPowerForOrder` in order to place orders without sufficient buying power according to the default model.
* Upgrades CustomModelsAlgorithm to Include CustomBuyingPowerModel
The custom buying power model overrides `HasSufficientBuyingPowerForOrderResult` but it doesn't change the trades and, consequently, the regression statistics.
* OptionChain and OptionContract improvements
- QCAlgorithm.AddUniverse will return the added Universe instance.
- Adding new OptionChainedUniverseSelectionModel will monitor a Universe changes
and will spwan new OptionChainUniverse from it's selections. Adding
regression test Py/C#.
- Adding new OptionContractUniverse that will own option contracts and
their underlying symbol. Adding regression test
- Fix double notification for security changes, bug seen in updated
UniverseSelectionRegressionAlgorithm
- Remove UniverseSelection special handling for Option and Future chains
- Fix DataManager not removing SubscriptionDataConfigs for Subscriptions
which finished before being removed from the universe
- Refactor detection of user added Universe so that they do not get
removed after calling the UniverseSelectionModel
* Add check for option underlying price is set
* Address reviews
- Adding python regression algorithm for
`AddOptionContractFromUniverseRegressionAlgorithm`
and `AddOptionContractExpiresRegressionAlgorithm`
- Rename QCAlgorithm new api method to `AddChainedOptionUniverse`
* Fix universe refresh bug
- Fix bug where a universe selection refresh would cause option or
future chain universes from being removed. Adding regression algorithm
reproducing the issue.
* Rename new option universe Algorithm API method
- Rename new option universe Algorith API method from
AddChainedOptionUniverse to AddUniverseOptions
- Rebase and update regression test order hash because of
option expiration message changed