diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/00.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/00.html new file mode 100644 index 0000000000..c912e94e13 --- /dev/null +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/00.html @@ -0,0 +1,36 @@ +
+
+
+

+

Request Futures data in your algorithm to receive a feed of contract prices in the OnDataon_data method. For more information about the specific dataset we use for backtests, see the US Futures dataset listing. To trade Futures live, you can use the QuantConnect data provider or one of the brokerage data providers.

+

+

To request Futures data, call one of the following methods:

+
    +
  • AddFutureself.add_future to add a basket of contracts for a single Future
  • +
  • AddFutureContractself.add_future_contract to add individual contracts for an underlying Future
  • +
+
+ +
+
\ No newline at end of file diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/01 Introduction.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/01 Introduction.html new file mode 100644 index 0000000000..367d9b6a7d --- /dev/null +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/01 Introduction.html @@ -0,0 +1,5 @@ +

+ The AddFutureadd_future 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 Individual Contracts. +

\ No newline at end of file diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/02 Create Universes.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/02 Create Universes.html new file mode 100644 index 0000000000..ef711a3f17 --- /dev/null +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/02 Create Universes.html @@ -0,0 +1,34 @@ +

To add a universe of Future contracts, in the Initializeinitialize method, call the AddFutureadd_future method. This method returns an Future object, which has a SetFilterset_filter method you can call to filter the set of tradable contract down to just the contracts you want.

+ +
+
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;
+            }
+        }
+    }
+}
+
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
+
+ +

For more information about the AddFutureadd_future method, see Create Universes.

\ No newline at end of file diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/metadata.json b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/metadata.json new file mode 100644 index 0000000000..3ae3b66ca9 --- /dev/null +++ b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Universes/metadata.json @@ -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" + } +} \ No newline at end of file diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Introduction.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/01 Introduction.html similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/01 Introduction.html rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/01 Introduction.html diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Create Subscriptions.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/02 Create Subscriptions.html similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Create Subscriptions.html rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/02 Create Subscriptions.html diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/03 Resolutions.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/03 Resolutions.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/03 Resolutions.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/03 Resolutions.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/04 Supported Markets.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/04 Supported Markets.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/04 Supported Markets.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/04 Supported Markets.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/05 Fill Forward.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/05 Fill Forward.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/05 Fill Forward.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/05 Fill Forward.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/06 Margin and Leverage.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/06 Margin and Leverage.html similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/06 Margin and Leverage.html rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/06 Margin and Leverage.html diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/07 Extended Market Hours.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/07 Extended Market Hours.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/07 Extended Market Hours.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/07 Extended Market Hours.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/08 Continuous Contracts.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/08 Continuous Contracts.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/08 Continuous Contracts.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/08 Continuous Contracts.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/09 Data Normalization.php b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/09 Data Normalization.php similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/09 Data Normalization.php rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/09 Data Normalization.php diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/10 Properties.html b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/10 Properties.html similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/10 Properties.html rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/10 Properties.html diff --git a/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/metadata.json b/03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/metadata.json similarity index 100% rename from 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/metadata.json rename to 03 Writing Algorithms/03 Securities/99 Asset Classes/06 Futures/01 Requesting Data/02 Individual Contracts/metadata.json