alpacahq / alpacahq/Alpaca-API

Add order_id to TradeActivity entity so fills can be linked to orders

Open
#94 2 comments 2 reactions 0 assignees View on GitHub
feature request
Dominant language
No language data
Stars
173
Forks
17
PR merge metrics
No merged PRs in 30d

Description

I propose adding an order_id attribute to the TradeActivity entity returned by `/v2/account/activities/FILL`. This will allow associating fills with the corresponding order.

**Description of problem**: Users need a way to maintain a complete, accurate, and fault-tolerant local view of orders and fills. A basic part of this requirement is the need to know which fills correspond to which orders.

**Current candidate APIs**

To reliably track fills and associate them with orders, these are the candidate APIs and their current limitations:

1. **`/v2/orders/{order_id}`**: with an order ID, you can query the order status, which includes the shares filled and avg price. But, this provides only an aggregate view of the order's fills. If the order had multiple partial fills, this endpoint does not provide that granularity.
2. **Streaming `trade_updates`**: the websocket API provides a fully granular stream of fills, and provides the associated order entity. Great! But, a streaming connection can't be exclusively relied upon to maintain an accurate local view, since events will be missed if the connection goes down for whatever reason.
3. **`/v2/account/activities/FILL`**: The trade activities API provides a fully granular view of fills. And because historical fills can be queried, it is possible to backfill and maintain an accurate local view even if the connection is interrupted. But, there is no reliable way to link the fill activity to the associated order.

Adding order_id to the `/v2/account/activities/FILL` endpoint seems to me the right solution, but if there is another solution I'm missing, please point me in the right direction.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.