instruction
stringclasses
1 value
input
stringlengths
81
758
output
stringlengths
420
23.9k
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm is for testing a custom Python filter for options that returns a OptionFilterUniverse.
```python from AlgorithmImports import * class FilterUniverseRegressionAlgorithm(QCAlgorithm): underlying_ticker = "GOOG" def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 28) self.set_cash(100000) equity = self.add_equity(self.underlying_ti...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to validate SecurityCache.Session functionality. Verifies that daily session bars (Open, High, Low, Close, Volume) are correctly
```python from AlgorithmImports import * class SecuritySessionRegressionAlgorithm(QCAlgorithm): def initialize(self): self.add_security_initializer(self.initialize_session_tracking) self.initialize_security() # Check initial session values session = self.security.session ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting that tick history request includes both trade and quote data
```python from AlgorithmImports import * class HistoryTickRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 12) self.set_end_date(2013, 10, 13) self._symbol = self.add_equity("SPY", Resolution.TICK).symbol trades_count = 0 quotes_coun...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to assert the behavior of <see cref="EmaCrossAlphaModel"/>.
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Alphas.EmaCrossAlphaModel import EmaCrossAlphaModel class EmaCrossAlphaModelFrameworkRegressionAlgorithm(BaseFrameworkRegressionAlgorithm): def initialize(self): super().initialize...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of how to define a universe using the fundamental data
```python from AlgorithmImports import * from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel class FundamentalUniverseSelectionRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 3, 26) self.set_end_date(2014, 4, 7) sel...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of how to define a universe using the fundamental data
```python from AlgorithmImports import * class FundamentalUniverseSelectionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 3, 25) self.set_end_date(2014, 4, 7) self.universe_settings.resolution = Resolution.DAILY self.add_equity("SPY") self.add_e...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Test algorithm using 'QCAlgorithm.add_risk_management(IRiskManagementModel)'
```python from AlgorithmImports import * class AddRiskManagementAlgorithm(QCAlgorithm): '''Basic template framework algorithm uses framework components to define the algorithm.''' def initialize(self): ''' Initialise the data and resolution required, as well as the cash and start-end dates for your ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Basic Continuous Futures Template Algorithm with extended market hours
```python from AlgorithmImports import * class BasicTemplateContinuousFutureWithExtendedMarketAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end date...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Asserts that algorithms can be universe-only, that is, universe selection is performed even if the ETF security is not explicitly added. Reproduces https://github.com/QuantConnect/Lean/issues/7473
```python from AlgorithmImports import * class UniverseOnlyRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 12, 1) self.set_end_date(2020, 12, 12) self.set_cash(100000) self.universe_settings.resolution = Resolution.DAILY # Add universe ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to use the OptionUniverseSelectionModel to select options contracts based on specified conditions. The model is updated daily and selects different options based on the current date. The algorithm ensures that only valid option co...
```python from AlgorithmImports import * class AddOptionUniverseSelectionModelRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 6, 5) self.set_end_date(2014, 6, 6) self.option_count = 0 self.universe_settings.resolution = Resolution.MINUTE ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Abstract regression framework algorithm for multiple framework regression tests
```python from AlgorithmImports import * class BaseFrameworkRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 6, 1) self.set_end_date(2014, 6, 30) self.universe_settings.resolution = Resolution.HOUR self.universe_settings.data_normalization_mode =...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Shows how to set a custom benchmark for you algorithms
```python from AlgorithmImports import * class CustomBenchmarkAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10,7) #Set Start...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting the behavior of specifying a null position group allowing us to fill orders which would be invalid if not
```python from AlgorithmImports import * class NullMarginMultipleOrdersRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) self.set_cash(10000) # override security position group model self.portfolio.s...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of using custom buying power model in backtesting. QuantConnect allows you to model all orders as deeply and accurately as you need.
```python from AlgorithmImports import * class CustomBuyingPowerModelAlgorithm(QCAlgorithm): '''Demonstration of using custom buying power model in backtesting. QuantConnect allows you to model all orders as deeply and accurately as you need.''' def initialize(self): self.set_start_date(2013,10,...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration algorithm for the Warm Up feature with basic indicators.
```python from AlgorithmImports import * class WarmupAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10,8) #Set Start Date ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression test tests for the loading of futures options contracts with a contract month of 2020-03 can live and be loaded from the same ZIP file that the 2020-04 contract month Future Option contract lives in.
```python from AlgorithmImports import * class FutureOptionMultipleContractsInDifferentContractMonthsWithSameUnderlyingFutureRegressionAlgorithm(QCAlgorithm): def initialize(self): self.expected_symbols = { self._create_option(datetime(2020, 3, 26), OptionRight.CALL, 1650.0): False, ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to use the FutureUniverseSelectionModel to select futures contracts for a given underlying asset. The model is set to update daily, and the algorithm ensures that the selected contracts meet specific criteria. This also includes a...
```python from AlgorithmImports import * class AddFutureUniverseSelectionModelRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2013, 10, 10) self.set_universe_selection(FutureUniverseSelectionModel( timedelta(d...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm asserts that futures have data at extended market hours when this is enabled.
```python from AlgorithmImports import * class FutureContractsExtendedMarketHoursRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 6) self.set_end_date(2013, 10, 11) es_future_symbol = Symbol.create_future(Futures.Indices.SP_500_E_MINI, Market.CME, dat...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting 'OnWarmupFinished' is being called
```python from AlgorithmImports import * class OnWarmupFinishedRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10, 8) ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example algorithm to demostrate the event handlers of Brokerage activities
```python from AlgorithmImports import * class BrokerageActivityEventHandlingAlgorithm(QCAlgorithm): ### <summary> ### Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. ### </summary> def initialize(self): ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This algorithm demonstrates the runtime addition and removal of securities from your algorithm. With LEAN it is possible to add and remove securities after the initialization.
```python from AlgorithmImports import * class AddRemoveSecurityRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10,7) ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Simple indicator demonstration algorithm of MACD
```python from AlgorithmImports import * class MACDTrendAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2004, 1, 1) #Set Start Dat...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example demonstrating how to access to options history for a given underlying equity security.
```python from AlgorithmImports import * class BasicTemplateOptionsHistoryAlgorithm(QCAlgorithm): ''' This example demonstrates how to get access to options history for a given underlying equity security.''' def initialize(self): # this test opens position in the first day of trading, lives through ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm demonstrating the use of custom data sourced from the object store
```python from AlgorithmImports import * class CustomDataObjectStoreRegressionAlgorithm(QCAlgorithm): custom_data = "2017-08-18 01:00:00,5749.5,5852.95,5749.5,5842.2,214402430,8753.33\n2017-08-18 02:00:00,5834.1,5904.35,5822.2,5898.85,144794030,5405.72\n2017-08-18 03:00:00,5885.5,5898.8,5852.3,5857.55,145721790,...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This algorithm showcases two margin related event handlers. OnMarginCallWarning: Fired when a portfolio's remaining margin dips below 5% of the total portfolio value OnMarginCall: Fired immediately before margin call orders are execued, this gives the algorith...
```python from AlgorithmImports import * class MarginCallEventsAlgorithm(QCAlgorithm): """ This algorithm showcases two margin related event handlers. on_margin_call_warning: Fired when a portfolio's remaining margin dips below 5% of the total portfolio value on_margin_call: Fired immediately before ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm used to test a fine and coarse selection methods returning Universe.UNCHANGED
```python from AlgorithmImports import * class UniverseUnchangedRegressionAlgorithm(QCAlgorithm): def initialize(self): self.universe_settings.resolution = Resolution.DAILY # Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and reduce fees. ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting the behavior of Universe.SELECTED collection
```python from AlgorithmImports import * class UniverseSelectedRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 3, 25) self.set_end_date(2014, 3, 27) self.universe_settings.resolution = Resolution.DAILY self._universe = self.add_universe(self.se...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm reproducing data type bugs in the RegisterIndicator API. Related to GH 4205.
```python from AlgorithmImports import * from CustomDataRegressionAlgorithm import Bitcoin class RegisterIndicatorRegressionAlgorithm(QCAlgorithm): # Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. def initialize(self):...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Tests the delisting of the composite Symbol (ETF symbol) and the removal of the universe and the symbol from the algorithm.
```python from AlgorithmImports import * class ETFConstituentUniverseCompositeDelistingRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 12, 1) self.set_end_date(2021, 1, 31) self.set_cash(100000) self.universe_symbol_count = 0 self.univers...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Algorithm demonstrating the usage of custom brokerage message handler and the new brokerage-side order handling/filtering. This test is supposed to be ran by the CustomBrokerageMessageHandlerTests unit test fixture. All orders are sent from the brokerage, non...
```python from AlgorithmImports import * class CustomBrokerageSideOrderHandlingRegressionPartialAlgorithm(QCAlgorithm): '''Algorithm demonstrating the usage of custom brokerage message handler and the new brokerage-side order handling/filtering. This test is supposed to be ran by the CustomBrokerageMessageH...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : In this algorithm we show how you can easily use the universe selection feature to fetch symbols to be traded using the BaseData custom data system in combination with the AddUniverse{T} method. AddUniverse{T} requires a function that will return the symbols t...
```python from AlgorithmImports import * import base64 class DropboxUniverseSelectionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2017, 7, 4) self.set_end_date(2018, 7, 4) self._backtest_symbols_per_day = {} self._current_universe = [] self....
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm showing how to implement a custom universe selection model and asserting it's behavior
```python from AlgorithmImports import * from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel class CustomUniverseSelectionModelRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014,3,24) self.set_end_date(2014,4,7) self.un...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting the behavior of the indicator history api
```python from AlgorithmImports import * class IndicatorHistoryRegressionAlgorithm(QCAlgorithm): '''Regression algorithm asserting the behavior of the indicator history api''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algor...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of how to use custom security properties. In this algorithm we trade a security based on the values of a slow and fast EMAs which are stored in the security itself.
```python from cmath import isclose from AlgorithmImports import * class SecurityCustomPropertiesAlgorithm(QCAlgorithm): '''Demonstration of how to use custom security properties. In this algorithm we trade a security based on the values of a slow and fast EMAs which are stored in the security itself.''' ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting that using separate coarse & fine selection with async universe settings is not allowed
```python from AlgorithmImports import * class CoarseFineAsyncUniverseRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Base regression algorithm exercising different style options with option price models that might or might not support them. Also, if the option style is supported, greeks are asserted to be accesible and have valid values.
```python from AlgorithmImports import * class OptionPriceModelForOptionStylesBaseRegressionAlgorithm(QCAlgorithm): def __init__(self) -> None: super().__init__() self._option_style_is_supported = False self._check_greeks = True self._tried_greeks_calculation = False self....
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm tests that we only receive the option chain for a single future contract in the option universe filter.
```python from AlgorithmImports import * class AddFutureOptionSingleOptionChainSelectedInUniverseFilterRegressionAlgorithm(QCAlgorithm): def initialize(self): self.invested = False self.on_data_reached = False self.option_filter_ran = False self.symbols_received = [] self....
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to assert the behavior of <see cref="MacdAlphaModel"/>.
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Alphas.MacdAlphaModel import MacdAlphaModel class MacdAlphaModelFrameworkRegressionAlgorithm(BaseFrameworkRegressionAlgorithm): def initialize(self): super().initialize() s...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Tests that orders are denied if they exceed the max shortable quantity.
```python from AlgorithmImports import * class RegressionTestShortableProvider(LocalDiskShortableProvider): def __init__(self): super().__init__("testbrokerage") class ShortableProviderOrdersRejectedRegressionAlgorithm(QCAlgorithm): def initialize(self): self.orders_allowed = [] self...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm tests using FutureOptions daily resolution
```python from AlgorithmImports import * class FutureOptionHourlyRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 7) self.set_end_date(2020, 1, 8) resolution = Resolution.HOUR # Add our underlying future contract self.es = self.add_fut...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Universe Selection regression algorithm simulates an edge case. In one week, Google listed two new symbols, delisted one of them and changed tickers.
```python from AlgorithmImports import * class UniverseSelectionRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014,3,22) #Set Start Date self.set_end_date(2014,4,7) #Set End Date self.set_cash(100000) #Set Strategy Cash ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of using the ETFConstituentsUniverseSelectionModel with simple ticker
```python from AlgorithmImports import * from Selection.ETFConstituentsUniverseSelectionModel import * from ETFConstituentsFrameworkAlgorithm import ETFConstituentsFrameworkAlgorithm class ETFConstituentsFrameworkWithDifferentSelectionModelAlgorithm(ETFConstituentsFrameworkAlgorithm): def initialize(self): ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example algorithm showing and asserting the usage of the "ShortMarginInterestRateModel" paired with a "IShortableProvider" instance, for example "InteractiveBrokersShortableProvider"
```python from AlgorithmImports import * class ShortInterestFeeRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10, 7) ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This is an option split regression algorithm
```python from AlgorithmImports import * class OptionRenameRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_cash(1000000) self.set_start_date(2013,6,28) self.set_end_date(2013,7,2) option = self.add_option("TFCFA") # set our strike/expiry filter for this...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Tests the delisting of the composite Symbol (ETF symbol) and the removal of the universe and the symbol from the algorithm, without adding a subscription via AddEquity
```python from AlgorithmImports import * class ETFConstituentUniverseCompositeDelistingRegressionAlgorithmNoAddEquityETF(QCAlgorithm): def initialize(self): self.set_start_date(2020, 12, 1) self.set_end_date(2021, 1, 31) self.set_cash(100000) self.universe_symbol_count = 0 ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to add options for a given underlying equity security. It also shows how you can prefilter contracts easily based on strikes and expirations. It also shows how you can inspect the option chain to pick a specific option contract to...
```python from AlgorithmImports import * class BasicTemplateOptionsFilterUniverseAlgorithm(QCAlgorithm): underlying_ticker = "GOOG" def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 28) self.set_cash(100000) equity = self.add_equity(self.und...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of using coarse and fine universe selection together to filter down a smaller universe of stocks.
```python from AlgorithmImports import * class CoarseFineFundamentalComboAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2014,1,1) #...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Mean Variance Optimization algorithm Uses the HistoricalReturnsAlphaModel and the MeanVarianceOptimizationPortfolioConstructionModel to create an algorithm that rebalances the portfolio according to modern portfolio theory
```python from AlgorithmImports import * from Portfolio.MeanVarianceOptimizationPortfolioConstructionModel import * class MeanVarianceOptimizationFrameworkAlgorithm(QCAlgorithm): '''Mean Variance Optimization algorithm.''' def initialize(self): # Set requested data resolution self.universe_...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Basic template algorithm for the Axos brokerage
```python from AlgorithmImports import * class BasicTemplateAxosAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algo...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm for testing parameterized regression algorithms get valid parameters.
```python from AlgorithmImports import * class GetParameterRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.check_parameter(None, self.get_parameter("non-existing"), "GetParameter(\"non-existing\")") self.check_parameter("100", self.get_parame...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm show casing and asserting the behavior of creating a consolidator specifying the start time
```python from AlgorithmImports import * from collections import deque class ConsolidatorStartTimeRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 4) self.set_end_date(2013, 10, 4) self.add_equity("SPY", Resolution.MINUTE) consolidator = Trad...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Framework algorithm that uses the EmaCrossUniverseSelectionModel to select the universe based on a moving average cross.
```python from AlgorithmImports import * from Alphas.ConstantAlphaModel import ConstantAlphaModel from Selection.EmaCrossUniverseSelectionModel import EmaCrossUniverseSelectionModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel class EmaCrossUniverseSelection...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to add options for a given underlying equity security. It also shows how you can prefilter contracts easily based on strikes and expirations. It also shows how you can inspect the option chain to pick a specific option contract to...
```python from AlgorithmImports import * class BasicTemplateOptionTradesAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) self.set_cash(100000) option = self.add_option("GOOG") # add the initial contract filt...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example algorithm showing that Slice, Securities and Portfolio behave as a Python Dictionary
```python from AlgorithmImports import * class PythonDictionaryFeatureRegressionAlgorithm(QCAlgorithm): '''Example algorithm showing that Slice, Securities and Portfolio behave as a Python Dictionary''' def initialize(self): self.set_start_date(2013,10, 7) #Set Start Date self.set_end_date...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example structure for structuring an algorithm with indicator and consolidator data for many tickers.
```python from AlgorithmImports import * class MultipleSymbolConsolidationAlgorithm(QCAlgorithm): # Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. def initialize(self) -> None: # This is the period of bars we'...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to test we can specify a custom settlement model, and override some of its methods
```python from AlgorithmImports import * from CustomBrokerageModelRegressionAlgorithm import CustomBrokerageModel class CustomSettlementModelRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10,7) self.set_end_date(2013,10,11) self.set_cash(10000) se...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Algorithm demonstrating and ensuring that Bybit crypto brokerage model works as expected
```python from AlgorithmImports import * class BybitCryptoRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2022, 12, 13) ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example algorithm implementing VolumeShareSlippageModel.
```python from AlgorithmImports import * from Orders.Slippage.VolumeShareSlippageModel import VolumeShareSlippageModel class VolumeShareSlippageModelAlgorithm(QCAlgorithm): _longs = [] _shorts = [] def initialize(self) -> None: self.set_start_date(2020, 11, 29) self.set_end_date(2020, 12...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm tests In The Money (ITM) index option expiry for short calls. We expect 2 orders from the algorithm, which are: * Initial entry, sell SPX Call Option (expiring ITM) * Option assignment Additionally, we test delistings for index ...
```python from AlgorithmImports import * class IndexOptionShortCallITMExpiryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2021, 1, 4) self.set_end_date(2021, 1, 31) self.set_cash(1000000) self.portfolio.set_margin_call_model(MarginCallModel.NULL); ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Hourly regression algorithm trading ADAUSDT binance futures long and short asserting the behavior
```python from AlgorithmImports import * class BasicTemplateCryptoFutureHourlyAlgorithm(QCAlgorithm): # <summary> # Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. # </summary> def initialize(self): sel...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : EMA cross with SP500 E-mini futures In this example, we demostrate how to trade futures contracts using a equity to generate the trading signals It also shows how you can prefilter contracts easily based on expirations. It also shows how you can inspect the fu...
```python from AlgorithmImports import * class FuturesMomentumAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2016, 1, 1) self.set_end_date(2016, 8, 18) self.set_cash(100000) fast_period = 20 slow_period = 60 self._tolerance = 1 + 0.001 s...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm is expected to stop executing after Initialization. Related to GH 6168 issue
```python from AlgorithmImports import * class QuitInInitializationRegressionAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algori...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Tests filtering in coarse selection by shortable quantity
```python from AlgorithmImports import * class AllShortableSymbolsCoarseSelectionRegressionAlgorithm(QCAlgorithm): def initialize(self): self._20140325 = datetime(2014, 3, 25) self._20140326 = datetime(2014, 3, 26) self._20140327 = datetime(2014, 3, 27) self._20140328 = datetime(2...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of the parameter system of QuantConnect. Using parameters you can pass the values required into C# algorithms for optimization.
```python from AlgorithmImports import * class ParameterizedAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013, 10, 7) #Set Start...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting the behavior of a ScheduledUniverse
```python from AlgorithmImports import * class BasicTemplateAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10, 7) self.s...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to get access to futures history for a given root symbol. It also shows how you can prefilter contracts easily based on expirations, and inspect the futures chain to pick a specific contract to trade.
```python from AlgorithmImports import * class BasicTemplateFuturesHistoryAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2013, 10, 9) self.set_cash(1000000) extended_market_hours = self.get_extended_market_hours() # Subs...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm illustrating the usage of the <see cref="QCAlgorithm.FuturesChains(IEnumerable{Symbol}, bool)"/> method to get multiple futures chains.
```python from AlgorithmImports import * class FuturesChainsMultipleFullDataRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 7) es_future = self.add_future(Futures.Indices.SP_500_E_MINI).symbol gc_future = self....
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Futures framework algorithm that uses open interest to select the active contract.
```python from AlgorithmImports import * class OpenInterestFuturesRegressionAlgorithm(QCAlgorithm): expected_expiry_dates = {datetime(2013, 12, 27), datetime(2014,2,26)} def initialize(self): self.universe_settings.resolution = Resolution.TICK self.set_start_date(2013,10,8) self.set...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm tests Out of The Money (OTM) future option expiry for calls. We expect 2 orders from the algorithm, which are: * Initial entry, buy ES Call Option (expiring OTM) - contract expires worthless, not exercised, so never opened a po...
```python from AlgorithmImports import * class FutureOptionCallOTMExpiryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 5) self.set_end_date(2020, 6, 30) self.es19m20 = self.add_future_contract( Symbol.create_future( Future...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting we can specify a custom Shortable Provider
```python from AlgorithmImports import * class CustomShortableProviderRegressionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_cash(10000000) self.set_start_date(2013,10,4) self.set_end_date(2013,10,6) self._spy = self.add_security(SecurityType.EQUITY, "SPY", Reso...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm testing history requests for <see cref="OptionUniverse"/> type work as expected and return the same data as the option chain provider.
```python from AlgorithmImports import * class OptionUniverseHistoryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 25) self.set_end_date(2015, 12, 25) option = self.add_option("GOOG").symbol historical_options_data_df = self.history(option...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Basic template framework algorithm uses framework components to define the algorithm.
```python from AlgorithmImports import * class BasicTemplateFrameworkAlgorithm(QCAlgorithm): '''Basic template framework algorithm uses framework components to define the algorithm.''' def initialize(self): '''initialise the data and resolution required, as well as the cash and start-end dates for y...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to test universe additions and removals with open positions
```python from AlgorithmImports import * class InceptionDateSelectionRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10,1) self.set_end_date(2013,10,31) self.set_cash(100000) self.changes = None self.universe_settings.resolution = Resolut...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of the Market On Close order for US Equities.
```python from AlgorithmImports import * class MarketOnOpenOnCloseAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10,7) #Set St...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm illustrating the usage of the <see cref="QCAlgorithm.OptionChain(Symbol)"/> method to get an option chain, which contains additional data besides the symbols, including prices, implied volatility and greeks. It also shows how this data can...
```python from AlgorithmImports import * from datetime import timedelta class OptionChainFullDataRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) self.set_cash(100000) goog = self.add_equity("GOOG").symbol ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression test is a version of "MarketOnCloseOrderBufferRegressionAlgorithm"
```python from AlgorithmImports import * class MarketOnCloseOrderBufferExtendedMarketHoursRegressionAlgorithm(QCAlgorithm): '''This regression test is a version of "MarketOnCloseOrderBufferRegressionAlgorithm" where we test market-on-close modeling with data from the post market.''' _valid_order_ticket ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm testing history requests for <see cref="FutureUniverse"/> type work as expected and return the same data as the futures chain provider.
```python from AlgorithmImports import * class OptionUniverseHistoryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 11) self.set_end_date(2013, 10, 11) future = self.add_future(Futures.Indices.SP_500_E_MINI).symbol historical_futures_data_d...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : def initialize(self) -> None:
```python from AlgorithmImports import * # <summary> # Regression algorithm to test the behaviour of ARMA versus AR models at the same order of differencing. # In particular, an ARIMA(1,1,1) and ARIMA(1,1,0) are instantiated while orders are placed if their difference # is sufficiently large (which would be due to t...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : In this algorithm we show how you can easily use the universe selection feature to fetch symbols to be traded using the BaseData custom data system in combination with the AddUniverse{T} method. AddUniverse{T} requires a function that will return the symbols t...
```python from AlgorithmImports import * class DropboxBaseDataUniverseSelectionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.universe_settings.resolution = Resolution.DAILY # Order margin value has to have a minimum of 0.5% of Portfolio value, allows filtering out small trades and ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm checks that adding data via AddData works as expected
```python from AlgorithmImports import * from QuantConnect.Data.Custom.IconicTypes import * class CustomDataIconicTypesAddDataRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 11) self.set_cash(100000) twx_equity...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Using rolling windows for efficient storage of historical data; which automatically clears after a period of time.
```python from AlgorithmImports import * class RollingWindowAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2013,10,1) #Set Start Da...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to implement a cross moving average for the futures front contract
```python from AlgorithmImports import * class EmaCrossFuturesFrontMonthAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2013, 10, 10) self.set_cash(1000000) future = self.add_future(Futures.Metals.GOLD) # Only consider th...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : The demonstration algorithm shows some of the most common order methods when working with CFD assets.
```python from AlgorithmImports import * class BasicTemplateCfdAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_account_currency('EUR') ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This algorithm tests and demonstrates EUREX futures subscription and trading: - It tests contracts rollover by adding a continuous future and asserting that mapping happens at some point. - It tests basic trading by buying a contract and holding it until expir...
```python from AlgorithmImports import * class BasicTemplateEurexFuturesAlgorithm(QCAlgorithm): def __init__(self): super().__init__() self._continuous_contract = None self._mapped_symbol = None self._contract_to_trade = None self._mappings_count = 0 self._bought_q...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Strategy example algorithm using CAPE - a bubble indicator dataset saved in dropbox. CAPE is based on a macroeconomic indicator(CAPE Ratio), we are looking for entry/exit points for momentum stocks CAPE data: January 1990 - December 2014 Goals: Capitalize in o...
```python # QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. # Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This example demonstrates how to add futures for a given underlying asset. It also shows how you can prefilter contracts easily based on expirations, and how you can inspect the futures chain to pick a specific contract to trade.
```python from AlgorithmImports import * class BasicTemplateFuturesAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2013, 10, 10) self.set_cash(1000000) self.contract_symbol = None # Subscribe and set our expiry filter for...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Example algorithm using and asserting the behavior of auxiliary data handlers
```python from AlgorithmImports import * class AuxiliaryDataHandlersRegressionAlgorithm(QCAlgorithm): def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.set_start_date(2007, 5,...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm asserting slice.get() works for both the alpha and the algorithm
```python from AlgorithmImports import * trade_flag = False class SliceGetByTypeRegressionAlgorithm(QCAlgorithm): def initialize(self) -> None: '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.se...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm illustrating how to request history data for continuous contracts with different depth offsets.
```python from AlgorithmImports import * class HistoryWithDifferentContinuousContractDepthOffsetsRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 6) self.set_end_date(2014, 1, 1) self._continuous_contract_symbol = self.add_future(Futures.Indices.SP_50...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm testing portfolio construction model control over rebalancing, specifying a date rules, see GH 4075.
```python from AlgorithmImports import * class PortfolioRebalanceOnDateRulesRegressionAlgorithm(QCAlgorithm): def initialize(self): ''' Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.universe_setti...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstration of how to initialize and use the Classic RenkoConsolidator
```python from AlgorithmImports import * class ClassicRenkoConsolidatorAlgorithm(QCAlgorithm): '''Demonstration of how to initialize and use the RenkoConsolidator''' def initialize(self) -> None: self.set_start_date(2012, 1, 1) self.set_end_date(2013, 1, 1) self.add_equity("SPY", Re...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This algorithm demonstrate how to use Option Strategies (e.g. OptionStrategies.STRADDLE) helper classes to batch send orders for common strategies. It also shows how you can prefilter contracts easily based on strikes and expirations, and how you can inspect t...
```python from AlgorithmImports import * class BasicTemplateOptionStrategyAlgorithm(QCAlgorithm): def initialize(self): # Set the cash we'd like to use for our backtest self.set_cash(1000000) # Start and end dates for the backtest. self.set_start_date(2015,12,24) self.se...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to test we can liquidate our portfolio holdings using order properties
```python from AlgorithmImports import * class CanLiquidateWithOrderPropertiesRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 6, 5) self.set_end_date(2014, 6, 6) self.set_cash(100000) self.open_exchange = datetime(2014, 6, 6, 10, 0, 0) ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression test to demonstrate importing and trading on custom data.
```python import json from AlgorithmImports import * class CustomDataRegressionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2020,1,5) # Set Start Date self.set_end_date(2020,1,10) # Set End Date self.set_cash(100000) # Set Strategy Cash ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm to demonstrate the use of SetBenchmark() with custom data
```python from AlgorithmImports import * class CustomDataBenchmarkRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2017, 8, 18) # Set Start Date self.set_end_date(2017, 8, 21) # Set End Date self.set_cash(100000) # Set Strategy Cash self.add_equity("...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : This regression algorithm is expected to stop executing after Initialization. Related to GH 6168 issue
```python from AlgorithmImports import * class QuitAfterInitializationRegressionAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your alg...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Minute resolution regression algorithm trading Coin and USDT binance futures long and short asserting the behavior
```python from AlgorithmImports import * class BasicTemplateCryptoFutureAlgorithm(QCAlgorithm): # <summary> # Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized. # </summary> def initialize(self): self.set_...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Regression algorithm for the SpreadExecutionModel. This algorithm shows how the execution model works to submit orders only when the price is on desirably tight spread.
```python from AlgorithmImports import * from Alphas.RsiAlphaModel import RsiAlphaModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel from Execution.SpreadExecutionModel import SpreadExecutionModel class SpreadExecutionModelRegressionAlgorithm(QCAlgorithm): ...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Demonstrates how to create a custom indicator and register it for automatic updated
```python from AlgorithmImports import * from collections import deque class CustomIndicatorAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2013,10,7) self.set_end_date(2013,10,11) self.add_equity("SPY", Resolution.SECOND) # Create a QuantConnect indicat...
You are a quantive developer and need to generate code for use in QuantConnect's LEAN algorithm framework.
Generate a LEAN Algorithm that can be described like this : Show cases how to use the CompositeAlphaModel to define.
```python from AlgorithmImports import * from Alphas.RsiAlphaModel import RsiAlphaModel from Alphas.EmaCrossAlphaModel import EmaCrossAlphaModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel class CompositeAlphaModelFrameworkAlgorithm(QCAlgorithm): '''Sh...