Code Examples
General client template
The minimal structure every Quantstrip client follows. This is the smallest working client in the codebase.
"""
Minimal example of a client implementation. This client will log a message every second.
"""
from quantstrip import ClientBase
import logging
logger = logging.getLogger(__name__)
class Client(ClientBase):
""" A minimal client """
def __init__(self, *args):
super().__init__()
self.display_name = "Default Client"
self.scheduler.every(1).seconds.do(self.job)
def job(self):
logger.info(f"Hello from {self.display_name}")
What's actually happening
| Line | Purpose |
|---|---|
class Client(ClientBase) | Every client is a subclass named
Client. This is the class the dashboard loads and instantiates. |
super().__init__() | Sets up lifecycle state — scheduler, heartbeat tracking, resource monitoring. Always call this first. |
self.scheduler.every(1).seconds.do(self.job) | Registers a job on
the schedule library scheduler owned by ClientBase. Strategy
logic is implemented in the scheduled job. |
logging.getLogger(__name__) | Standard library logging; no dedicated Quantstrip logging class. Output is written to the files the Logging page reads. |
Database, broker, and email access are optional and follow the same pattern: import from
quantstrip or a broker module, and call from inside a scheduled job. See
IBKR template for a client that places orders and records
executions.
Deploying it
Drop a file like this in Data\clients\ (or edit it through the
Python Editor, which enforces a
working-copy-then-deploy workflow), and the service picks it up and shows it on
Client Monitor once loaded.