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 : Algorithm illustrating how to manually set market hours and symbol properties database entries to be picked up by the algorithm's securities. This specific case illustrates how to do it for CFDs to match InteractiveBrokers brokerage, which has different market...
```python from AlgorithmImports import * import Newtonsoft.Json as json class ManuallySetMarketHoursAndSymbolPropertiesDatabaseEntriesAlgorithm(QCAlgorithm): ''' Algorithm illustrating how to manually set market hours and symbol properties database entries to be picked up by the algorithm's securities. ...
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 is a regression test for issue #2018 and PR #2038.
```python from AlgorithmImports import * class OptionDataNullReferenceRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2016, 12, 1) self.set_end_date(2017, 1, 1) self.set_cash(500000) self.add_equity("DUST") option = self.add_option("DUST") ...
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 using the history provider to retrieve data to warm up indicators before data is received.
```python from AlgorithmImports import * class WarmupHistoryAlgorithm(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,5,2) #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 : The demonstration algorithm shows some of the most common order methods when working with FutureOption assets.
```python from AlgorithmImports import * class BasicTemplateFutureOptionAlgorithm(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, 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 : This example demonstrates how to execute a Call Butterfly option equity strategy It adds options for a given underlying equity security, and shows how you can prefilter contracts easily based on strikes and expirations
```python from AlgorithmImports import * class BasicTemplateOptionEquityStrategyAlgorithm(QCAlgorithm): underlying_ticker = "GOOG" def initialize(self) -> None: self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) equity = self.add_equity(self.underlying_ticker) ...
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 of custom fill model for security to only fill bars of data obtained after the order was placed. This is to encourage more pessimistic fill models and eliminate the possibility to fill on old market data that may not be relevant.
```python from AlgorithmImports import * class ForwardDataOnlyFillModelAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10,1) self.set_end_date(2013,10,31) self.security = self.add_equity("SPY", Resolution.HOUR) self.security.set_fill_model(ForwardDataOnlyFi...
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 on how to access order tickets right after placing an order.
```python from datetime import timedelta from AlgorithmImports import * class OrderTicketAssignmentDemoAlgorithm(QCAlgorithm): '''Demonstration on how to access order tickets right after placing an order.''' def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 11...
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 fee, slippage, fill, and buying power models for modeling transactions in backtesting. QuantConnect allows you to model all orders as deeply and accurately as you need. This example illustrates how Lean exports its API to Python c...
```python from AlgorithmImports import * import random class CustomModelsPEP8Algorithm(QCAlgorithm): '''Demonstration of using custom fee, slippage, fill, and buying power models for modeling transactions in backtesting. QuantConnect allows you to model all orders as deeply and accurately as you need.''' ...
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 as a combination of use the coarse fundamental data and fine fundamental data
```python from AlgorithmImports import * class CoarseFineFundamentalRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014,3,24) #Set Start Date self.set_end_date(2014,4,7) #Set End Date self.set_cash(50000) #Set Strategy Cash self.uni...
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 the functionality of the CompositeIndicator using either a lambda expression or a method reference.
```python from AlgorithmImports import * class CompositeIndicatorWorksAsExpectedRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 4) self.set_end_date(2013, 10, 5) self.add_equity("SPY", Resolution.MINUTE) close = self.identity("SPY", Resolutio...
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 giving an introduction into using IDataConsolidators. This is an advanced QC concept and requires a certain level of comfort using C# and its event system. What is an IDataConsolidator? IDataConsolidator is a plugin point that can be used to...
```python from AlgorithmImports import * class DataConsolidationAlgorithm(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 a future option chain.
```python from AlgorithmImports import * class FutureOptionChainFullDataRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 6) self.set_end_date(2020, 1, 6) future_contract = self.add_future_contract( Symbol.create_future(Futures.Indices.SP_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 : The regression algorithm showcases the utilization of a custom data source with the Sort flag set to true. This means that the source initially provides data in descending order, which is then organized into ascending order and returned in the 'on_data' functi...
```python from AlgorithmImports import * class DescendingCustomDataObjectStoreRegressionAlgorithm(QCAlgorithm): descending_custom_data = [ "2024-10-03 19:00:00,173.5,176.0,172.0,175.2,120195681,4882.29", "2024-10-02 18:00:00,174.0,177.0,173.0,175.8,116275729,4641.97", "2024-10-01 17:00: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 : Basic Continuous Futures Template Algorithm
```python from AlgorithmImports import * class BasicTemplateContinuousFutureAlgorithm(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 algorit...
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 sends portfolio targets to CrunchDAO API once a week.
```python from AlgorithmImports import * class CrunchDAOSignalExportDemonstrationAlgorithm(QCAlgorithm): crunch_universe = [] def initialize(self) -> None: self.set_start_date(2023, 5, 22) self.set_end_date(2023, 5, 26) self.set_cash(1_000_000) # Disable automatic exports a...
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 and regression algorithm asserting the behavior of registering and unregistering an indicator from the engine
```python from AlgorithmImports import * class UnregisterIndicatorRegressionAlgorithm(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 : Regression algorithm testing GH feature 3790, using SetHoldings with a collection of targets which will be ordered by margin impact before being executed, with the objective of avoiding any margin errors
```python from AlgorithmImports import * class SetHoldingsMultipleTargetsRegressionAlgorithm(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(201...
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 portfolio target tags usage
```python from AlgorithmImports import * class PortfolioTargetTagsRegressionAlgorithm(QCAlgorithm): '''Algorithm demonstrating the portfolio target tags usage''' def initialize(self): self.set_start_date(2013,10,7) #Set Start Date self.set_end_date(2013,10,11) #Set End Date 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 : Demonstration of using the Delisting event in your algorithm. Assets are delisted on their last day of trading, or when their contract expires. This data is not included in the open source project.
```python from AlgorithmImports import * class DelistingEventsAlgorithm(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, 15) #Set Star...
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 showing how to easily convert an old algorithm into the framework. 1. When making orders, also create insights for the correct direction (up/down/flat), can also set insight prediction period/magnitude/direction 2. Emit insights befo...
```python from AlgorithmImports import * class ConvertToFrameworkAlgorithm(QCAlgorithm): '''Demonstration algorithm showing how to easily convert an old algorithm into the framework.''' fast_ema_period = 12 slow_ema_period = 26 def initialize(self): '''Initialise the data and resolution req...
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 asserting that consolidated bars are of type `QuoteBar` when `QCAlgorithm.consolidate()` is called with `tick_type=TickType.QUOTE`
```python from AlgorithmImports import * class CorrectConsolidatedBarTypeForTickTypesAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 7) symbol = self.add_equity("SPY", Resolution.TICK).symbol self.consolidate(symbol, tim...
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 Scheduled Events features available in QuantConnect.
```python from AlgorithmImports import * class ScheduledEventsAlgorithm(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 : Show example of how to use the TrailingStopRiskManagementModel
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Risk.TrailingStopRiskManagementModel import TrailingStopRiskManagementModel class TrailingStopRiskFrameworkRegressionAlgorithm(BaseFrameworkRegressionAlgorithm): '''Show example of how to u...
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 how to use QCAlgorithm.train method
```python from AlgorithmImports import * from time import sleep class TrainingExampleAlgorithm(QCAlgorithm): '''Example algorithm showing how to use QCAlgorithm.train method''' def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 14) self.add_equity("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 : Regression algorithm asserting that the option chain APIs return consistent values for index options. See QCAlgorithm.OptionChain(Symbol) and QCAlgorithm.OptionChainProvider
```python from datetime import datetime from AlgorithmImports import * from OptionChainApisConsistencyRegressionAlgorithm import OptionChainApisConsistencyRegressionAlgorithm class IndexOptionChainApisConsistencyRegressionAlgorithm(OptionChainApisConsistencyRegressionAlgorithm): def get_test_date(self) -> 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 : Regression algorithm illustrating the usage of the <see cref="QCAlgorithm.OptionChains(IEnumerable{Symbol})"/> method to get multiple option chains, which contains additional data besides the symbols, including prices, implied volatility and greeks. It also sh...
```python from AlgorithmImports import * from datetime import timedelta class OptionChainsMultipleFullDataRegressionAlgorithm(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"...
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 demonstrate how to use the UniverseSettings to define the data normalization mode (raw)
```python from AlgorithmImports import * class RawPricesUniverseRegressionAlgorithm(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.''' # what resolution should the 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 : Algorithm asserting that closed orders can be updated with a new tag
```python from AlgorithmImports import * class CompleteOrderTagUpdateAlgorithm(QCAlgorithm): _tag_after_fill = "This is the tag set after order was filled." _tag_after_canceled = "This is the tag set after order was canceled." def initialize(self) -> None: 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 : Regression algorithm for the StandardDeviationExecutionModel. This algorithm shows how the execution model works to split up orders and submit them only when the price is 2 standard deviations from the 60min mean (default model settings).
```python from AlgorithmImports import * from Alphas.RsiAlphaModel import RsiAlphaModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel from Execution.StandardDeviationExecutionModel import StandardDeviationExecutionModel class StandardDeviationExecutionModelRe...
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 of the Identity indicator with the filtering enhancement. Filtering is used to check the output of the indicator before returning it.
```python from AlgorithmImports import * class FilteredIdentityAlgorithm(QCAlgorithm): ''' Example algorithm of the Identity indicator with the filtering enhancement ''' def initialize(self): self.set_start_date(2014,5,2) # Set Start Date self.set_end_date(self.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 algorithm asserts we can consolidate Tick data with different tick types
```python from AlgorithmImports import * class ConsolidateDifferentTickTypesRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 6) self.set_end_date(2013, 10, 7) self.set_cash(1000000) equity = self.add_equity("SPY", Resolution.TICK, Market.USA)...
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 option universe filter by greeks and other options data feature
```python from AlgorithmImports import * class OptionUniverseFilterGreeksRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) self.set_cash(100000) underlying_ticker = "GOOG" self.add_equity(underlying_...
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 the consolidated US equity daily bars from the hour bars exactly matches the daily bars returned from the database
```python from AlgorithmImports import * class ConsolidateHourBarsIntoDailyBarsRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 5, 1) self.set_end_date(2020, 6, 5) self.spy = self.add_equity("SPY", Resolution.HOUR).symbol # We will use these two ...
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 the SetHolding trading API precision
```python from AlgorithmImports import * class SetHoldingsRegressionAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' asynchronous_orders = False def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-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 : This algorithm shows how to grab symbols from an external api each day and load data using the universe selection feature. In this example we define a custom data type for the NYSE top gainers and then short the top 2 gainers each day
```python from AlgorithmImports import * class CustomDataUniverseAlgorithm(QCAlgorithm): def initialize(self): # Data ADDED via universe selection is added with Daily resolution. self.universe_settings.resolution = Resolution.DAILY self.set_start_date(2015,1,5) self.set_end_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 : Algorithm used for regression tests purposes
```python from AlgorithmImports import * class RegressionAlgorithm(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 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 algorithm tests In The Money (ITM) index option expiry for calls. We test to make sure that index options have greeks enabled, same as equity options.
```python from AlgorithmImports import * class IndexOptionCallITMGreeksExpiryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.on_data_calls = 0 self.invested = False self.set_start_date(2021, 1, 4) self.set_end_date(2021, 1, 31) spx = self.add_index("SPX", 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 : Regression test illustrating how history from custom data sources can be requested. The <see cref="QCAlgorithm.history"/> method used in this example also allows to specify other parameters than just the resolution, such as the data normalization mode, the dat...
```python from AlgorithmImports import * class HistoryWithCustomDataSourceRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 6, 5) self.set_end_date(2014, 6, 6) self.aapl = self.add_data(CustomData, "AAPL", Resolution.MINUTE).symbol self.spy = 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 which tests that a two leg currency conversion happens correctly
```python from AlgorithmImports import * class TwoLegCurrencyConversionRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2018, 4, 4) self.set_end_date(2018, 4, 4) self.set_brokerage_model(BrokerageName.GDAX, AccountType.CASH) # GDAX doesn't have LTCETH or...
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 verifying OnEndOfDay callbacks are called as expected. See GH issue 2865.
```python from AlgorithmImports import * class OnEndOfDayRegressionAlgorithm(QCAlgorithm): '''Test algorithm verifying OnEndOfDay callbacks are called as expected. See GH issue 2865.''' 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 illustrating how to request history data for different data normalization modes.
```python from AlgorithmImports import * class HistoryWithDifferentDataNormalizationModeRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2014, 1, 1) self.aapl_equity_symbol = self.add_equity("AAPL", Resolution.DAILY).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 : Tests delistings for Futures and Futures Options to ensure that they are delisted at the expected times.
```python from AlgorithmImports import * class FuturesAndFutures_optionsExpiryTimeAndLiquidationRegressionAlgorithm(QCAlgorithm): def initialize(self): self.invested = False self.liquidated = 0 self.delistings_received = 0 self.expected_expiry_warning_time = datetime(2020, 6, 19...
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 a default symbol is created using equity market when scheduling if none found
```python from AlgorithmImports import * class DefaultSchedulingSymbolRegressionAlgorithm(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, 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 : Regression algorithm to assert the behavior of <see cref="MaximumDrawdownPercentPerSecurity"/>.
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Risk.MaximumDrawdownPercentPerSecurity import MaximumDrawdownPercentPerSecurity class MaximumDrawdownPercentPerSecurityFrameworkRegressionAlgorithm(BaseFrameworkRegressionAlgorithm): def i...
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) future option expiry for calls. We expect 3 orders from the algorithm, which are: * Initial entry, buy ES Call Option (expiring ITM) * Option exercise, receiving ES future contracts * Future contract li...
```python from AlgorithmImports import * class FutureOptionCallITMExpiryRegressionAlgorithm(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( Futur...
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 universe symbols selection can be done by returning the symbol IDs in the selection function
```python from AlgorithmImports import * class SelectUniverseSymbolsFromIDRegressionAlgorithm(QCAlgorithm): ''' Regression algorithm asserting that universe symbols selection can be done by returning the symbol IDs in the selection function ''' def initialize(self): self.set_start_date(2014,...
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 asserting that the consolidators are removed from the SubscriptionManager. This makes sure that we don't lose references to python consolidators when they are wrapped in a DataConsolidatorPythonWrapper.
```python from AlgorithmImports import * class ManuallyRemovedConsolidatorsAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 11) self.consolidators = [] self.spy = self.add_equity("SPY").symbol # Case 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 : def initialize(self) -> None:
```python from AlgorithmImports import * from collections import deque from math import isclose class CustomIndicatorWithExtensionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2013, 10, 9) self.set_end_date(2013, 10, 9) self._spy = self.add_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 : Example of custom volatility model
```python from AlgorithmImports import * class CustomVolatilityModelAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10,7) #Set Start Date self.set_end_date(2015,7,15) #Set End Date self.set_cash(100000) #Set Strategy Cash # Find more symbols...
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 estimate constituents of QC500 index based on the company fundamentals The algorithm creates a default tradable and liquid universe containing 500 US equities which are chosen at the first trading day of each month.
```python from AlgorithmImports import * class ConstituentsQC500GeneratorAlgorithm(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_settings.resolution...
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 illustrating how to get a security's industry-standard identifier from its `Symbol`
```python from AlgorithmImports import * class IndustryStandardSecurityIdentifiersRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2014, 6, 5) self.set_end_date(2014, 6, 5) equity = self.add_equity("AAPL").symbol cusip = equity.cusip composite...
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 shows how you can handle universe selection in anyway you like, at any time you like. This algorithm has a list of 10 stocks that it rotates through every hour.
```python from AlgorithmImports import * class UserDefinedUniverseAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_cash(100000) self.set_start_date(2015, 1, 1) self.set_end_date(2015, 12, 1) self._symbols = ["SPY", "GOOG", "IBM", "AAPL", "MSFT", "CSCO", "ADBE", "WMT"] self.universe_setting...
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="HistoricalReturnsAlphaModel"/>.
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Alphas.HistoricalReturnsAlphaModel import HistoricalReturnsAlphaModel class HistoricalReturnsAlphaModelFrameworkRegressionAlgorithm(BaseFrameworkRegressionAlgorithm): 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 : Test algorithm using 'QCAlgorithm.add_alpha_model()'
```python from AlgorithmImports import * class AddAlphaModelAlgorithm(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 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 : Test algorithm using 'ConfidenceWeightedPortfolioConstructionModel' and 'ConstantAlphaModel' generating a constant 'Insight' with a 0.25 confidence
```python from AlgorithmImports import * class ConfidenceWeightedFrameworkAlgorithm(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.''' # Set requested data resolution...
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 : Custom Consolidator Regression Algorithm shows some examples of how to build custom
```python from AlgorithmImports import * class CustomConsolidatorRegressionAlgorithm(QCAlgorithm): '''Custom Consolidator Regression Algorithm shows some examples of how to build custom consolidators in Python.''' def initialize(self): self.set_start_date(2013,10,4) 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 : Regression algorithm which tests a fine fundamental filtered universe, related to GH issue 4127
```python from AlgorithmImports import * class FineFundamentalFilteredUniverseRegressionAlgorithm(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_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 : The demonstration algorithm shows some of the most common order methods when working with Crypto assets.
```python from AlgorithmImports import * class BasicTemplateCryptoAlgorithm(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(2018, 4, 4) #Set 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 : Framework algorithm that uses the PearsonCorrelationPairsTradingAlphaModel. This model extendes BasePairsTradingAlphaModel and uses Pearson correlation to rank the pairs trading candidates and use the best candidate to trade.
```python from AlgorithmImports import * from Alphas.PearsonCorrelationPairsTradingAlphaModel import PearsonCorrelationPairsTradingAlphaModel class PearsonCorrelationPairsTradingAlphaModelFrameworkAlgorithm(QCAlgorithm): '''Framework algorithm that uses the PearsonCorrelationPairsTradingAlphaModel. This 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 : This regression algorithm tests In The Money (ITM) future option expiry for short calls. We expect 3 orders from the algorithm, which are: * Initial entry, sell ES Call Option (expiring ITM) * Option assignment, sell 1 contract of the underlying (ES) * ...
```python from AlgorithmImports import * class FutureOptionShortCallITMExpiryRegressionAlgorithm(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( ...
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 with daily resolution.
```python from AlgorithmImports import * class BasicTemplateFuturesDailyAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2014, 10, 10) self.set_cash(1000000) resolution = self.get_resolution() extended_market_hours = self.ge...
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 : Regrssion algorithm to assert we can update indicators that inherit from IndicatorBase<TradeBar> with RenkoBar's
```python from AlgorithmImports import * class IndicatorWithRenkoBarsRegressionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 9) self.add_equity("SPY") self.add_equity("AIG") spy_renko_consolidator = 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 : Test algorithm using 'QCAlgorithm.add_universe_selection(IUniverseSelectionModel)'
```python from AlgorithmImports import * class AddUniverseSelectionModelAlgorithm(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 demonstrating the usage of the RSI indicator in combination with ETF constituents data to replicate the weighting of the ETF's assets in our own account.
```python from AlgorithmImports import * class ETFConstituentUniverseRSIAlphaModelAlgorithm(QCAlgorithm): ### <summary> ### Initialize 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 regression algorithm tests using FutureOptions daily resolution
```python from AlgorithmImports import * class FutureOptionDailyRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2020, 1, 7) self.set_end_date(2020, 1, 8) resolution = Resolution.DAILY # 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 : Test algorithm using 'InsightWeightingPortfolioConstructionModel' and 'ConstantAlphaModel' generating a constant 'Insight' with a 0.25 weight
```python from AlgorithmImports import * from Selection.ManualUniverseSelectionModel import ManualUniverseSelectionModel from Alphas.ConstantAlphaModel import ConstantAlphaModel from Portfolio.InsightWeightingPortfolioConstructionModel import InsightWeightingPortfolioConstructionModel from Execution.ImmediateExecuti...
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 access the statistics results from within an algorithm through the `Statistics` property.
```python from AlgorithmImports import * from System.Collections.Generic import Dictionary class StatisticsResultsAlgorithm(QCAlgorithm): most_traded_security_statistic = "Most Traded Security" most_traded_security_trade_count_statistic = "Most Traded Security Trade Count" 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 of using RiskParityPortfolioConstructionModel
```python from AlgorithmImports import * from Portfolio.RiskParityPortfolioConstructionModel import * class RiskParityPortfolioAlgorithm(QCAlgorithm): '''Example algorithm of using RiskParityPortfolioConstructionModel''' def initialize(self): self.set_start_date(2021, 2, 21) # 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 : Custom data universe selection regression algorithm asserting it's behavior. Similar to CustomDataUniverseRegressionAlgorithm but with a custom schedule
```python from AlgorithmImports import * class CustomDataUniverseScheduledRegressionAlgorithm(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(201...
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 : A demonstration of consolidating futures data into larger bars for your algorithm.
```python from AlgorithmImports import * class BasicTemplateFuturesConsolidationAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 11) self.set_cash(1000000) # Subscribe and set our expiry filter for the futures chain ...
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 of indicators history window usage
```python from AlgorithmImports import * class IndicatorHistoryAlgorithm(QCAlgorithm): '''Demonstration algorithm of indicators history window usage.''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms mu...
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 simply initializes the date range and cash
```python from AlgorithmImports import * class LimitFillRegressionAlgorithm(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 asserting the behavior of auxiliary data history requests
```python from AlgorithmImports import * class HistoryAuxiliaryDataRegressionAlgorithm(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(2021, 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 : This algorithm demonstrates how to submit orders to a Financial Advisor account group, allocation profile or a single managed account.
```python from AlgorithmImports import * class FinancialAdvisorDemoAlgorithm(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 be initialized. self.set_start_date(2013,10,7) #Set 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 : Provides a regression baseline focused on updating orders
```python from AlgorithmImports import * from math import copysign class UpdateOrderRegressionAlgorithm(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_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 : Example algorithm for trading continuous future
```python from AlgorithmImports import * class BasicTemplateFutureRolloverAlgorithm(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): 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 : Continuous Futures Regression algorithm. Asserting and showcasing the behavior of adding a continuous future
```python from AlgorithmImports import * class ContinuousFutureRegressionAlgorithm(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....
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 benchmark model, and override some of its methods
```python from AlgorithmImports import * from CustomBrokerageModelRegressionAlgorithm import CustomBrokerageModel class CustomBenchmarkRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10,7) self.set_end_date(2013,10,11) self.set_brokerage_model(CustomBroker...
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 various ways you can call the History function, what it returns, and what you can do with the returned values.
```python from AlgorithmImports import * class HistoryAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013,10, 8) #Set Start Date self.set_end_date(2013,10,11) #Set End Date self.set_cash(100000) #Set Strategy Cash # Find more symbols here: http:/...
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 extended market hours trading.
```python from AlgorithmImports import * class ExtendedMarketTradingRegressionAlgorithm(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,...
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 algorithm defines its own custom coarse/fine fundamental selection model with sector weighted portfolio.
```python from AlgorithmImports import * class SectorWeightingFrameworkAlgorithm(QCAlgorithm): '''This example algorithm defines its own custom coarse/fine fundamental selection model with sector weighted portfolio.''' 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 : Regression algorithm testing portfolio construction model control over rebalancing, specifying a custom rebalance function that returns null in some cases, see GH 4075.
```python from AlgorithmImports import * class PortfolioRebalanceOnCustomFuncRegressionAlgorithm(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_sett...
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 different data mapping modes.
```python from AlgorithmImports import * class HistoryWithDifferentDataMappingModeRegressionAlgorithm(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_500_E_MINI, Resol...
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="MaximumSectorExposureRiskManagementModel"/>.
```python from AlgorithmImports import * from BaseFrameworkRegressionAlgorithm import BaseFrameworkRegressionAlgorithm from Risk.MaximumSectorExposureRiskManagementModel import MaximumSectorExposureRiskManagementModel class MaximumSectorExposureRiskManagementModelFrameworkRegressionAlgorithm(BaseFrameworkRegressionA...
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) future option expiry for puts. We expect 3 orders from the algorithm, which are: * Initial entry, buy ES Put Option (expiring ITM) (buy, qty 1) * Option exercise, receiving short ES future contracts (sell...
```python from AlgorithmImports import * class FutureOptionPutITMExpiryRegressionAlgorithm(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( Futures...
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 : A demonstration of consolidating options data into larger bars for your algorithm.
```python from AlgorithmImports import * class BasicTemplateOptionsConsolidationAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 7) self.set_end_date(2013, 10, 11) self.set_cash(1000000) # Subscribe and set our filter for the options chain optio...
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 with custom data types
```python from datetime import time import os from AlgorithmImports import * class BybitCustomDataCryptoRegressionAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2022, 12, 13) self.set_end_date(2022, 12, 13) self.set_account_currency("USDT") self.set_ca...
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 base algorithm demonstrates how to use OptionStrategies helper class to batch send orders for common strategies.
```python from AlgorithmImports import * from QuantConnect.Securities.Positions import IPositionGroup class OptionStrategyFactoryMethodsBaseAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2015, 12, 24) self.set_end_date(2015, 12, 24) self.set_cash(1000000) opti...
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 algorithm shows how to import and use Tiingo daily prices data.
```python from AlgorithmImports import * from QuantConnect.Data.Custom.Tiingo import TiingoPrice class TiingoPriceAlgorithm(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. ...
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 GH issue #5921. Asserting a security can be warmup correctly on initialize
```python from AlgorithmImports import * class SecuritySeederRegressionAlgorithm(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 : Demonstration of payments for cash dividends in backtesting. When data normalization mode is set to "Raw" the dividends are paid as cash directly into your portfolio.
```python from AlgorithmImports import * class DividendAlgorithm(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(1998,1,1) #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 algorithm tests Out of The Money (OTM) index option expiry for calls. We expect 2 orders from the algorithm, which are: * Initial entry, buy SPX Call Option (expiring OTM) - contract expires worthless, not exercised, so never opened a po...
```python from AlgorithmImports import * class IndexOptionCallOTMExpiryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2021, 1, 4) self.set_end_date(2021, 1, 31) self.spx = self.add_index("SPX", Resolution.MINUTE).symbol # Select a index option call ...
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 checks if all the option chain data coming to the algo is consistent with current securities manager state
```python from AlgorithmImports import * class OptionChainConsistencyRegressionAlgorithm(QCAlgorithm): underlying_ticker = "GOOG" def initialize(self): self.set_cash(10000) self.set_start_date(2015,12,24) self.set_end_date(2015,12,24) self.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 : Regression Channel algorithm simply initializes the date range and cash
```python from AlgorithmImports import * class RegressionChannelAlgorithm(QCAlgorithm): def initialize(self): self.set_cash(100000) self.set_start_date(2009,1,1) self.set_end_date(2015,1,1) equity = self.add_equity("SPY", Resolution.MINUTE) self._spy = equity.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 : his algorithm sends a list of portfolio targets to custom endpoint
```python from AlgorithmImports import * class CustomSignalExportDemonstrationAlgorithm(QCAlgorithm): def initialize(self) -> None: ''' Initialize the date and add all equity symbols present in list _symbols ''' self.set_start_date(2013, 10, 7) #Set Start Date self.set_end_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 : In this algorithm we submit/update/cancel each order type
```python from AlgorithmImports import * class OrderTicketDemoAlgorithm(QCAlgorithm): '''In this algorithm we submit/update/cancel each order type''' def initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must i...
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 algorithm for scheduled universe selection GH 3890
```python from AlgorithmImports import * class FundamentalCustomSelectionTimeRegressionAlgorithm(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._month_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 : Basic Template India Index Algorithm uses framework components to define the algorithm.
```python from AlgorithmImports import * class BasicTemplateIndiaIndexAlgorithm(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 ...
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 asserting that tick history that includes multiple tick types (trade, quote) is correctly converted to a pandas dataframe without raising exceptions. The main exception in this case was a "non-unique multi-index" error due to trades ad...
```python from AlgorithmImports import * class PandasDataFrameFromMultipleTickTypeTickHistoryRegressionAlgorithm(QCAlgorithm): def initialize(self): self.set_start_date(2013, 10, 8) self.set_end_date(2013, 10, 8) spy = self.add_equity("SPY", Resolution.MINUTE).symbol subscriptio...
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 example we look at the canonical 15/30 day moving average cross. This algorithm will go long when the 15 crosses above the 30 and will liquidate when the 15 crosses back below the 30.
```python from AlgorithmImports import * class MovingAverageCrossAlgorithm(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(2009, 1, 1) #Set ...