Charting Server
Contents
Charting Server
The Charting Server processes time series queries on market data and publishes ongoing updates to clients. It performs calculations such as candlestick aggregation, technical indicators, and other analytical transformations over historical and real-time market data. By centralizing these computations, the server enables multiple clients to subscribe to identical chart data without redundant calculation overhead.
The Charting Server integrates with the Service Locator for authentication and service registration. Multiple Charting Servers can be deployed concurrently to distribute query processing load across instances with the Service Locator performing the load balancing among them.
Configuration
The Charting Server is configured via a YAML file that defines its network interface and Service Locator integration. Below is the structure of the configuration file with example values:
--- server: # Primary network interface and port the Charting Server binds to. interface: "0.0.0.0:21400" # List of addresses the server is reachable at (for registration with Service Locator). # Typically includes both public-facing and local addresses. addresses: ["198.51.100.5:21400", "10.0.0.5:21400"] service_locator: # The address of the Service Locator (host:port). address: "10.0.0.5:20000" # The account username used by the Charting Server to authenticate with the Service Locator. username: charting_service # The password for the Charting Server's Service Locator account. password: admin_password ...
Installation & Setup
A setup.py script is provided to generate the final config.yml from the config.default.yml template.
The script supports the following arguments:
python setup.py --local 0.0.0.0 # Local interface (default: auto-detected IP) --world 198.51.100.5 # Global/public interface (optional) --address 10.0.0.5:20000 # Service Locator address (default: local_interface:20000) --password [REQUIRED] # Service password for authentication
Operations
The Charting Server is controlled using three operational scripts: start.sh, stop.sh, and check.sh.
Log files are generated in the format:
srv_YYYYMMDD_HH_MM_SS.log
Upon startup, older log files are moved into the logs/ directory.
check.sh
The check.sh script verifies whether the server is currently running by inspecting the PID recorded in pid.lock and testing whether the associated process exists.
If the server is not running, it prints:
ChartingServer is not running.
start.sh
The start.sh script:
- Exits immediately if the server is already running
- Creates a
logs/directory if necessary - Moves any existing
srv_*.logfiles intologs/ - Starts the
ChartingServerprocess in the background - Writes the PID to
pid.lock - Reads network interfaces from
config.ymland waits until the server is listening on at least one configured address
This ensures the server is fully initialized before the script exits.
stop.sh
The stop.sh script:
- Reads the PID from
pid.lock - Sends
SIGINTto request a graceful shutdown - Waits for termination using exponential backoff (up to 300 seconds)
- Sends
SIGKILLif the server fails to stop cleanly - Appends a forced-termination message to the most recent log file (if applicable)
- Removes the
pid.lockfile
This guarantees consistent shutdown behavior across normal and exceptional conditions.
