Skip to content

Commit 2a6fb22

Browse files
author
clickingbuttons
authored
Parse crypto aggs (#283)
* fix crypto agg and forex agg swap * fix typo * fix lint
1 parent 640631a commit 2a6fb22

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

examples/websocket/crypto.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from polygon.websocket.models import WebSocketMessage, Market
33
from typing import List
44

5-
c = WebSocketClient(market=Market.Crypto, subscriptions=["XT.*"])
5+
c = WebSocketClient(market=Market.Crypto, subscriptions=["XA.*"])
66

77

88
def handle_msg(msgs: List[WebSocketMessage]):

polygon/websocket/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(
3333
"""
3434
Initialize a Polygon WebSocketClient.
3535
36-
:param api_key: Your API keYour API key.
36+
:param api_key: Your API key.
3737
:param feed: The feed to subscribe to.
3838
:param raw: Whether to pass raw Union[str, bytes] to user callback.
3939
:param verbose: Whether to log client and server status messages.

polygon/websocket/models/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ def parse_single(data: Dict[str, Any]):
88
event_type = data["ev"]
99
if event_type in [EventType.EquityAgg.value, EventType.EquityAggMin.value]:
1010
return EquityAgg.from_dict(data)
11-
elif event_type == EventType.CryptoAgg.value:
12-
return CurrencyAgg.from_dict(data)
13-
elif event_type == EventType.CryptoQuote.value:
11+
elif event_type in [EventType.CryptoAgg.value, EventType.ForexAgg.value]:
1412
return CurrencyAgg.from_dict(data)
1513
elif event_type == EventType.EquityTrade.value:
1614
return EquityTrade.from_dict(data)

polygon/websocket/models/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class Market(Enum):
2020
class EventType(Enum):
2121
EquityAgg = "A"
2222
EquityAggMin = "AM"
23-
CryptoAgg = "CA"
24-
ForexAgg = "XA"
23+
CryptoAgg = "XA"
24+
ForexAgg = "CA"
2525
EquityTrade = "T"
2626
CryptoTrade = "XT"
2727
EquityQuote = "Q"

polygon/websocket/models/models.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class CurrencyAgg:
5656
vwap: Optional[float] = None
5757
start_timestamp: Optional[int] = None
5858
end_timestamp: Optional[int] = None
59-
avg_trade_size: Optional[int] = None
59+
avg_trade_size: Optional[float] = None
6060

6161
@staticmethod
6262
def from_dict(d):

0 commit comments

Comments
 (0)