diff --git a/08 Drafts/05 Historical Data/01 Getting Started/01 History Requests.html b/08 Drafts/05 Historical Data/01 Getting Started/01 History Requests.html new file mode 100644 index 0000000000..be0bd59ccb --- /dev/null +++ b/08 Drafts/05 Historical Data/01 Getting Started/01 History Requests.html @@ -0,0 +1,18 @@ +
Follow these steps to get some historical data:
+ +The process to creating a new project depends on if you use the Cloud Platform, Local Platform, or CLI.
+ +initialize
Initialize
method, add an asset.var spy = AddEquity("SPY");+
spy = self.add_equity('SPY')+
history
History
method with the asset's Symbol and a lookback period.var history = History(spy.Symbol, 10, Resolution.Daily);+
history = self.history(spy.symbol, 10, Resolution.DAILY)+
Follow these steps to add a warm-up period to the start of your algorithm:
+ +The process to creating a new project depends on if you use the Cloud Platform, Local Platform, or CLI.
+ +initialize
Initialize
method, call the set_warm_up
SetWarmUp
method with the warm-up duration.SetWarmUp(10, Resolution.Daily);+
self.set_warm_up(10, Resolution.DAILY)+
+You can set a warm-up period based on a period of time or a number of bars. To set a warm-up, in your algorithm's Initialize
initialize
method, call the SetWarmUp
set_warm_up
method.
// Wind time back 7 days from start +SetWarmUp(TimeSpan.FromDays(7)); + +// Feed in 100 bars before start date +SetWarmUp(100); ++
# Wind time back 7 days from start +self.set_warm_up(timedelta(7)) + +# Feed in 100 bars before start date +self.set_warm_up(100) ++
If you pass a timedelta
TimeSpan
argument, the warm-up period consists of that timedelta
TimeSpan
before the start date and pipes in data that matches the resolution of your data subscriptions.
If you pass just an integer argument, LEAN calculates the start of the warm-up period for each of your security subscriptions by using the number of bars you specify, the resolution of each security, and the trading calendar of each security. After it calculates the start time of the warm-up period for each security, it sets the earliest start time as the start of the algorithm warm-up period. For instance, in the following example, the warm-up period consists of 100 minute resolution bars for SPY and as many second resolution bars for BTCUSD that occur from the start of the SPY warm-up period to the algorithm StartDate
start_date
.
AddEquity("SPY", Resolution.Minute, fillForward: false); +AddCrypto("BTCUSD", Resolution.Second, fillForward: false); +SetWarmUp(100); ++
self.add_equity("SPY", Resolution.MINUTE, fill_forward=False) +self.add_crypto("BTCUSD", Resolution.SECOND, fill_forward=False) +self.set_warm_up(100) ++
To use a specific resolution of data for the warm-up period, pass a resolution
argument to the SetWarmUp
set_warm_up
method.
// Feed in 100 days of daily data before the start date +SetWarmUp(TimeSpan.FromDays(100), Resolution.Daily); + +// Feed in data for 100 trading days of daily data before the start date +SetWarmUp(100, Resolution.Daily);+
# Feed in 100 days of daily data before the start date +self.set_warm_up(timedelta(days=100), Resolution.DAILY) + +# Feed in data for 100 trading days before the start date +self.set_warm_up(100, Resolution.DAILY)+
If you pass a timedelta
TimeSpan
and a resolution, the warm-up period consists of the time period and resolution you set, regardless of the resolution of your data subscriptions.
If you pass an integer and a resolution, the warm-up period consists of the number of bars and resolution you set, regardless of the resolution of your data subscriptions. In this case, LEAN calculates the start of the warm-up period for each of your security subscriptions just like it does when you only pass an integer argument. After it calculates the start time of the warm-up period for each security, it sets the earliest start time as the start of the algorithm warm-up period.
If you pass a resolution argument and you registered indicators or consolidators for automatic updates, the warm-up period resolution must be less than or equal to the lowest resolution of your automatic indicators and consolidators. For instance, in the following example, the indicators use minute resolution data, so you can set the warm-up period to use tick, second, or minute resolution data.
+ +_spy = AddEquity("SPY", Resolution.Minute, fillForward: false).Symbol; +_btc = AddCrypto("BTCUSD", Resolution.Second, fillForward: false).Symbol; + +_spySma = SMA(_spy, 10); +_btcSMA = SMA(_btc, 10, Resolution.Minute); + +SetWarmUp(100, Resolution.Minute); ++
self._spy = self.add_equity("SPY", Resolution.MINUTE, fill_forward=False).symbol +self._btc = self.add_crypto("BTCUSD", Resolution.SECOND, fill_forward=False).symbol + +self._spy_sma = self.sma(self._spy, 10) +self._btc_sma = self.sma(self._btc, 10, Resolution.MINUTE) + +self.set_warm_up(100, Resolution.MINUTE) ++
You may need to distinguish warm-up data from real data. To check if the algorithm is currently in a warm up period, use the IsWarmingUp
is_warming_up
property.
// In Initialize +var emaFast = EMA("IBM", 50); +var emaSlow = EMA("IBM", 100); +SetWarmup(100); + +// In OnData: Don't run if the indicators aren't ready +if (IsWarmingUp) return; ++
# In Initialize +self._ema_fast = self.ema("IBM", 50); +self._ema_slow = self.ema("IBM", 100); +self.set_warmup(100); + +// In OnData: Don't run if the indicators aren't ready +if self.is_warming_up: return ++
The OnWarmupFinished
on_warmup_finished
event handler executes when the warm up period ends, even if you don't set a warm up period.
public override void OnWarmupFinished() +{ + // Done warming up +} ++
def on_warmup_finished(self) -> None: + pass # Done warming up+
You can't place trades during the warm-up period because they would be operating on fictional fast-forwarded data.
\ No newline at end of file diff --git a/08 Drafts/05 Historical Data/07 Warm Up Periods/99 Examples.html b/08 Drafts/05 Historical Data/07 Warm Up Periods/99 Examples.html new file mode 100644 index 0000000000..62169a494d --- /dev/null +++ b/08 Drafts/05 Historical Data/07 Warm Up Periods/99 Examples.html @@ -0,0 +1,11 @@ + diff --git a/08 Drafts/05 Historical Data/07 Warm Up Periods/metadata.json b/08 Drafts/05 Historical Data/07 Warm Up Periods/metadata.json new file mode 100644 index 0000000000..4235bc6090 --- /dev/null +++ b/08 Drafts/05 Historical Data/07 Warm Up Periods/metadata.json @@ -0,0 +1,12 @@ +{ + "type": "metadata", + "values": { + "description": "LEAN supports an automated fast-forward system called \"Warm Up\". It simulates winding back the clock from the time you deploy the algorithm.", + "keywords": "historical data, warm up, algorithmic trading", + "og:description": "LEAN supports an automated fast-forward system called \"Warm Up\". It simulates winding back the clock from the time you deploy the algorithm.", + "og:title": "Warm Up Periods - Documentation QuantConnect.com", + "og:type": "website", + "og:site_name": "Warm Up Periods - QuantConnect.com", + "og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/historical-data/warm-up-periods.png" + } +} diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/01 Introduction.php b/08 Drafts/05 Historical Data/08 Rolling Window/01 Introduction.php new file mode 100644 index 0000000000..47f45efbe2 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/01 Introduction.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/introduction.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/02 Supported Types.php b/08 Drafts/05 Historical Data/08 Rolling Window/02 Supported Types.php new file mode 100644 index 0000000000..56e5ed6527 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/02 Supported Types.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/supported-types.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/03 Add Data.php b/08 Drafts/05 Historical Data/08 Rolling Window/03 Add Data.php new file mode 100644 index 0000000000..7757b719df --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/03 Add Data.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/add-data.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/04 Warm Up.php b/08 Drafts/05 Historical Data/08 Rolling Window/04 Warm Up.php new file mode 100644 index 0000000000..eca0e33023 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/04 Warm Up.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/warm-up.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/05 Check Readiness.php b/08 Drafts/05 Historical Data/08 Rolling Window/05 Check Readiness.php new file mode 100644 index 0000000000..a1009dff68 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/05 Check Readiness.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/check-readiness.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/06 Adjust Size.php b/08 Drafts/05 Historical Data/08 Rolling Window/06 Adjust Size.php new file mode 100644 index 0000000000..f3a7c60076 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/06 Adjust Size.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/adjust-size.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/07 Access Data.php b/08 Drafts/05 Historical Data/08 Rolling Window/07 Access Data.php new file mode 100644 index 0000000000..239cb7c116 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/07 Access Data.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/access-data.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/08 Combine with Indicators.php b/08 Drafts/05 Historical Data/08 Rolling Window/08 Combine with Indicators.php new file mode 100644 index 0000000000..4e17ff885c --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/08 Combine with Indicators.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/indicators/historical-values.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/09 Combine with Consolidators.php b/08 Drafts/05 Historical Data/08 Rolling Window/09 Combine with Consolidators.php new file mode 100644 index 0000000000..78da95693d --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/09 Combine with Consolidators.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/combine-with-consolidators.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/10 Cast to Other Types.php b/08 Drafts/05 Historical Data/08 Rolling Window/10 Cast to Other Types.php new file mode 100644 index 0000000000..885cd90953 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/10 Cast to Other Types.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/cast-to-other-types.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/11 Delete Data.php b/08 Drafts/05 Historical Data/08 Rolling Window/11 Delete Data.php new file mode 100644 index 0000000000..c0bcb62860 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/11 Delete Data.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/delete-data.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/12 Examples.php b/08 Drafts/05 Historical Data/08 Rolling Window/12 Examples.php new file mode 100644 index 0000000000..fac02b1ae1 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/12 Examples.php @@ -0,0 +1 @@ + include(DOCS_RESOURCES."/rolling-window/examples.html"); ?> \ No newline at end of file diff --git a/08 Drafts/05 Historical Data/08 Rolling Window/metadata.json b/08 Drafts/05 Historical Data/08 Rolling Window/metadata.json new file mode 100644 index 0000000000..0e4e6a6327 --- /dev/null +++ b/08 Drafts/05 Historical Data/08 Rolling Window/metadata.json @@ -0,0 +1,12 @@ +{ + "type": "metadata", + "values": { + "description": "A RollingWindow is an array of a fixed-size that holds trailing data. It's more efficient to store data than to make many historical data requests.", + "keywords": "historical data, rolling window, trailing data, indicators, consolidators", + "og:description": "A RollingWindow is an array of a fixed-size that holds trailing data. It's more efficient to store data than to make many historical data requests.", + "og:title": "Rolling Window - Documentation QuantConnect.com", + "og:type": "website", + "og:site_name": "Rolling Window - QuantConnect.com", + "og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/historical-data/rolling-window.png" + } +} diff --git a/08 Drafts/05 Historical Data/09 Common Errors/01 Introduction.html b/08 Drafts/05 Historical Data/09 Common Errors/01 Introduction.html new file mode 100644 index 0000000000..9b3494f524 --- /dev/null +++ b/08 Drafts/05 Historical Data/09 Common Errors/01 Introduction.html @@ -0,0 +1,7 @@ +add Live Trading +Other data providers +Trading disabled in warm-up + Limitations of quantconnect provider +Limitations of brokerages +E.g. IB is slow and leads to timeout if we request or warm up too many symbols (e.g. options) +Indicator readiness.