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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion 01 Cloud Platform/10 Live Trading/02 Brokerages/00.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"02" : "US Equities, Equity Options, FOREX, Futures, Future Options, Index, Index Options, & CFD",
"03" : "US Equities, Equity Options, Futures, Index, & Index Options",
"04" : "US Equities, Equity Options, Futures, Future Options, Index, & Index Options",
"05" : "US Equities, Equity Options, & Crypto",
"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",
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/public.html"); ?>
<!--p>To view the implementation of the Public brokerage integration, see the <a href='https://github.com/QuantConnect/Lean.Brokerages.Public' rel='nofollow' target="_blank">Lean.Brokerages.Public repository</a>.</p-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<p>Public 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/public">Public brokerage model documentation</a>.</p>

<h4>Create an Account</h4>
<p>Follow the <a rel="nofollow" target="_blank" href="https://public.com/">account creation wizard</a> on the Public website to create a Public account.</p>

<h4>Create API Credentials</h4>
<p>To trade with the Public API, you need a secret key and the account number of the Public account you want to trade. The following steps summarize how to get them. For a video walkthrough, see <a rel="nofollow" target="_blank" href="https://www.youtube.com/watch?v=de-CfFI2wkw">The Public API: How to Program Your Trading of Stocks, Options, and More</a> on the Public YouTube channel.</p>
<ol>
<li>Apply for API access on the <a rel="nofollow" target="_blank" href="https://public.com/api">Public API</a> page. Fill out and submit the form, and then wait for the Public concierge team to approve your application.</li>
<li>After approval, log in to <a rel="nofollow" target="_blank" href="https://public.com/">Public.com</a>, open the <span class='menu-name'>Settings</span> menu, click <span class='menu-name'>Security</span> on the far right side of the menu, and then click <span class='button-name'>API</span> in the left panel.</li>
<li>Generate your <span class='field-name'>secret key</span>. You can keep up to two keys at once and remove a key at any time. Keys inherit your account's permissions and allow read and write access, and LEAN exchanges the secret key for short-lived access tokens automatically.</li>
<li>Note the <span class='field-name'>account number</span> of the Public account you want to trade. Public lets you have more than one account, so the account number picks which one to trade.</li>
</ol>

<h4>Paper Trading</h4>

<p>The Public 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/public'>set the Public 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,6 @@
<?
include(DOCS_RESOURCES."/brokerages/public/asset-classes.php");

$brokerageName = "Public";
include(DOCS_RESOURCES."/brokerages/us-etfs.php");
?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Public doesn't provide a live data feed. The <a href='/docs/v2/cloud-platform/datasets/quantconnect'>QuantConnect data provider</a> supplies US Equity and Crypto data during live trading. For Equity Options, Index, and Index Options data, use the <a href='/docs/v2/cloud-platform/datasets/polygon'>Polygon data provider</a> or a data feed from another brokerage, such as <a href='/docs/v2/cloud-platform/datasets/tastytrade'>Tastytrade</a> or <a href='/docs/v2/cloud-platform/datasets/charles-schwab'>Charles Schwab</a>. 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 Public 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/public/orders.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>The Public API limits the rate of requests, so our Public integration throttles its requests to 10 requests per second. Public also allows up to 10 pending orders that open new positions on the same underlying.</p>

<p>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>Public trading for Equity, Equity Options, and Options on ETFs is commission-free during regular market hours. Equity trades during extended hours cost $2.99 per trade, Index Options cost $0.50 per contract, and Crypto trades carry a fee that depends on the order amount. To view the Public trading fees, see the <a rel="nofollow" target="_blank" href="https://public.com/disclosures/fee-schedule">Fee Schedule</a> page on the Public website. To view how we model their fees, see <a href='/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/public#06-Fees'>Fees</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>We model <a href='/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/public#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>

<p>Trading on margin with Public, which includes short selling and buying for more than your settled cash, requires your account to hold at least $2,000 of cash, equities, and bonds. The <code class="csharp">UseMargin</code><code class="python">use_margin</code> <a href='/docs/v2/cloud-platform/live-trading/brokerages/public#06-Orders'>order property</a> selects the buying power each order uses.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?
$brokerageName = "Public";
$paperTradingSupported = false;
include(DOCS_RESOURCES."/brokerages/slippage.php");
?>

