alpacahq / alpacahq/Alpaca-API

Request support for nested order.

オープン
#204 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
言語のデータがありません
スター
173
フォーク
17
PR マージ指標
30日以内にマージされた PR はありません

説明

**Is your feature request related to a problem? Please describe.**
As a system, it would be great to support orders with nested legs which allows the user to place a chain of orders in one endpoint call. This will enable a user to place a two-side order, including take_profit and stop_loss orders via one endpoint call, without too much effort on the code and minimize the latency.

Currently, I can simulate this behavior by monitoring streaming trades and placing market OTOCO order when the signal shows on one side. I can't place limit orders simultaneously on two sides as the system forbids orders on two sides, even they are limit orders. This leads to slippages due to the latency between the client and server, and needs to subscribe trade to my client.

For example, if a user wants an OCO order, which long at 110, take profit at 115, stop loss at 100; OR short at 90, take profit at 85, stop loss at 100. a nested order would look like this:
```json
{
"order_class": "oco",
"legs": [
{
"order_class": "otoco",
"triger": {
"side": "buy",
"qty": 10,
"limit_price": 110,
"type": "limit",
},
"legs": [
{
"side": "sell",
"qty": 1,
"limit_price": 115,
"type": "limit",
},
{
"side": "sell",
"qty": 1,
"stop_price": 90,
"type": "stop",
},
],
},
{
"order_class": "otoco",
"triger": {
"side": "sell",
"qty": 1,
"limit_price": 90,
"type": "limit",
},
"legs": [
{
"side": "buy",
"qty": 1,
"limit_price": 85,
"type": "limit",
},
{
"side": "buy",
"qty": 1,
"stop_price": 100,
"type": "stop",
},
],
},
],
}
```

Similarly, it can further expand to one buy signal with multiple exit signals on different conditions. Examples in TD Ameritrade:
https://developer.tdameritrade.com/content/place-order-samples

**Describe the solution you'd like**
Alpaca has the fundamentals to implement nested orders using the existing attribute `legs`. Extending existing `order_class` with more options would do the job. e.g. when `order_class = 'oco' or 'oto'`, accepting `legs` as extra input for leg orders, which follows the schema of order.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。