Skip to content

Commit

Permalink
Code generated by Alternative-Datasets-Code-Generator.py
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub authored and AlexCatarino committed May 9, 2024
1 parent 1767c38 commit 6bc0c83
Show file tree
Hide file tree
Showing 79 changed files with 565 additions and 497 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<p>The following snippet demonstrates how to request data from the US ETF Constituents dataset:</p>

<div class="section-example-container">
<pre class="python">from QuantConnect.DataSource import *

def initialize(self) -&gt; None:
<pre class="python">def initialize(self) -&gt; None:
self.universe_settings.asynchronous = True
# Use the following method for a Classic Algorithm
self._universe = self.add_universe(self.universe.etf("SPY", Market.USA, self.universe_settings, self.etf_constituents_filter))
Expand All @@ -15,9 +13,7 @@
def etf_constituents_filter(self, constituents: List[ETFConstituentUniverse]) -&gt; List[Symbol]:
# Add all Symbols of the ETFConstituentUniverse
return [x.symbol for x in constituents]</pre>
<pre class="csharp">using QuantConnect.DataSource;

public override void Initialize()
<pre class="csharp">public override void Initialize()
{
UniverseSettings.Asynchronous = True;
// Use the following method for a Classic Algorithm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
self.set_start_date(2019, 1, 1)
security = self.add_equity("AAPL")
security.set_shortable_provider(InteractiveBrokersShortableProvider())
self.symbol = security.symbol</pre>
self._symbol = security.symbol</pre>

<pre class="csharp">using QuantConnect.Data.Shortable;
namespace QuantConnect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
// Check if there are a certain quantity of shares available
var quantity = 100;
var isShortableQuantity = Shortable(_symbol, quantity);</pre>
<pre class="python">shortable_provider = self.securities[self.symbol].shortable_provider
shortable_quantity = shortable_provider.shortable_quantity(self.symbol, self.time)
<pre class="python">shortable_provider = self.securities[self._symbol].shortable_provider
shortable_quantity = shortable_provider.shortable_quantity(self._symbol, self.time)

# Check if there are a certain quantity of shares available
quantity = 100;
is_shortable_quantity = self.shortable(self.symbol, quantity)</pre>
is_shortable_quantity = self.shortable(self._symbol, quantity)</pre>
</div>

<p>To check borrowing cost, call the <b class="csharp">FeeRate</b><b class="python">fee_rate</b> or <b class="csharp">RebateRate</b><b class="python">rebate_rate</b> method of the <b class="csharp">ShortableProvider</b><b class="python">shortable_provider</b></p>
<div class="section-example-container">
<pre class="csharp">var feeRate = shortableProvider.FeeRate(_symbol, Time);
var rebateRate = shortableProvider.RebateRate(_symbol, Time);</pre>
<pre class="python">fee_rate = shortable_provider.fee_rate(self.symbol, self.time);
rebate_rate = shortable_provider.rebate_rate(self.symbol, self.time);</pre>
<pre class="python">fee_rate = shortable_provider.fee_rate(self._symbol, self.time);
rebate_rate = shortable_provider.rebate_rate(self._symbol, self.time);</pre>
</div>

To get valid borrowing rates, use the <a href="/docs/v2/writing-algorithms/reality-modeling/short-availability/supported-providers#05-Interactive-Brokers-Provider">InteractiveBrokersShortableProvider</a><a>.</a>
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<div class="section-example-container">
<pre class="python">def on_data(self, slice: Slice) -&gt; None:
if slice.splits.contains_key(self.symbol):
split = slice.splits[self.symbol]
if slice.splits.contains_key(self._symbol):
split = slice.splits[self._symbol]
split_type = {0: "Warning", 1: "SplitOccurred"}.get(split.type)
self.log(f"Split: {split.symbol}\t{split.split_factor}\t{split.reference_price}\t{split_type}")</pre>
<pre class="csharp">public override void OnData(Slice slice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<div class="section-example-container">
<pre class="python">def on_data(self, slice: Slice) -&gt; None:
if slice.dividends.contains_key(self.symbol):
dividend = slice.dividends[self.symbol]
if slice.dividends.contains_key(self._symbol):
dividend = slice.dividends[self._symbol]
self.log(f'Dividend: {dividend.symbol}\t{dividend.distribution}\t{dividend.reference_price}')</pre>
<pre class="csharp">public override void OnData(Slice slice)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<div class="section-example-container">
<pre class="python">def on_data(self, slice: Slice) -&gt; None:
if slice.delistings.contains_key(self.symbol):
delisting = slice.delistings[self.symbol]
if slice.delistings.contains_key(self._symbol):
delisting = slice.delistings[self._symbol]
delisting_type = {0: "Warning", 1: "Delisted"}.get(delisting.type)
self.log(f'Delistings: {delisting_type}')</pre>
<pre class="csharp">public override void OnData(Slice slice)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<p>To get the current Symbol change events, index the <b class="csharp">SymbolChangedEvents</b><b class="python">symbol_changed_events</b> property of the current <b>Slice</b> with the Equity <b>Symbol</b>. Slice objects deliver unique events to your algorithm as they happen, but the <b>Slice</b> may not contain data for your security at every time step. To avoid issues, check if the <b>Slice</b> contains the data you want before you index it.</p>
<div class="section-example-container">
<pre class="python">def on_data(self, slice: Slice) -&gt; None:
if slice.symbol_changed_events.contains_key(self.symbol):
symbol_changed_event = slice.symbol_changed_events[self.symbol]
if slice.symbol_changed_events.contains_key(self._symbol):
symbol_changed_event = slice.symbol_changed_events[self._symbol]
self.log(f"Symbol changed: {symbol_changed_event.old_symbol} -&gt; {symbol_changed_event.new_symbol}")
</pre>
<pre class="csharp">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p>The US Futures Security Master dataset by QuantConnect provides mapping reference data for the most liquid contracts of the CME Group exchanges, calculated with popular rolling techniques. The data covers 75 root Future contracts, starts in 2012, and is delivered on a daily frequency with a zip file with all the contract mappings. This dataset is created by daily processing of the US historical Future chains.</p>
<p>The US Futures Security Master dataset by QuantConnect provides mapping reference data for the most liquid contracts of the CME Group exchanges, calculated with popular rolling techniques. The data covers 162 root Future contracts, starts in 2012, and is delivered on a daily frequency with a zip file with all the contract mappings. This dataset is created by daily processing of the US historical Future chains.</p>

<p>This dataset, paired the US Futures dataset, supports the following rolling techniques: ForwardPanamaCanal, BackwardsPanamaCanal, and Backwards Ratio. You can set the specific date of rolling to occur on the LastTradingDay, FirstDayMonth, or on the day where the contract with the greatest OpenInterest changes.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</tr></thead><tbody><tr><td>Start Date</td>
<td>January 2012</td>
</tr><tr><td>Asset Coverage</td>
<td>75 Liquid Futures</td>
<td>162 Liquid Futures</td>
</tr><tr><td>Data Density</td>
<td>Regular</td>
</tr><tr><td>Resolution</td>
Expand Down
Loading

0 comments on commit 6bc0c83

Please sign in to comment.