Skip to content

Commit

Permalink
add streamer refresh interval (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 authored Feb 5, 2025
1 parent bcbb811 commit a5788cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tastytrade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
BACKTEST_URL = "https://backtester.vast.tastyworks.com"
CERT_URL = "https://api.cert.tastyworks.com"
VAST_URL = "https://vast.tastyworks.com"
VERSION = "9.8"
VERSION = "9.9"

__version__ = VERSION

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
Expand Down
6 changes: 5 additions & 1 deletion tastytrade/streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ class DXLinkStreamer:
def __init__(
self,
session: Session,
refresh_interval: float = 0.1,
reconnect_args: tuple[Any, ...] = (),
reconnect_fn: Optional[Callable[..., Coroutine[Any, Any, None]]] = None,
ssl_context: SSLContext = create_default_context(),
Expand All @@ -404,6 +405,9 @@ def __init__(
"Underlying": 17,
}
self._subscription_state: dict[str, str] = defaultdict(lambda: "CHANNEL_CLOSED")
#: Time in seconds between fetching new events from dxfeed. You can try a higher
#: value if processing quote updates quickly is not a high priority.
self.refresh_interval = refresh_interval
#: An async function to be called upon reconnection. The first argument must be
#: of type `DXLinkStreamer` and will be a reference to the streamer object.
self.reconnect_fn = reconnect_fn
Expand Down Expand Up @@ -647,7 +651,7 @@ async def _channel_setup(self, event_type: str) -> None:
message = {
"type": "FEED_SETUP",
"channel": self._channels[event_type],
"acceptAggregationPeriod": 10,
"acceptAggregationPeriod": self.refresh_interval,
"acceptDataFormat": "COMPACT",
}

Expand Down

0 comments on commit a5788cf

Please sign in to comment.