Skip to content
Draft
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
3 changes: 3 additions & 0 deletions async_rithmic/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ class RithmicErrorResponse(Exception):
class InvalidRequestError(Exception):
"""Raised when a user-level API call is missing required arguments or is malformed."""
pass

class HistoricalDataRequestInProgressError(RuntimeError):
pass
2 changes: 1 addition & 1 deletion async_rithmic/helpers/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from contextlib import asynccontextmanager

@asynccontextmanager
async def try_acquire_lock(plant, timeout: float = 5.0, context: str = ""):
async def try_acquire_lock(plant, timeout: float = 10.0, context: str = ""):
"""
Attempts to acquire an asyncio.Lock with timeout.
Logs and raises on timeout to help detect deadlocks.
Expand Down
17 changes: 14 additions & 3 deletions async_rithmic/plants/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,12 @@ async def _process_response(self, response):
# - pnl subscription responses
return True

if response.template_id in [203, 207]:
# Let plant handle:
# - historical time bars
# - historical tick bars
return False

if response.template_id == 77:
# Forced logout
self.logger.warning("Received a ForcedLogout message from Rithmic - did you reach the maximum number of concurrent sessions ?")
Expand All @@ -555,11 +561,16 @@ async def _process_response(self, response):
raise RithmicErrorResponse(f"Rithmic returned an error={MessageToDict(response)} for the request={request}")

else:
if response.template_id in [11, 15, 114, 301]:
# We expect a single response containing `rp_code` for these endpoints
# single-response endpoints that carries data along with the terminal sentinel
# 11: login response
# 15: reference data response
# 114: front month contract response
# 301: login info response
_terminal_carries_data = {11, 15, 114, 301}

if response.template_id in _terminal_carries_data:
self.request_manager.handle_response(response)

# Else: multiple response + a sentinel message with `rp_code`
self.request_manager.mark_complete(request_id)
else:
self.request_manager.handle_response(response)
Expand Down
Loading
Loading