Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 10 additions & 9 deletions 01 Cloud Platform/10 Live Trading/02 Brokerages/00.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
"05" : "US Equities, Equity Options, Index Options, & Crypto",
"06" : "US Equities, Equity Options, & Crypto",
"07" : "US Equities, Equity Options, Index, & Index Options",
"08" : "US Equities, Equity Options, Index, & Index Options",
"09" : "Crypto & Crypto Futures",
"08" : "US Equities, Equity Options, & Index Options",
"09" : "US Equities, Equity Options, Index, & Index Options",
"10" : "Crypto & Crypto Futures",
"11" : "US Equities & Equity Options",
"12" : "Crypto",
"11" : "Crypto & Crypto Futures",
"12" : "US Equities & Equity Options",
"13" : "Crypto",
"14" : "Crypto",
"15" : "Crypto Futures",
"16" : "US Equities, Equity Options, Futures, & Index Options",
"15" : "Crypto",
"16" : "Crypto Futures",
"17" : "US Equities, Equity Options, Futures, & Index Options",
"18" : "US Equities, Equity Options, Futures, Future Options, Index, & Index Options",
"19" : "Futures",
"20" : "US Equities",
"18" : "US Equities, Equity Options, Futures, & Index Options",
"19" : "US Equities, Equity Options, Futures, Future Options, Index, & Index Options",
"20" : "Futures",
"21" : "US Equities",
"97" : "Financial Information eXchange",
"98" : "CFD & FOREX",
"99" : "Request New Additions"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<? include(DOCS_RESOURCES."/landing-page-introductions/individual-brokerages.php"); ?>
<? include(DOCS_RESOURCES."/brokerages/introduction-by-brokerage/clearstreet.html"); ?>
<!--p>To view the implementation of the Clear Street brokerage integration, see the <a href='https://github.com/QuantConnect/Lean.Brokerages.ClearStreet' rel='nofollow' target="_blank">Lean.Brokerages.ClearStreet repository</a>.</p-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>Clear Street supports cash and margin accounts. To set the account type in an algorithm, see the <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet">Clear Street brokerage model documentation</a>.</p>

<h4>Create an Account</h4>
<p>Follow the <a rel="nofollow" target="_blank" href="https://app.clearstreet.com/">sign up wizard</a> on the Clear Street website to create a Clear Street account.</p>

<h4>Create API Credentials</h4>
<p>To trade with the Clear Street API, you need an API key, which serves as your access token, and the ID of the Clear Street account you want to trade. The following steps summarize how to get them. For more information, see <a rel="nofollow" target="_blank" href="https://docs.clearstreet.com/">Get Started</a> in the Clear Street API documentation.</p>
<ol>
<li>Log in to the <a rel="nofollow" target="_blank" href="https://app.clearstreet.com/">Clear Street web app</a>.</li>
<li>Click the <span class='menu-name'>Account</span> icon in the left navigation and then click <span class='menu-name'>API keys</span>.</li>
<li>Generate a named <span class='field-name'>API key</span> and save it. The page shows the status and expiration of each key, and you can revoke a key at any time. Treat the key like a password.</li>
<li>Note the numeric <span class='field-name'>account ID</span> of the Clear Street account you want to trade. Clear Street lets you have more than one account, so the account ID picks which one to trade.</li>
</ol>

<h4>Paper Trading</h4>

<p>The Clear Street API doesn't support paper trading, but you can follow these steps to simulate it with QuantConnect:</p>

<ol>
<li>In the <code class="csharp">Initialize</code><code class="python">initialize</code> method of your algorithm, <a href='/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet'>set the Clear Street brokerage model and your account type</a>.</li>
<li><a href="/docs/v2/cloud-platform/live-trading/brokerages/quantconnect-paper-trading#15-Deploy-Live-Algorithms">Deploy your algorithm with the QuantConnect Paper Trading brokerage</a>.</li>
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?
include(DOCS_RESOURCES."/brokerages/clearstreet/asset-classes.php");

$brokerageName = "Clear Street";
include(DOCS_RESOURCES."/brokerages/us-etfs.php");
?>

