Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add streamer refresh interval #212

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading