Skip to content

Commit

Permalink
Parse crypto aggs (#283)
Browse files Browse the repository at this point in the history
* fix crypto agg and forex agg swap

* fix typo

* fix lint
  • Loading branch information
clickingbuttons authored Aug 18, 2022
1 parent 640631a commit 2a6fb22
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/websocket/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from polygon.websocket.models import WebSocketMessage, Market
from typing import List

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


def handle_msg(msgs: List[WebSocketMessage]):
Expand Down
2 changes: 1 addition & 1 deletion polygon/websocket/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(
"""
Initialize a Polygon WebSocketClient.
:param api_key: Your API keYour API key.
:param api_key: Your API key.
:param feed: The feed to subscribe to.
:param raw: Whether to pass raw Union[str, bytes] to user callback.
:param verbose: Whether to log client and server status messages.
Expand Down
4 changes: 1 addition & 3 deletions polygon/websocket/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ def parse_single(data: Dict[str, Any]):
event_type = data["ev"]
if event_type in [EventType.EquityAgg.value, EventType.EquityAggMin.value]:
return EquityAgg.from_dict(data)
elif event_type == EventType.CryptoAgg.value:
return CurrencyAgg.from_dict(data)
elif event_type == EventType.CryptoQuote.value:
elif event_type in [EventType.CryptoAgg.value, EventType.ForexAgg.value]:
return CurrencyAgg.from_dict(data)
elif event_type == EventType.EquityTrade.value:
return EquityTrade.from_dict(data)
Expand Down
4 changes: 2 additions & 2 deletions polygon/websocket/models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class Market(Enum):
class EventType(Enum):
EquityAgg = "A"
EquityAggMin = "AM"
CryptoAgg = "CA"
ForexAgg = "XA"
CryptoAgg = "XA"
ForexAgg = "CA"
EquityTrade = "T"
CryptoTrade = "XT"
EquityQuote = "Q"
Expand Down
2 changes: 1 addition & 1 deletion polygon/websocket/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class CurrencyAgg:
vwap: Optional[float] = None
start_timestamp: Optional[int] = None
end_timestamp: Optional[int] = None
avg_trade_size: Optional[int] = None
avg_trade_size: Optional[float] = None

@staticmethod
def from_dict(d):
Expand Down

0 comments on commit 2a6fb22

Please sign in to comment.