<p>The Clear Street API currently supports options trading levels 1 and 2, which cover covered calls, cash-secured puts, and long calls and puts.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Clear Street doesn't provide a live data feed, so we recommend the <a href='/docs/v2/cloud-platform/datasets/quantconnect'>QuantConnect data provider</a>, which is free and supplies <a href='/docs/v2/cloud-platform/datasets/quantconnect/us-equities'>US Equities</a>, <a href='/docs/v2/cloud-platform/datasets/quantconnect/us-equity-options'>US Equity Options</a>, and <a href='/docs/v2/cloud-platform/datasets/quantconnect/us-index-options'>US Index Options</a> data during live trading. It doesn't supply Index data, so add a third-party data provider such as <a href='/docs/v2/cloud-platform/datasets/polygon'>Polygon</a> to trade Index Options. Index Options need data for the underlying index, such as SPX, VIX, and NDX. For more information about live data providers, see <a href='/docs/v2/cloud-platform/datasets'>Datasets</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<p>We model the Clear Street API by supporting several order types, the <code>TimeInForce</code> order property, and order updates. When you deploy live algorithms, you can <a href='/docs/v2/cloud-platform/live-trading/algorithm-control#03-Place-Manual-Trades'>place manual orders</a> through the IDE.</p>
<? include(DOCS_RESOURCES."/brokerages/clearstreet/orders.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Clear Street limits the rate of requests to its trading API and answers with a <code>429 Too Many Requests</code> error when you exceed the limit. Clear Street doesn't publish the limit values. Our Clear Street integration reads your order updates by polling the API every 3 seconds. To avoid hitting these limits, design your algorithm to issue orders sparingly.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Clear Street doesn't publish its trading fees on its website. To learn the fees of your account, contact <a rel="nofollow" target="_blank" href="https://www.clearstreet.com/">Clear Street</a>. To view how we model their fees, see <a href='/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet#06-Fees'>Fees</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>We model <a href='/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet#07-Buying-Power'>buying power</a> and <a href='/docs/v2/writing-algorithms/reality-modeling/margin-calls'>margin calls</a> to ensure your algorithm stays within the margin requirements.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?
$brokerageName = "Clear Street";
$paperTradingSupported = false;
include(DOCS_RESOURCES."/brokerages/slippage.php");
?>

<p>To view how we model Clear Street slippage, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet#05-Slippage">Slippage</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?
$brokerageName = "Clear Street";
$paperTradingSupported = false;
include(DOCS_RESOURCES."/brokerages/fills.php");
?>
<p>To view how we model Clear Street order fills, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet#04-Fills">Fills</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?
$usBrokerage=true;
$cashAccount=true;
$marginAccount=true;
$equities=true;
$options=true;
include(DOCS_RESOURCES."/brokerages/settlements.php");
?>

<p>To view how we model settlement for Clear Street trades, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet#08-Settlement">Settlement</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?
$brokerageName = "Clear Street";
$statusPageURL = null;
include(DOCS_RESOURCES."/brokerages/security-and-stability.php");
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<p>The following algorithm demonstrates the functionality of the Clear Street brokerage:</p>

<div class="section-example-container testable">
<pre class="csharp">// Demonstrate Clear Street brokerage functionality with an EMA crossover strategy on SPY.
public class ClearStreetDemoAlgorithm : QCAlgorithm
{
private ExponentialMovingAverage _fast;
private ExponentialMovingAverage _slow;

public override void Initialize()
{
SetStartDate(2024, 9, 1);
SetEndDate(2024, 12, 31);
SetCash(100000);
SetBrokerageModel(BrokerageName.ClearStreet, AccountType.Margin);
var symbol = AddEquity("SPY", Resolution.Daily).Symbol;
_fast = EMA(symbol, 10, Resolution.Daily);
_slow = EMA(symbol, 50, Resolution.Daily);
}

public override void OnData(Slice slice)
{
if (!_slow.IsReady) return;
if (_fast &gt; _slow &amp;&amp; !Portfolio.Invested)
SetHoldings("SPY", 1);
else if (_fast &lt; _slow &amp;&amp; Portfolio.Invested)
Liquidate();
}
}</pre>
<pre class="python"># Demonstrate Clear Street brokerage functionality with an EMA crossover strategy on SPY.
class ClearStreetDemoAlgorithm(QCAlgorithm):
def initialize(self) -&gt; None:
self.set_start_date(2024, 9, 1)
self.set_end_date(2024, 12, 31)
self.set_cash(100000)
self.set_brokerage_model(BrokerageName.CLEAR_STREET, AccountType.MARGIN)
symbol = self.add_equity("SPY", Resolution.DAILY).symbol
self._fast = self.ema(symbol, 10, Resolution.DAILY)
self._slow = self.ema(symbol, 50, Resolution.DAILY)

def on_data(self, slice: Slice) -&gt; None:
if not self._slow.is_ready:
return
if self._fast.current.value &gt; self._slow.current.value and not self.portfolio.invested:
self.set_holdings("SPY", 1)
elif self._fast.current.value &lt; self._slow.current.value and self.portfolio.invested:
self.liquidate()</pre>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?
$brokerageName = "Clear Street";
$cashState = false;
$holdingsState = false;
$secondBullet = "";
$authentication = "<li>Enter your Clear Street access token and account ID.</li>" . file_get_contents(DOCS_RESOURCES."/brokerages/create-credentials/clearstreet.html");
$postDeploy = "";
$dataProviderDetails = "<p>Clear Street doesn't provide a live data feed, so use the <a href='/docs/v2/cloud-platform/datasets'>QuantConnect data provider</a> or another data provider for the securities you trade.</p>";
include(DOCS_RESOURCES."/live-trading/deploy-live-algorithm.php");
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<? include(DOCS_RESOURCES."/brokerages/clearstreet/troubleshooting.html"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "metadata",
"values": {
"description": "Our Clear Street integration lets you deploy live trading algorithms on our co-located servers that trade the capital you have in your Clear Street account.",
"keywords": "Clear Street, ClearStreet, live trading, brokerage integration, deploy co-located algorithms",
"og:description": "Our Clear Street integration lets you deploy live trading algorithms on our co-located servers that trade the capital you have in your Clear Street account.",
"og:title": "Clear Street - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Clear Street - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/cloud-platform/live-trading/brokerages/clearstreet.png"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<? include(DOCS_RESOURCES."/brokerages/deposits-and-withdrawals.html");?>
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"AlpacaBrokerageSettings": object,
"WebullBrokerageSettings": object,
"PublicBrokerageSettings": object,
"ClearStreetBrokerageSettings": object,
"BloombergFixSettings": object,
},
"dataProviders":
Expand Down Expand Up @@ -866,6 +867,33 @@
</table><table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>ClearStreetBrokerageSettings</code> Model - Settings for using Clear Street as the brokerage for a live algorithm.</th>
</tr>
</thead>
<tr>
<td width="20%">id</td> <td> <code>string Enum<br/><i><sub>required</sub></i></code> <br/> Id of the module. Options : ['ClearStreetBrokerage']</td>
</tr>
<tr>
<td width="20%">clearstreet-access-token</td> <td> <code>string<br/><i><sub>required</sub></i></code> <br/> Your Clear Street API access token.</td>
</tr>
<tr>
<td width="20%">clearstreet-account-id</td> <td> <code>string<br/><i><sub>required</sub></i></code> <br/> Your Clear Street account ID, the numeric ID of the account the algorithm trades.</td>
</tr>
<tr>
<td width="20%">Example</td>
<td>
<div class="cli section-example-container"><pre>
{
"id": "ClearStreetBrokerage",
"clearstreet-access-token": "string",
"clearstreet-account-id": "string"
}</pre>
</div>
</td>
</tr>
</table><table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>PublicBrokerageSettings</code> Model - Settings for using Public as the brokerage for a live algorithm.</th>
</tr>
</thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"18": "",
"19": "",
"20": "",
"21": ""
"21": "",
"22": ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>This page explains the <code>ClearStreetBrokerageModel</code>, including the asset classes it supports, its default <a href='/docs/v2/writing-algorithms/reality-modeling/key-concepts#02-Security-Level-Models'>security-level models</a>, and its default markets.</p>

<div class="section-example-container">
<pre class="csharp">SetBrokerageModel(BrokerageName.ClearStreet, AccountType.Cash);
SetBrokerageModel(BrokerageName.ClearStreet, AccountType.Margin);</pre>
<pre class="python">self.set_brokerage_model(BrokerageName.CLEAR_STREET, AccountType.CASH)
self.set_brokerage_model(BrokerageName.CLEAR_STREET, AccountType.MARGIN)</pre>
</div>

<p class='csharp'>For more information about this model, see the <a target="_blank" rel="nofollow" href="https://www.lean.io/docs/v2/lean-engine/class-reference/cs/classQuantConnect_1_1Brokerages_1_1ClearStreetBrokerageModel.html">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Brokerages/ClearStreetBrokerageModel.cs">implementation</a>.</p>
<p class='python'>For more information about this model, see the <a target="_blank" rel="nofollow" href="https://www.lean.io/docs/v2/lean-engine/class-reference/py/QuantConnect/Brokerages/ClearStreetBrokerageModel/">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Brokerages/ClearStreetBrokerageModel.cs">implementation</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<? include(DOCS_RESOURCES."/brokerages/clearstreet/asset-classes.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>The <code>ClearStreetBrokerageModel</code> supports several order types, order properties, and order updates.</p>

<?php include(DOCS_RESOURCES."/brokerages/clearstreet/orders.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/trade-fills/supported-models/equity-model'>EquityFillModel</a> for Equity trades and the <a href='/docs/v2/writing-algorithms/reality-modeling/trade-fills/supported-models/immediate-model'>ImmediateFillModel</a> for Equity Options and Index Options trades.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/slippage/supported-models#02-Null-Model'>NullSlippageModel</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#13-Interactive-Brokers-Model'>InteractiveBrokersFeeModel</a> for Equity and Equity Option trades and the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#02-Constant-Model'>ConstantFeeModel</a> with no fees for Index Option trades.</p>

<div class="section-example-container">
<pre class="csharp">// For Equity and Equity Option trades:
security.SetFeeModel(new InteractiveBrokersFeeModel());

// For Index Option trades:
security.SetFeeModel(new ConstantFeeModel(0.0m));</pre>
<pre class="python"># For Equity and Equity Option trades:
security.set_fee_model(InteractiveBrokersFeeModel())

# For Index Option trades:
security.set_fee_model(ConstantFeeModel(0))</pre>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <code>SecurityMarginModel</code>. If you have a margin account, the <code>ClearStreetBrokerageModel</code> allows up to 2x leverage.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/settlement/supported-models#02-Immediate-Model'>ImmediateSettlementModel</a> for margin accounts and the <a href='/docs/v2/writing-algorithms/reality-modeling/settlement/supported-models#03-Delayed-Model'>DelayedSettlementModel</a> with the <a href='/docs/v2/writing-algorithms/reality-modeling/settlement/key-concepts#03-Default-Behavior'>default settlement rules</a> for cash accounts.</p>

<div class="section-example-container">
<pre class="csharp">// For cash accounts:
security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime));

// For margin accounts:
security.SetSettlementModel(new ImmediateSettlementModel());</pre>
<pre class="python"># For cash accounts:
security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME))

# For margin accounts:
security.set_settlement_model(ImmediateSettlementModel())</pre>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>ClearStreetBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/margin-interest-rate/supported-models#02-Null-Model'>NullMarginInterestRateModel</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The default market of the <code>ClearStreetBrokerageModel</code> is <code>Market.USA</code>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<p>
The <code>ClearStreetBrokerageModel</code> doesn't set a default currency.
To change the algorithm's currency from USD to a different currency, see <a href='/docs/v2/writing-algorithms/initialization#03-Set-Account-Currency'>Set Account Currency</a>.
</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "metadata",
"values": {
"description": "This page explains the default security-level models and markets of the ClearStreetBrokerageModel.",
"keywords": "brokerage model, fill model, slippage model, fee model, buying power model, margin model, settlement model, default markets",
"og:description": "This page explains the default security-level models and markets of the ClearStreetBrokerageModel.",
"og:title": "Clear Street - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Clear Street - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/reality-modeling/brokerages/supported-models/clearstreet.png"
}
}
Loading