Skip to content

Commit a5788cf

Browse files
authored
add streamer refresh interval (#212)
1 parent bcbb811 commit a5788cf

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

tastytrade/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
BACKTEST_URL = "https://backtester.vast.tastyworks.com"
55
CERT_URL = "https://api.cert.tastyworks.com"
66
VAST_URL = "https://vast.tastyworks.com"
7-
VERSION = "9.8"
7+
VERSION = "9.9"
8+
9+
__version__ = VERSION
810

911
logger = logging.getLogger(__name__)
1012
logger.setLevel(logging.DEBUG)

tastytrade/streamer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ class DXLinkStreamer:
387387
def __init__(
388388
self,
389389
session: Session,
390+
refresh_interval: float = 0.1,
390391
reconnect_args: tuple[Any, ...] = (),
391392
reconnect_fn: Optional[Callable[..., Coroutine[Any, Any, None]]] = None,
392393
ssl_context: SSLContext = create_default_context(),
@@ -404,6 +405,9 @@ def __init__(
404405
"Underlying": 17,
405406
}
406407
self._subscription_state: dict[str, str] = defaultdict(lambda: "CHANNEL_CLOSED")
408+
#: Time in seconds between fetching new events from dxfeed. You can try a higher
409+
#: value if processing quote updates quickly is not a high priority.
410+
self.refresh_interval = refresh_interval
407411
#: An async function to be called upon reconnection. The first argument must be
408412
#: of type `DXLinkStreamer` and will be a reference to the streamer object.
409413
self.reconnect_fn = reconnect_fn
@@ -647,7 +651,7 @@ async def _channel_setup(self, event_type: str) -> None:
647651
message = {
648652
"type": "FEED_SETUP",
649653
"channel": self._channels[event_type],
650-
"acceptAggregationPeriod": 10,
654+
"acceptAggregationPeriod": self.refresh_interval,
651655
"acceptDataFormat": "COMPACT",
652656
}
653657

0 commit comments

Comments
 (0)