Skip to content

Commit ef81237

Browse files
authored
fix: Add missing trade events (#630)
* fix: add missing trade events * fix: black
1 parent 3943194 commit ef81237

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

alpaca/trading/enums.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,18 @@ class CorporateActionDateType(str, Enum):
319319

320320

321321
class TradeEvent(str, Enum):
322-
FILL = "fill"
322+
ACCEPTED = "accepted"
323323
CANCELED = "canceled"
324-
PENDING_NEW = "pending_new"
324+
EXPIRED = "expired"
325+
FILL = "fill"
325326
NEW = "new"
326327
PARTIAL_FILL = "partial_fill"
328+
PENDING_CANCEL = "pending_cancel"
329+
PENDING_NEW = "pending_new"
330+
PENDING_REPLACE = "pending_replace"
331+
REJECTED = "rejected"
332+
REPLACED = "replaced"
333+
RESTATED = "restated"
327334

328335

329336
class QueryOrderStatus(str, Enum):

tests/trading/test_trading_models.py

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
from alpaca.trading.enums import OrderSide, OrderType, TimeInForce, OrderClass
1+
import uuid
2+
import warnings
3+
4+
import pytest
5+
6+
from alpaca.trading.enums import (
7+
OrderClass,
8+
OrderSide,
9+
OrderType,
10+
TimeInForce,
11+
TradeEvent,
12+
)
13+
from alpaca.trading.models import TradeUpdate
214
from alpaca.trading.requests import (
3-
MarketOrderRequest,
4-
TrailingStopOrderRequest,
515
LimitOrderRequest,
16+
MarketOrderRequest,
617
OptionLegRequest,
18+
TrailingStopOrderRequest,
719
)
8-
import pytest
9-
import warnings
1020

1121

1222
def test_has_qty_or_notional_but_not_both():
@@ -204,3 +214,26 @@ def factory(warn_validated: bool = True, **kwargs):
204214
OptionLegRequest(symbol=symbols[0], ratio_qty=1, side=OrderSide.BUY)
205215
],
206216
)
217+
218+
219+
def test_trade_update_events() -> None:
220+
base = {
221+
"timestamp": "2025-01-01T11:11:11.123456Z",
222+
"event": "accepted",
223+
"order": {
224+
"id": uuid.uuid4(),
225+
"client_order_id": "123",
226+
"created_at": "2025-01-01T11:11:11.123456Z",
227+
"updated_at": "2025-01-01T11:11:11.123456Z",
228+
"submitted_at": "2025-01-01T11:11:11.123456Z",
229+
"order_class": "simple",
230+
"time_in_force": "day",
231+
"status": "accepted",
232+
"extended_hours": False,
233+
},
234+
}
235+
236+
for event in TradeEvent:
237+
msg = base.copy()
238+
msg["event"] = event
239+
TradeUpdate(**msg)

0 commit comments

Comments
 (0)