<p>To view how we model Public slippage, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/public#05-Slippage">Slippage</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?
$brokerageName = "Public";
$paperTradingSupported = false;
include(DOCS_RESOURCES."/brokerages/fills.php");
?>
<p>To view how we model Public order fills, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/public#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 Public trades, see <a href="/docs/v2/writing-algorithms/reality-modeling/brokerages/supported-models/public#08-Settlement">Settlement</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?
$brokerageName = "Public";
$statusPageURL = null;
include(DOCS_RESOURCES."/brokerages/security-and-stability.php");
?>
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
@@ -0,0 +1,48 @@
<p>The following algorithm demonstrates the functionality of the Public brokerage:</p>

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

public override void Initialize()
{
SetStartDate(2024, 9, 1);
SetEndDate(2024, 12, 31);
SetCash(100000);
SetBrokerageModel(BrokerageName.Public, 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 Public brokerage functionality with an EMA crossover strategy on SPY.
class PublicDemoAlgorithm(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.PUBLIC, 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 = "Public";
$cashState = false;
$holdingsState = false;
$secondBullet = "";
$authentication = "<li>Enter your Public secret key and account number.</li>" . file_get_contents(DOCS_RESOURCES."/brokerages/create-credentials/public.html");
$postDeploy = "";
$dataProviderDetails = "<p>Public doesn't provide a live data feed, so use a data provider for the securities you trade. The <a href='/docs/v2/cloud-platform/datasets/quantconnect'>QuantConnect data provider</a> supplies US Equity and Crypto data. For Equity Options, Index, and Index Options data, use the <a href='/docs/v2/cloud-platform/datasets/polygon'>Polygon data provider</a> or a data feed from another brokerage.</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/public/troubleshooting.html"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"type": "metadata",
"values": {
"description": "Our Public integration lets you deploy live trading algorithms on our co-located servers that trade the capital you have in your Public account.",
"keywords": "Public, live trading, brokerage integration, deploy co-located algorithms",
"og:description": "Our Public integration lets you deploy live trading algorithms on our co-located servers that trade the capital you have in your Public account.",
"og:title": "Public - Documentation QuantConnect.com",
"og:type": "website",
"og:site_name": "Public - QuantConnect.com",
"og:image": "https://cdn.quantconnect.com/docs/i/cloud-platform/live-trading/brokerages/public.png"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
"TastytradeSettings": object,
"AlpacaBrokerageSettings": object,
"WebullBrokerageSettings": object,
"PublicBrokerageSettings": object,
},
"dataProviders":
}</pre>
Expand Down Expand Up @@ -860,6 +861,33 @@
</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>
<tr>
<td width="20%">id</td> <td> <code>string Enum<br/><i><sub>required</sub></i></code> <br/> Id of the module. Options : ['PublicBrokerage']</td>
</tr>
<tr>
<td width="20%">public-secret-key</td> <td> <code>string<br/><i><sub>required</sub></i></code> <br/> Your Public secret key.</td>
</tr>
<tr>
<td width="20%">public-account-number</td> <td> <code>string<br/><i><sub>required</sub></i></code> <br/> The number of the Public account you want to trade.</td>
</tr>
<tr>
<td width="20%">Example</td>
<td>
<div class="cli section-example-container"><pre>
{
"id": "PublicBrokerage",
"public-secret-key": "string",
"public-account-number": "string"
}</pre>
</div>
</td>
</tr>
</table><table class="table qc-table">
<thead>
<tr>
<th colspan="2"><code>BrokerageHolding</code> Model - Holding object class for creating a live algorithm.</th>
</tr>
</thead>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<p>The <code>PublicFeeModel</code> models <a rel="nofollow" target="_blank" href="https://public.com/disclosures/fee-schedule">the fees of Public</a> at the regular member tier.</p>

<div class="section-example-container">
<pre class="csharp">security.SetFeeModel(new PublicFeeModel());</pre>
<pre class="python">security.set_fee_model(PublicFeeModel())</pre>
</div>

<p>The <code>PublicFeeModel</code> charges $0 USD for Equity trades during regular market hours and $2.99 USD per trade during extended hours. Options on stocks and ETFs are free, and Index Options cost $0.50 USD per contract. For Crypto trades, it charges a fee that depends on the order amount in USD:</p>

<table class="qc-table table">
<thead>
<tr>
<th>Order Amount (USD)</th>
<th>Fee (USD)</th>
</tr>
</thead>
<tbody>
<tr><td>$10 or less</td><td>$0.49</td></tr>
<tr><td>$10.01 - $25</td><td>$0.69</td></tr>
<tr><td>$25.01 - $50</td><td>$1.19</td></tr>
<tr><td>$50.01 - $100</td><td>$1.69</td></tr>
<tr><td>$100.01 - $250</td><td>$3.29</td></tr>
<tr><td>$250.01 - $500</td><td>$6.29</td></tr>
<tr><td>More than $500</td><td>1.25% of the order amount</td></tr>
</tbody>
</table>

<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_1Orders_1_1Fees_1_1PublicFeeModel.html">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Orders/Fees/PublicFeeModel.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/Orders/Fees/PublicFeeModel/">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Orders/Fees/PublicFeeModel.cs">implementation</a>.</p>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"type": "metadata",
"values": {
"description": "This page describes some of the pre-built fee models in LEAN. If none of these models perform exactly how you want, create a custom fee model.",
"keywords": "pre-built fee models, custom fee model, fees of Interactive Brokers, fees of Binance and Binance US, fees of Bitfinex, fees of Coinbase, fees of Kraken, fees of Samco, fees of Charles Schwab, fees of Webull, fees of Wolverine Execution Services, fees of Zerodha",
"keywords": "pre-built fee models, custom fee model, fees of Interactive Brokers, fees of Binance and Binance US, fees of Bitfinex, fees of Coinbase, fees of Kraken, fees of Public, fees of Samco, fees of Charles Schwab, fees of Webull, fees of Wolverine Execution Services, fees of Zerodha",
"og:description": "This page describes some of the pre-built fee models in LEAN. If none of these models perform exactly how you want, create a custom fee model.",
"og:title": "Supported Models - Documentation QuantConnect.com",
"og:type": "website",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>The <code>TradeStationBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#17-TradeStation-Model'>TradeStationFeeModel</a> with the default argument values. We model current <a rel='nofollow' target='_blank' href='https://qnt.co/tradestation-signup'>TradeStation</a> fees on all assets.</p>
<p>The <code>TradeStationBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#18-TradeStation-Model'>TradeStationFeeModel</a> with the default argument values. We model current <a rel='nofollow' target='_blank' href='https://qnt.co/tradestation-signup'>TradeStation</a> fees on all assets.</p>
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>The <code>TastytradeBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#16-Tastytrade-Model'>TastytradeFeeModel</a> with the default argument values. We model current <a rel='nofollow' target='_blank' href='https://qnt.co/tastytrade'>Tastytrade</a> fees on all assets.</p>
<p>The <code>TastytradeBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#17-Tastytrade-Model'>TastytradeFeeModel</a> with the default argument values. We model current <a rel='nofollow' target='_blank' href='https://qnt.co/tastytrade'>Tastytrade</a> fees on all assets.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<p>This page explains the <code>PublicBrokerageModel</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.Public, AccountType.Cash);
SetBrokerageModel(BrokerageName.Public, AccountType.Margin);</pre>
<pre class="python">self.set_brokerage_model(BrokerageName.PUBLIC, AccountType.CASH)
self.set_brokerage_model(BrokerageName.PUBLIC, 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_1PublicBrokerageModel.html">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Brokerages/PublicBrokerageModel.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/PublicBrokerageModel/">class reference</a> and <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Brokerages/PublicBrokerageModel.cs">implementation</a>.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<? include(DOCS_RESOURCES."/brokerages/public/asset-classes.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>The <code>PublicBrokerageModel</code> supports several order types, order properties, and order updates.</p>

<?php include(DOCS_RESOURCES."/brokerages/public/orders.php"); ?>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>PublicBrokerageModel</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, Index Options, and Crypto trades.</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>The <code>PublicBrokerageModel</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 @@
<p>The <code>PublicBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#15-Public-Model'>PublicFeeModel</a>.</p>
Loading