-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Trailing Stop for All Fill Models
- Loading branch information
1 parent
b04da06
commit 30297c4
Showing
25 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
...y Modeling/02 Trade Fills/02 Supported Models/02 Future Model/07 Trailing Stop 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,4 @@ | ||
<? | ||
$includeIntro = true; | ||
include(DOCS_RESOURCES."/reality-modeling/trade-fills/trailing-stop-orders.php"); | ||
?> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...ing/02 Trade Fills/02 Supported Models/03 Future Option Model/07 Trailing Stop 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,4 @@ | ||
<? | ||
$includeIntro = true; | ||
include(DOCS_RESOURCES."/reality-modeling/trade-fills/trailing-stop-orders.php"); | ||
?> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...odeling/02 Trade Fills/02 Supported Models/04 Immediate Model/07 Trailing Stop 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,4 @@ | ||
<? | ||
$includeIntro = true; | ||
include(DOCS_RESOURCES."/reality-modeling/trade-fills/trailing-stop-orders.php"); | ||
?> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions
4
...ling/02 Trade Fills/02 Supported Models/05 Latest Price Model/07 Trailing Stop 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,4 @@ | ||
<? | ||
$includeIntro = true; | ||
include(DOCS_RESOURCES."/reality-modeling/trade-fills/trailing-stop-orders.php"); | ||
?> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
221 changes: 221 additions & 0 deletions
221
Resources/reality-modeling/trade-fills/trailing-stop-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,221 @@ | ||
<? if ($includeIntro) { ?><p>The following table describes the fill logic of trailing stop orders for each data format and order direction. Once the stop condition is met, the model fills the orders and sets the fill price.</p><? } ?> | ||
|
||
<table class="qc-table table"> | ||
<thead> | ||
<tr> | ||
<th>Data Format</th> | ||
<th><code>TickType</code></th> | ||
<th>Order Direction | ||
</th><th>Stop Condition</th> | ||
<th>Fill Price</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Buy</td> | ||
<td>quote price > stop price</td> | ||
<td>max(stop price, quote price + slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Sell</td> | ||
<td>quote price < stop price</td> | ||
<td>min(stop price, quote price - slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Buy</td> | ||
<td>trade price > stop price</td> | ||
<td>max(stop price, last trade price + slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Sell</td> | ||
<td>trade price < stop price</td> | ||
<td>min(stop price, last trade price - slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>ask high price > stop price</td> | ||
<td>max(stop price, ask close price + slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>bid low price < stop price</td> | ||
<td>min(stop price, bid close price - slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>high price > stop price</td> | ||
<td>max(stop price, close price + slippage)</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>low price < stop price</td> | ||
<td>min(stop price, close price - slippage)</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<? if ($includeIntro) { ?><p>While the stop condition is not met, the model updates the stop price under certain conditions. The following table shows the update condition and stop price value for the nominal trailing amount.</p><? } ?> | ||
|
||
<table class="qc-table table"> | ||
<thead> | ||
<tr> | ||
<th>Data Format</th> | ||
<th><code>TickType</code></th> | ||
<th>Order Direction</th> | ||
<th>Update Condition</th> | ||
<th>Stop Price</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Buy</td> | ||
<td>stop price - quote price <= trailing amount</td> | ||
<td>quote price + trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Sell</td> | ||
<td>quote price - stop price <= trailing amount</td> | ||
<td>quote price - trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Buy</td> | ||
<td>stop price - trade price <= trailing amount</td> | ||
<td>trade price + trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Sell</td> | ||
<td>trade price - stop price <= trailing amount</td> | ||
<td>trade price - trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>stop price - ask low price <= trailing amount</td> | ||
<td>ask low price + trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>bid high price - stop price <= trailing amount</td> | ||
<td>bid high price - trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>stop price - low price <= trailing amount</td> | ||
<td>low price + trailing amount</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>high price - stop price <= trailing amount</td> | ||
<td>high price - trailing amount</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<? if ($includeIntro) { ?><p>The following table shows the update condition and stop price value for the percentage trailing amount.</p><? } ?> | ||
|
||
<table class="qc-table table"> | ||
<thead> | ||
<tr> | ||
<th>Data Format</th> | ||
<th><code>TickType</code></th> | ||
<th>Order Direction</th> | ||
<th>Update Condition</th> | ||
<th>Stop Price</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Buy</td> | ||
<td>stop price - quote price <= quote price * trailing amount</td> | ||
<td>quote price * (1 + trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Quote</code></td> | ||
<td>Sell</td> | ||
<td>quote price - stop price <= quote price * trailing amount</td> | ||
<td>quote price * (1 - trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Buy</td> | ||
<td>stop price - trade price <= trade price * trailing amount</td> | ||
<td>trade price * (1 + trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>Tick</code></td> | ||
<td><code>Trade</code></td> | ||
<td>Sell</td> | ||
<td>trade price - stop price <= trade price * trailing amount</td> | ||
<td>trade price * (1 - trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>stop price - ask low price <= ask low price * trailing amount</td> | ||
<td>ask low price * (1 + trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>QuoteBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>bid high price - stop price <= bid high price * trailing amount</td> | ||
<td>bid high price * (1 - trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Buy</td> | ||
<td>stop price - low price <= stop price * trailing amount</td> | ||
<td>low price * (1 + trailing amount)</td> | ||
</tr> | ||
<tr> | ||
<td><code>TradeBar</code></td> | ||
<td><br></td> | ||
<td>Sell</td> | ||
<td>high price - stop price <= high price * trailing amount</td> | ||
<td>high price * (1 - trailing amount)</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<p>The model only fills trailing stop orders when the exchange is open.</p> | ||
<? | ||
$orderType = "trailing stop"; | ||
include(DOCS_RESOURCES."/reality-modeling/trade-fills/fill-with-stale-data.php"); | ||
?> |