Skip to content
This repository was archived by the owner on Mar 9, 2022. It is now read-only.
Open
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
9 changes: 7 additions & 2 deletions pybit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1891,7 +1891,7 @@ def __init__(self, endpoint, api_key=None, api_secret=None,
subscriptions=None, logging_level=logging.INFO,
max_data_length=200, ping_interval=30, ping_timeout=10,
restart_on_error=True, purge_on_fetch=True,
trim_data=True):
trim_data=True, signature_window=1000):
"""
Initializes the websocket session.

Expand Down Expand Up @@ -1920,6 +1920,8 @@ def __init__(self, endpoint, api_key=None, api_secret=None,
length or only get the data since the last fetch?
:param trim_data: Decide whether the returning data should be
trimmed to only provide the data value.
:param signature_window: Timestamp window used for authentication
signature generation. Set in ms.

:returns: WebSocket session.
"""
Expand Down Expand Up @@ -2005,6 +2007,9 @@ def __init__(self, endpoint, api_key=None, api_secret=None,
self.api_key = api_key
self.api_secret = api_secret

# Set signature window
self.signature_window = signature_window

# Set topic subscriptions for WebSocket.
self.subscriptions = subscriptions
# Checking if using auth spot connection.
Expand Down Expand Up @@ -2080,7 +2085,7 @@ def _auth(self):
"""

# Generate expires.
expires = int((time.time() + 1) * 1000)
expires = int((time.time() + 1) * int(self.signature_window))

# Generate signature.
_val = f'GET/realtime{expires}'
Expand Down