-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Alpaca Brokerage and Fee Models
- Loading branch information
1 parent
5e67f3d
commit a052ffe
Showing
70 changed files
with
209 additions
and
10 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
...gorithms/24 Reality Modeling/04 Transaction Fees/01 Key Concepts/03 Default Behavior.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p>The brokerage model of your algorithm automatically sets the fill model for each security. The default brokerage model is the <code>DefaultBrokerageModel</code>, which set the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#02-Constant-Model'>ConstantFeeModel</a> with no fees for Forex, CFD, and Crypto assets and sets the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#03-Interactive-Brokers-Model'>InteractiveBrokersFeeModel</a> for the remaining asset classes.</p> | ||
<p>The brokerage model of your algorithm automatically sets the fill model for each security. The default brokerage model is the <code>DefaultBrokerageModel</code>, which set the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#02-Constant-Model'>ConstantFeeModel</a> with no fees for Forex, CFD, and Crypto assets and sets the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#11-Interactive-Brokers-Model'>InteractiveBrokersFeeModel</a> for the remaining asset classes.</p> |
20 changes: 20 additions & 0 deletions
20
...gorithms/24 Reality Modeling/04 Transaction Fees/02 Supported Models/03 Alpaca Model.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,20 @@ | ||
<p>The <code>AlpacaFeeModel</code> models <a rel="nofollow" target="_blank" href="https://docs.alpaca.markets/docs/crypto-fees">the fees of Alpaca</a>.</p> | ||
|
||
|
||
<div class="section-example-container"> | ||
<pre class="csharp">security.SetFeeModel(new AlpacaFeeModel());</pre> | ||
<pre class="python">security.set_fee_model(AlpacaFeeModel())</pre> | ||
</div> | ||
|
||
<p>The <code>AlpacaFeeModel</code> charges zero fees for Equity and Equity Options trading. It charges order fees of Alpaca for crypto trading which is a 0.15% maker and 0.25% taker fee. If you add liquidity to the order book by placing a limit order that doesn't cross the spread, you pay maker fees. If you remove liquidity from the order book by placing an order that crosses the spread, you pay taker fees. Alpaca adjusts your fees based on your 30-day trading volume, but we don't currently model these metrics to adjust fees.</p> | ||
|
||
<p>The <code>AlpacaFeeModel</code> charges fees in the currency you receive from a trade. For example, if you buy ETHBTC, you pay fees in ETH. If you sell ETHBTC, you pay fees in BTC.</p> | ||
|
||
<p>To view the implementation of this model, see the <a target="_blank" rel="nofollow" href="https://github.com/QuantConnect/Lean/blob/master/Common/Orders/Fees/AlpacaFeeModel.cs">LEAN GitHub repository</a>.</p> | ||
|
||
<style> | ||
#binance-fee-table td:last-child, | ||
#binance-fee-table th:last-child { | ||
text-align: right; | ||
} | ||
</style> |
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.
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
"03": "", | ||
"04": "", | ||
"05": "", | ||
"06": "", | ||
"07": "", | ||
"08": "", | ||
"09": "", | ||
|
2 changes: 1 addition & 1 deletion
2
...ity Modeling/05 Brokerages/02 Supported Models/01 QuantConnect Paper Trading/06 Fees.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
11 changes: 11 additions & 0 deletions
11
...thms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/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,11 @@ | ||
<p>This page explains the <code>AlpacaBrokerageModel</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 it's default markets.</p> | ||
|
||
|
||
<div class="section-example-container"> | ||
<pre class="csharp">SetBrokerageModel(BrokerageName.Alpaca, AccountType.Cash); | ||
SetBrokerageModel(BrokerageName.Alpaca, AccountType.Margin);</pre> | ||
<pre class="python">self.set_brokerage_model(BrokerageName.ALPACA, AccountType.CASH) | ||
self.set_brokerage_model(BrokerageName.ALPACA, AccountType.MARGIN)</pre> | ||
</div> | ||
|
||
<p>To view the implementation of this model, see the <a rel='nofollow' target="_blank" href='https://github.com/QuantConnect/Lean/blob/master/Common/Brokerages/AlpacaBrokerageModel.cs'>LEAN GitHub repository</a>.</p> |
1 change: 1 addition & 0 deletions
1
...thms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/02 Asset Classes.php
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 @@ | ||
<? include(DOCS_RESOURCES."/brokerages/alpaca/asset-classes.php"); ?> |
3 changes: 3 additions & 0 deletions
3
... Algorithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/03 Orders.php
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,3 @@ | ||
<p>The <code>AlpacaBrokerageModel</code> supports several order types, order properties, and most order updates.</p> | ||
|
||
<? include(DOCS_RESOURCES."/brokerages/alpaca/orders.php"); ?> |
1 change: 1 addition & 0 deletions
1
... Algorithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/04 Fills.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 @@ | ||
<p>The <code>AlpacaBrokerageModel</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 Option and Crypto trades.</p> |
6 changes: 6 additions & 0 deletions
6
...gorithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/05 Slippage.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,6 @@ | ||
<p>The <code>AlpacaBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/slippage/supported-models#02-Null-Model'>NullSlippageModel</a>.</p> | ||
|
||
<div class="section-example-container"> | ||
<pre class="csharp">security.set_slippage_model(NullSlippageModel.instance);</pre> | ||
<pre class="python">security.set_slippage_model(NullSlippageModel.instance)</pre> | ||
</div> |
1 change: 1 addition & 0 deletions
1
...g Algorithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/06 Fees.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 @@ | ||
<p>The <code>AlpacaBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#03-Alpaca-Model'>AlpacaFeeModel</a> with the default argument values. We model current Alpaca fees on all assets.</p> |
3 changes: 3 additions & 0 deletions
3
...thms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/07 Buying Power.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,3 @@ | ||
<p>The <code>AlpacaBrokerageModel</code> uses the <code>CashBuyingPowerModel</code> for cash accounts, the <code>SecurityMarginModel</code> for margin accounts, and <code>OptionMarginModel</code> for Option trades.</p> | ||
|
||
<p>If you have a margin account, the <code>AlpacaBrokerageModel</code> allows 2x leverage for Equities, and 3x leverage for Crypto.</p> |
21 changes: 21 additions & 0 deletions
21
...rithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/08 Settlement.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,21 @@ | ||
<p>The <code>AlpacaBrokerageModel</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 with Equity and Equity Options.</p> | ||
|
||
|
||
<div class="section-example-container"> | ||
<pre class="csharp">// For US Equities with a cash account: | ||
security.SetSettlementModel(new DelayedSettlementModel(Equity.DefaultSettlementDays, Equity.DefaultSettlementTime)); | ||
|
||
// For Equity Options with a cash account: | ||
security.SetSettlementModel(new DelayedSettlementModel(Option.DefaultSettlementDays, Option.DefaultSettlementTime)); | ||
|
||
// For remaining cases: | ||
security.SetSettlementModel(new ImmediateSettlementModel());</pre> | ||
<pre class="python"># For US Equities with a cash account: | ||
security.set_settlement_model(DelayedSettlementModel(Equity.DEFAULT_SETTLEMENT_DAYS, Equity.DEFAULT_SETTLEMENT_TIME)) | ||
|
||
# For Equity Options with a cash account: | ||
security.set_settlement_model(DelayedSettlementModel(Option.DEFAULT_SETTLEMENT_DAYS, Option.DEFAULT_SETTLEMENT_TIME)) | ||
|
||
# For remaining cases: | ||
security.set_settlement_model(ImmediateSettlementModel())</pre> | ||
</div> |
1 change: 1 addition & 0 deletions
1
...Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/09 Margin Interest Rate.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 @@ | ||
<p>The <code>AlpacaBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/margin-interest-rate/supported-models#02-Null-Model'>NullMarginInterestRateModel</a>.</p> |
1 change: 1 addition & 0 deletions
1
...s/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/17 Default Markets.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 @@ | ||
<p>The default market of the <code>AlpacaBrokerageModel</code> is <code>Market.USA</code> for Equity and Equity Options, and <code class="csharp">Market.Coinbase</code><code class="python">Market.COINBASE</code> for Crypto.</p> |
12 changes: 12 additions & 0 deletions
12
... Algorithms/24 Reality Modeling/05 Brokerages/02 Supported Models/02 Alpaca/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": "This page explains the default security-level models and markets of the AlpacaBrokerageModel.", | ||
"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 AlpacaBrokerageModel.", | ||
"og:title": "Alpaca - Documentation QuantConnect.com", | ||
"og:type": "website", | ||
"og:site_name": "Alpaca - QuantConnect.com", | ||
"og:image": "https://cdn.quantconnect.com/docs/i/writing-algorithms/reality-modeling/brokerages/supported-models/alpaca.png" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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.
2 changes: 1 addition & 1 deletion
2
...Supported Models/03 Bitfinex/06 Fees.html → ...Supported Models/04 Bitfinex/06 Fees.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p>The <code>BitfinexBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#08-Bitfinex-Model'>BitfinexFeeModel</a> with the default argument values that models the current Bitfinex fee schedule.</p> | ||
<p>The <code>BitfinexBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#07-Bitfinex-Model'>BitfinexFeeModel</a> with the default argument values that models the current Bitfinex fee schedule.</p> |
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.
2 changes: 1 addition & 1 deletion
2
...02 Supported Models/04 Bybit/06 Fees.html → ...02 Supported Models/05 Bybit/06 Fees.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p>The <code>BybitBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#09-Bybit-Model'>BybitFeeModel</a> for Crypto trades and the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#10-Bybit-Futures-Model'>BybitFuturesFeeModel</a> for Crypto Future trades. In both cases, the brokerage model uses the default argument values that models the Bybit fee schedule for VIP Level 0.</p> | ||
<p>The <code>BybitBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#08-Bybit-Model'>BybitFeeModel</a> for Crypto trades and the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#09-Bybit-Futures-Model'>BybitFuturesFeeModel</a> for Crypto Future trades. In both cases, the brokerage model uses the default argument values that models the Bybit fee schedule for VIP Level 0.</p> |
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.
2 changes: 1 addition & 1 deletion
2
...Supported Models/05 Coinbase/06 Fees.html → ...Supported Models/06 Coinbase/06 Fees.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p>The <code>CoinbaseBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#11-Coinbase-Model'>CoinbaseFeeModel</a>.</p> | ||
<p>The <code>CoinbaseBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#10-Coinbase-Model'>CoinbaseFeeModel</a>.</p> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...24 Reality Modeling/05 Brokerages/02 Supported Models/07 Interactive Brokers/06 Fees.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 |
---|---|---|
@@ -1 +1 @@ | ||
<p>The <code>InteractiveBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#03-Interactive-Brokers-Model'>InteractiveBrokersFeeModel</a> with the default argument values. We model current Interactive Brokers fees on all assets.</p> | ||
<p>The <code>InteractiveBrokersBrokerageModel</code> uses the <a href='/docs/v2/writing-algorithms/reality-modeling/transaction-fees/supported-models#11-Interactive-Brokers-Model'>InteractiveBrokersFeeModel</a> with the default argument values. We model current Interactive Brokers fees on all assets.</p> |
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,7 @@ | ||
<p><?= $writingAlgorithms ? "The <code>AlpacaBrokerageModel</code>" : "Our Alpaca integration" ?> supports the following asset classes:</p> | ||
|
||
<ul> | ||
<li><a href='/docs/v2/writing-algorithms/securities/asset-classes/us-equity'>US Equities</a></li> | ||
<li><a href='/docs/v2/writing-algorithms/securities/asset-classes/equity-options'>Equity Options</a></li> | ||
<li><a href='/docs/v2/writing-algorithms/securities/asset-classes/crypto'>Crypto</a></li> | ||
</ul> |
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,110 @@ | ||
<h4>Order Types</h4> | ||
|
||
<p>The following table describes the available order types for each asset class that <?= $cloudPlatform ? "our Alpaca integration" : "the <code>AlpacaBrokerageModel</code>" ?> supports:</p> | ||
|
||
<table class="qc-table table" id='order-types-table'> | ||
<thead> | ||
<tr> | ||
<th style='width: 40%'>Order Type</th> | ||
<th style='width: 20%'>Equity</th> | ||
<th style='width: 20%'>Equity Options</th> | ||
<th style='width: 20%'>Crypto</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/market-orders'>Market</a></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
</tr> | ||
<tr> | ||
<td><a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/limit-orders'>Limit</a></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
</tr> | ||
<tr> | ||
<td><a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/stop-market-orders'>Stop market</a></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td></td> | ||
</tr> | ||
<tr> | ||
<td><a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/stop-limit-orders'>Stop limit</a></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
</tr> | ||
<tr> | ||
<td><a href='/docs/v2/writing-algorithms/trading-and-orders/order-types/trailing-stop-orders'>Trailing stop</a></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td><img src="https://cdn.quantconnect.com/i/tu/check.png" alt="green check" width="15px;"></td> | ||
<td></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<style> | ||
#order-types-table td:not(:first-child), | ||
#order-types-table th:not(:first-child) { | ||
text-align: center; | ||
} | ||
</style> | ||
|
||
<h4>Time In Force</h4> | ||
<p><?= $writingAlgorithms ? "The <code>AlpacaBrokerageModel</code> supports" : "We model the Alpaca API by supporting" ?> the following <a href='/docs/v2/writing-algorithms/trading-and-orders/order-properties#03-Time-In-Force'>TimeInForce</a> instructions:</p> | ||
|
||
<ul> | ||
<li><code class="csharp">Day</code><code class="python">DAY</code></li> | ||
<li><code class="csharp">GoodTilCanceled</code><code class="python">GOOD_TIL_CANCELED</code></li> | ||
<li><code class="csharp">GoodTilDate</code><code class="python">good_til_date</code></li> | ||
</ul> | ||
|
||
<? if ($writingAlgorithms) { ?> | ||
<div class="section-example-container"> | ||
<pre class="csharp">public override void Initialize() | ||
{ | ||
// Set the default order properties | ||
DefaultOrderProperties.TimeInForce = TimeInForce.GoodTilCanceled; | ||
} | ||
|
||
public override void OnData(Slice slice) | ||
{ | ||
// Use default order order properties | ||
LimitOrder(_symbol, quantity, limitPrice); | ||
|
||
// Override the default order properties | ||
LimitOrder(_symbol, quantity, limitPrice, | ||
orderProperties: new TradeStationOrderProperties | ||
{ | ||
TimeInForce = TimeInForce.Day | ||
}); | ||
LimitOrder(_symbol, quantity, limitPrice, | ||
orderProperties: new TradeStationOrderProperties | ||
{ | ||
TimeInForce = TimeInForce.GoodTilDate(new DateTime(year, month, day)) | ||
}); | ||
}</pre> | ||
<pre class="python">def initialize(self) -> None: | ||
# Set the default order properties | ||
self.default_order_properties.time_in_force = TimeInForce.GOOD_TIL_CANCELED | ||
|
||
def on_data(self, slice: Slice) -> None: | ||
# Use default order order properties | ||
self.limit_order(self._symbol, quantity, limit_price) | ||
|
||
# Override the default order properties | ||
order_properties = TradeStationOrderProperties() | ||
order_properties.time_in_force = TimeInForce.DAY | ||
self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties) | ||
|
||
order_properties.time_in_force = TimeInForce.good_til_date(datetime(year, month, day)) | ||
self.limit_order(self._symbol, quantity, limit_price, order_properties=order_properties)</pre> | ||
</div> | ||
<? } ?> | ||
|
||
<h4>Updates</h4> | ||
<p><?= $writingAlgorithms ? "The <code>AlpacaBrokerageModel</code> supports" : "We model the Alpaca API by supporting" ?> <a href='/docs/v2/writing-algorithms/trading-and-orders/order-management/order-tickets#04-Update-Orders'>order updates</a>.</p> | ||
|
||
<? include(DOCS_RESOURCES."/brokerages/handling-splits.html"); ?> |