Skip to content

Commit ec93871

Browse files
committed
Fix the quote mapping for the data steam
1 parent 37cae35 commit ec93871

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

alpaca_trade_api/entity.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,40 @@ def df(self):
244244
)
245245
self._df = df
246246
return self._df
247+
248+
249+
trade_mapping = {
250+
"sym": "symbol",
251+
"c": "conditions",
252+
"x": "exchange",
253+
"p": "price",
254+
"s": "size",
255+
"t": "timestamp"
256+
}
257+
258+
quote_mapping = {
259+
"T": "symbol",
260+
"X": "askexchange",
261+
"P": "askprice",
262+
"S": "asksize",
263+
"x": "bidexchange",
264+
"p": "bidprice",
265+
"s": "bidsize",
266+
"c": "conditions",
267+
"t": "timestamp"
268+
}
269+
270+
agg_mapping = {
271+
"sym": "symbol",
272+
"o": "open",
273+
"c": "close",
274+
"h": "high",
275+
"l": "low",
276+
"a": "average",
277+
"x": "exchange",
278+
"v": "volume",
279+
"s": "start",
280+
"e": "end",
281+
"vw": "vwap",
282+
"av": "totalvolume",
283+
}

alpaca_trade_api/polygon/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ class DailyOpenClose(Entity):
329329
"t": "timestamp"
330330
}
331331

332-
quote_mapping = {
332+
quote_mapping = {
333333
"sym": "symbol",
334334
"ax": "askexchange",
335335
"ap": "askprice",

alpaca_trade_api/stream2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
import re
55
import websockets
66
from .common import get_base_url, get_data_url, get_credentials
7-
from .entity import Account, Entity
7+
from .entity import Account, Entity, trade_mapping, agg_mapping, quote_mapping
88
from . import polygon
9-
from .polygon.entity import (
10-
Trade, Quote, Agg, trade_mapping, agg_mapping, quote_mapping
11-
)
9+
from .polygon.entity import Trade, Quote, Agg
1210
import logging
1311

1412

0 commit comments

Comments
 (0)