Skip to content
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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ pip install async_rithmic

👉 [See the official documentation for usage examples](https://async-rithmic.readthedocs.io/en/latest/)

## 🧠 Using it in Production

This library handles connectivity and streaming with Rithmic, but it does not solve higher-level concerns such as failure handling or ensuring correctness under load.

For a detailed discussion of how to build fault-tolerant async trading systems in practice:

👉 [Designing Fault-Tolerant Async Trading Services in Python](https://quant.engineering/designing-fault-tolerant-async-trading-services-python.html)


## 🧪 Testing

To execute the tests, use the following command: `make tests`
Expand Down
3 changes: 2 additions & 1 deletion async_rithmic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async def connect(self, **kwargs):
SysInfraType.TICKER_PLANT,
SysInfraType.PNL_PLANT
])
plant_connect_delay = kwargs.get("plant_connect_delay", 0.1)

try:
for plant in self.plants.values():
Expand All @@ -126,7 +127,7 @@ async def connect(self, **kwargs):

await plant._start_background_tasks()
await plant._login()
await asyncio.sleep(0.1)
await asyncio.sleep(plant_connect_delay)

except:
logger.exception("Failed to connect")
Expand Down
9 changes: 4 additions & 5 deletions async_rithmic/helpers/connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ async def _try_to_reconnect(plant, attempt):
settings = plant.client.reconnection_settings

while True:
wait_time = plant.client.reconnection_settings.get_delay(attempt)
plant.logger.info(f"Waiting {wait_time} seconds before the next reconnection attempt ...")
await asyncio.sleep(wait_time)

plant.logger.info(f"Reconnection attempt #{attempt}")

if settings.max_retries is not None and attempt > settings.max_retries:
Expand All @@ -64,8 +68,3 @@ async def _try_to_reconnect(plant, attempt):

attempt += 1

wait_time = plant.client.reconnection_settings.get_delay(attempt)
plant.logger.info(f"Waiting {wait_time} seconds before the next reconnection attempt ...")
await asyncio.sleep(wait_time)

return False
Loading