-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Organization of Futures > Requesting Data
- Loading branch information
1 parent
081c643
commit 1981b85
Showing
15 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/00.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div class="sub-heading-content"> | ||
<div class="sub-heading-landing"> | ||
<div class="internal-content"> | ||
<p> | ||
<p>Request Futures data in your algorithm to receive a feed of contract prices in the <code class="csharp">OnData</code><code class="python">on_data</code> method. For more information about the specific dataset we use for backtests, see the <a href="/datasets/algoseek-us-futures">US Futures dataset listing</a>. To trade Futures live, you can use the <a href='/docs/v2/cloud-platform/datasets/quantconnect/futures'>QuantConnect data provider</a> or one of the <a href='/docs/v2/cloud-platform/datasets'>brokerage data providers</a>.</p> | ||
</p> | ||
<p>To request Futures data, call one of the following methods:</p> | ||
<ul> | ||
<li><code class='csharp'>AddFuture</code><code class='python'>self.add_future</code> to add a basket of contracts for a single Future</li> | ||
<li><code class='csharp'>AddFutureContract</code><code class='python'>self.add_future_contract</code> to add individual contracts for an underlying Future</li> | ||
</ul> | ||
</div> | ||
<div class="docs-landing-links"> | ||
<div class="col-md-6 col-sm-12 docs-landing-link-wrap"> | ||
<div class="content clickable" onclick="window.location.href = '/docs/v2/writing-algorithms/securities/asset-classes/futures/requesting-data/universes'"> | ||
<div class="docs-internal-link"> | ||
<h4> | ||
Request and Filter All Contracts | ||
</h4> | ||
</div> | ||
<code class='csharp'>AddFuture</code><code class='python'>self.add_future</code> | ||
</div> | ||
</div> | ||
<div class="col-md-6 col-sm-12 docs-landing-link-wrap"> | ||
<div class="content clickable" onclick="window.location.href = '/docs/v2/writing-algorithms/securities/asset-classes/futures/requesting-data/individual-contracts'"> | ||
<div class="docs-internal-link"> | ||
<h4> | ||
Select Individual Contracts | ||
</h4> | ||
</div> | ||
<code class='csharp'>AddFutureContract</code><code class='python'>self.add_future_contract</code> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
...curities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/01 Introduction.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<p> | ||
The <code class="csharp">AddFuture</code><code class="python">add_future</code> method enables you to select a basket of Future contracts for an underlying Future. | ||
To form your universe of contracts, you can filter them down by their expiry. | ||
If you want to subscribe to individual contracts one-by-one instead of a set of contracts, see <a href='/docs/v2/writing-algorithms/securities/asset-classes/futures/requesting-data/individual-contracts'>Individual Contracts</a>. | ||
</p> |
34 changes: 34 additions & 0 deletions
34
...ties/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/02 Create Universes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<p>To add a universe of Future contracts, in the <code class="csharp">Initialize</code><code class="python">initialize</code> method, call the <code class="csharp">AddFuture</code><code class="python">add_future</code> method. This method returns an <code>Future</code> object, which has a <code class="csharp">SetFilter</code><code class="python">set_filter</code> method you can call to filter the set of tradable contract down to just the contracts you want.</p> | ||
|
||
<div class="section-example-container"> | ||
<pre class="csharp">public class BasicFutureAlgorithm : QCAlgorithm | ||
{ | ||
public override void Initialize() | ||
{ | ||
var future = AddFuture(Futures.Indices.SP500EMini); | ||
future.SetFilter(0, 182); | ||
} | ||
|
||
public override void OnData(Slice data) | ||
{ | ||
foreach (var (continuousSymbol, chain) in data.FuturesChains) | ||
{ | ||
foreach (var (symbol, contract) in chain.Contracts) | ||
{ | ||
var expiry = contract.Expiry; | ||
} | ||
} | ||
} | ||
}</pre> | ||
<pre class="python">class BasicFutureAlgorithm(QCAlgorithm): | ||
def initialize(self): | ||
future = self.add_future(Futures.Indices.SP500E_MINI) | ||
option.set_filter(0, 182) | ||
|
||
def on_data(self, data): | ||
for continuous_symbol, chain in data.future_chains.items(): | ||
for symbol, contract in chain.contracts.items(): | ||
contract.strike</pre> | ||
</div> | ||
|
||
<p>For more information about the <code class="csharp">AddFuture</code><code class="python">add_future</code> method, see <a href='/docs/v2/writing-algorithms/universes/futures#11-Create-Universes'>Create Universes</a>.</p> |
12 changes: 12 additions & 0 deletions
12
...s/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"type": "metadata", | ||
"values": { | ||
"description": "Request Futures data in your algorithm to receive a feed of contract prices in the OnData method.", | ||
"keywords": "Futures, security subscriptions, Extended Market Hours, fill forward, margin, leverage", | ||
"og:description": "Request Futures data in your algorithm to receive a feed of contract prices in the OnData method.", | ||
"og:title": "Universes - Documentation QuantConnect.com", | ||
"og:type": "website", | ||
"og:site_name": "Universes - QuantConnect.com", | ||
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/securities/asset-classes/futures/requesting-data/universes.png" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.