<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.spiretrading.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kamal</id>
	<title>Spire Trading Inc. - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.spiretrading.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kamal"/>
	<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php/Special:Contributions/Kamal"/>
	<updated>2026-04-07T11:08:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Server_Overview&amp;diff=246</id>
		<title>Server Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Server_Overview&amp;diff=246"/>
		<updated>2025-12-01T22:40:08Z</updated>

		<summary type="html">&lt;p&gt;Kamal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Server Overview =&lt;br /&gt;
Spire is a distributed trading platform composed of multiple specialized servers that work together to provide a complete trading infrastructure. Each server is independently deployable, communicates through well-defined service interfaces, and authenticates through a central Service Locator.&lt;br /&gt;
== Architecture Principles ==&lt;br /&gt;
&lt;br /&gt;
'''Service-Oriented Design''' - Each server provides a focused set of functionality&lt;br /&gt;
&lt;br /&gt;
'''Distributed Deployment''' - Services can be deployed across multiple machines for scalability&lt;br /&gt;
&lt;br /&gt;
'''Centralized Authentication''' - All services authenticate through the Service Locator&lt;br /&gt;
&lt;br /&gt;
'''Persistent Storage''' - Critical data persisted to MySQL for durability&lt;br /&gt;
&lt;br /&gt;
'''Real-time Updates''' - Services publish updates to subscribed clients&lt;br /&gt;
&lt;br /&gt;
== Service Categories ==&lt;br /&gt;
=== Infrastructure Services ===&lt;br /&gt;
&lt;br /&gt;
'''[[Service Locator]]''' - Centralized authentication, account management, and service discovery&lt;br /&gt;
&lt;br /&gt;
'''[[Uid Server]]''' - Generates unique identifiers for orders and other entities&lt;br /&gt;
&lt;br /&gt;
=== Account &amp;amp; Administration ===&lt;br /&gt;
&lt;br /&gt;
'''[[Administration Server]]''' - Manages account roles, entitlements, risk parameters, and trading permissions&lt;br /&gt;
&lt;br /&gt;
'''[[Web Portal]]''' - Web-based interface for account management and administrative tasks&lt;br /&gt;
&lt;br /&gt;
=== Market Data ===&lt;br /&gt;
&lt;br /&gt;
'''[[Definitions Server]]''' - Provides reference data (countries, currencies, venues, trading schedules)&lt;br /&gt;
&lt;br /&gt;
'''[[Market Data Server]]''' - Receives, sequences, and persists market data from feed clients&lt;br /&gt;
&lt;br /&gt;
'''[[Market Data Relay Server]]''' - Load-balanced distribution of market data to end users&lt;br /&gt;
&lt;br /&gt;
'''[[Charting Server]]''' - Processes time series queries for candlestick and technical analysis data&lt;br /&gt;
&lt;br /&gt;
=== Trading Controls ===&lt;br /&gt;
&lt;br /&gt;
'''[[Compliance Server]]''' - Manages compliance rules and monitors violations&lt;br /&gt;
&lt;br /&gt;
'''[[Risk Server]]''' - Monitors profit/loss, enforces risk limits, manages account state transitions&lt;br /&gt;
&lt;br /&gt;
'''[[Order Execution Server]]''' - Routes orders to venues, tracks execution, enforces controls&lt;br /&gt;
&lt;br /&gt;
== Common Operational Patterns ==&lt;br /&gt;
All servers follow consistent operational patterns:&lt;br /&gt;
&lt;br /&gt;
Configuration via YAML files&lt;br /&gt;
&lt;br /&gt;
Setup scripts for generating configurations&lt;br /&gt;
&lt;br /&gt;
Standard start/stop/check scripts&lt;br /&gt;
&lt;br /&gt;
Timestamped log files in logs/ directory&lt;br /&gt;
&lt;br /&gt;
PID-based process management&lt;br /&gt;
&lt;br /&gt;
== System-Wide Management ==&lt;br /&gt;
In addition to individual server management scripts, the platform provides aggregate scripts for managing all servers collectively.&lt;br /&gt;
&lt;br /&gt;
=== install.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;install.sh&amp;lt;/code&amp;gt; script is designed for the latest Ubuntu Server LTS and performs a complete system installation including:&lt;br /&gt;
* Installing system dependencies (build tools, MySQL, Node.js, Python packages)&lt;br /&gt;
* Building all server applications&lt;br /&gt;
* Configuring MySQL database and creating the spire schema&lt;br /&gt;
* Creating service accounts in the Service Locator&lt;br /&gt;
* Setting up initial permissions and directory structure&lt;br /&gt;
* Configuring all servers with appropriate network settings&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./install.sh -p [password] [options]&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
  -p    Password for Spire services&lt;br /&gt;
&lt;br /&gt;
Optional:&lt;br /&gt;
  -u    MySQL username (default: spireadmin)&lt;br /&gt;
  -m    MySQL password (default: same as -p)&lt;br /&gt;
  -i    Global network interface (default: auto-detected)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation script automatically creates service accounts for all servers and assigns them to the appropriate permission groups.&lt;br /&gt;
&lt;br /&gt;
=== setup.py ===&lt;br /&gt;
The &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script configures all servers by propagating common settings across individual server configurations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py [options]&lt;br /&gt;
&lt;br /&gt;
Optional:&lt;br /&gt;
  --local            Local network interface&lt;br /&gt;
  --world            Global/public network interface&lt;br /&gt;
  --address          Service Locator address&lt;br /&gt;
  --password         Service account password&lt;br /&gt;
  --mysql_address    MySQL server address&lt;br /&gt;
  --mysql_username   MySQL username&lt;br /&gt;
  --mysql_password   MySQL password&lt;br /&gt;
  --mysql_schema     MySQL schema name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script calls each server's individual setup script with appropriate parameters, ensuring consistent configuration across the platform.&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script starts all servers in dependency order:&lt;br /&gt;
&lt;br /&gt;
# Service Locator&lt;br /&gt;
# Uid Server&lt;br /&gt;
# Definitions Server&lt;br /&gt;
# Administration Server&lt;br /&gt;
# Market Data Server&lt;br /&gt;
# Market Data Relay Server&lt;br /&gt;
# Charting Server&lt;br /&gt;
# Compliance Server&lt;br /&gt;
# Order Execution Server&lt;br /&gt;
# Risk Server&lt;br /&gt;
# Web Portal&lt;br /&gt;
# Market Data Feed Client&lt;br /&gt;
&lt;br /&gt;
After starting all servers, the script automatically runs &amp;lt;code&amp;gt;reset_risk_states.py&amp;lt;/code&amp;gt; to initialize risk state for the trading session.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script gracefully stops all servers in reverse dependency order, ensuring that dependent services shut down before the services they depend on.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies that all servers are running and reports the status of each service. It exits with a non-zero status if any server is not running, making it suitable for monitoring and health check automation.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Server_Overview&amp;diff=245</id>
		<title>Server Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Server_Overview&amp;diff=245"/>
		<updated>2025-12-01T22:39:52Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Server Overview = Spire is a distributed trading platform composed of multiple specialized servers that work together to provide a complete trading infrastructure. Each serv...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Server Overview =&lt;br /&gt;
Spire is a distributed trading platform composed of multiple specialized servers that work together to provide a complete trading infrastructure. Each server is independently deployable, communicates through well-defined service interfaces, and authenticates through a central Service Locator.&lt;br /&gt;
== Architecture Principles ==&lt;br /&gt;
&lt;br /&gt;
'''Service-Oriented Design''' - Each server provides a focused set of functionality&lt;br /&gt;
&lt;br /&gt;
'''Distributed Deployment''' - Services can be deployed across multiple machines for scalability&lt;br /&gt;
&lt;br /&gt;
'''Centralized Authentication''' - All services authenticate through the Service Locator&lt;br /&gt;
&lt;br /&gt;
'''Persistent Storage''' - Critical data persisted to MySQL for durability&lt;br /&gt;
&lt;br /&gt;
'''Real-time Updates''' - Services publish updates to subscribed clients&lt;br /&gt;
&lt;br /&gt;
== Service Categories ==&lt;br /&gt;
=== Infrastructure Services ===&lt;br /&gt;
&lt;br /&gt;
'''[[Service Locator]]''' - Centralized authentication, account management, and service discovery&lt;br /&gt;
&lt;br /&gt;
'''[[Uid Server]]''' - Generates unique identifiers for orders and other entities&lt;br /&gt;
&lt;br /&gt;
=== Account &amp;amp; Administration ===&lt;br /&gt;
&lt;br /&gt;
'''[[Administration Server]]''' - Manages account roles, entitlements, risk parameters, and trading permissions&lt;br /&gt;
&lt;br /&gt;
'''[[Web Portal]]''' - Web-based interface for account management and administrative tasks&lt;br /&gt;
&lt;br /&gt;
=== Market Data ===&lt;br /&gt;
&lt;br /&gt;
'''[[Definitions Server]]''' - Provides reference data (countries, currencies, venues, trading schedules)&lt;br /&gt;
&lt;br /&gt;
'''[[Market Data Server]]''' - Receives, sequences, and persists market data from feed clients&lt;br /&gt;
&lt;br /&gt;
'''[[Market Data Relay Server]]''' - Load-balanced distribution of market data to end users&lt;br /&gt;
&lt;br /&gt;
'''[[Charting Server]]''' - Processes time series queries for candlestick and technical analysis data&lt;br /&gt;
&lt;br /&gt;
=== Trading Controls ===&lt;br /&gt;
&lt;br /&gt;
'''[[Compliance Server]]''' - Manages compliance rules and monitors violations&lt;br /&gt;
&lt;br /&gt;
'''[[Risk Server]]''' - Monitors profit/loss, enforces risk limits, manages account state transitions&lt;br /&gt;
&lt;br /&gt;
'''[[Order Execution Server]]''' - Routes orders to venues, tracks execution, enforces controls&lt;br /&gt;
&lt;br /&gt;
== Common Operational Patterns ==&lt;br /&gt;
All servers follow consistent operational patterns:&lt;br /&gt;
&lt;br /&gt;
Configuration via YAML files&lt;br /&gt;
&lt;br /&gt;
Setup scripts for generating configurations&lt;br /&gt;
&lt;br /&gt;
Standard start/stop/check scripts&lt;br /&gt;
&lt;br /&gt;
Timestamped log files in logs/ directory&lt;br /&gt;
&lt;br /&gt;
PID-based process management&lt;br /&gt;
&lt;br /&gt;
== System-Wide Management ==&lt;br /&gt;
In addition to individual server management scripts, the platform provides aggregate scripts for managing all servers collectively.&lt;br /&gt;
&lt;br /&gt;
=== install.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;install.sh&amp;lt;/code&amp;gt; script is designed for Ubuntu Server LTS and performs a complete system installation including:&lt;br /&gt;
* Installing system dependencies (build tools, MySQL, Node.js, Python packages)&lt;br /&gt;
* Building all server applications&lt;br /&gt;
* Configuring MySQL database and creating the spire schema&lt;br /&gt;
* Creating service accounts in the Service Locator&lt;br /&gt;
* Setting up initial permissions and directory structure&lt;br /&gt;
* Configuring all servers with appropriate network settings&lt;br /&gt;
&lt;br /&gt;
Usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
./install.sh -p [password] [options]&lt;br /&gt;
&lt;br /&gt;
Required:&lt;br /&gt;
  -p    Password for Spire services&lt;br /&gt;
&lt;br /&gt;
Optional:&lt;br /&gt;
  -u    MySQL username (default: spireadmin)&lt;br /&gt;
  -m    MySQL password (default: same as -p)&lt;br /&gt;
  -i    Global network interface (default: auto-detected)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The installation script automatically creates service accounts for all servers and assigns them to the appropriate permission groups.&lt;br /&gt;
&lt;br /&gt;
=== setup.py ===&lt;br /&gt;
The &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script configures all servers by propagating common settings across individual server configurations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py [options]&lt;br /&gt;
&lt;br /&gt;
Optional:&lt;br /&gt;
  --local            Local network interface&lt;br /&gt;
  --world            Global/public network interface&lt;br /&gt;
  --address          Service Locator address&lt;br /&gt;
  --password         Service account password&lt;br /&gt;
  --mysql_address    MySQL server address&lt;br /&gt;
  --mysql_username   MySQL username&lt;br /&gt;
  --mysql_password   MySQL password&lt;br /&gt;
  --mysql_schema     MySQL schema name&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script calls each server's individual setup script with appropriate parameters, ensuring consistent configuration across the platform.&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script starts all servers in dependency order:&lt;br /&gt;
&lt;br /&gt;
# Service Locator&lt;br /&gt;
# Uid Server&lt;br /&gt;
# Definitions Server&lt;br /&gt;
# Administration Server&lt;br /&gt;
# Market Data Server&lt;br /&gt;
# Market Data Relay Server&lt;br /&gt;
# Charting Server&lt;br /&gt;
# Compliance Server&lt;br /&gt;
# Order Execution Server&lt;br /&gt;
# Risk Server&lt;br /&gt;
# Web Portal&lt;br /&gt;
# Market Data Feed Client&lt;br /&gt;
&lt;br /&gt;
After starting all servers, the script automatically runs &amp;lt;code&amp;gt;reset_risk_states.py&amp;lt;/code&amp;gt; to initialize risk state for the trading session.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script gracefully stops all servers in reverse dependency order, ensuring that dependent services shut down before the services they depend on.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies that all servers are running and reports the status of each service. It exits with a non-zero status if any server is not running, making it suitable for monitoring and health check automation.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Web_Portal&amp;diff=244</id>
		<title>Web Portal</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Web_Portal&amp;diff=244"/>
		<updated>2025-12-01T22:30:25Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Web Portal = The Web Portal provides web-based access to account management and administrative functions through both an web API and an interactive HTML interface. It serves...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Web Portal =&lt;br /&gt;
The Web Portal provides web-based access to account management and administrative functions through both an web API and an interactive HTML interface. It serves as the primary user interface for creating and managing trading accounts, configuring market data entitlements, defining compliance rules, setting risk parameters, and monitoring account activity. By aggregating functionality from multiple backend services, the Web Portal enables administrators and managers to perform operational tasks through a unified web application.&lt;br /&gt;
&lt;br /&gt;
The Web Portal integrates with the Service Locator for authentication and communicates with the Administration Server, Compliance Server, Risk Server, and Order Execution Server to provide comprehensive account management capabilities.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Web Portal 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:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Web Portal binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:8080&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:8080&amp;quot;, &amp;quot;10.0.0.5:8080&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Web Portal to authenticate with the Service Locator.&lt;br /&gt;
  username: web_portal_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Web Portal's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
The Web Portal provides access to the following administrative and operational capabilities:&lt;br /&gt;
&lt;br /&gt;
=== Account Management ===&lt;br /&gt;
* Create new trading accounts&lt;br /&gt;
* Assign accounts to groups and directories&lt;br /&gt;
* Configure account permissions and access controls&lt;br /&gt;
* Set account roles (trader, manager, administrator, service)&lt;br /&gt;
* Modify account credentials and settings&lt;br /&gt;
&lt;br /&gt;
=== Market Data Entitlements ===&lt;br /&gt;
* View available market data packages and pricing&lt;br /&gt;
* Assign entitlements to accounts or groups&lt;br /&gt;
* Configure per-venue and per-message-type permissions&lt;br /&gt;
&lt;br /&gt;
=== Compliance Configuration ===&lt;br /&gt;
* Define compliance rules and rule schemas&lt;br /&gt;
* Assign rules to accounts, groups, or directories&lt;br /&gt;
* Configure rule states (active, passive, disabled)&lt;br /&gt;
* Monitor compliance rule violations&lt;br /&gt;
* Review historical compliance events&lt;br /&gt;
&lt;br /&gt;
=== Risk Management ===&lt;br /&gt;
* Configure risk parameters per account&lt;br /&gt;
* Set buying power limits&lt;br /&gt;
* Define net loss thresholds&lt;br /&gt;
* Configure risk state transitions&lt;br /&gt;
* Monitor real-time profit and loss&lt;br /&gt;
* View position summaries and inventory snapshots&lt;br /&gt;
&lt;br /&gt;
=== Order and Execution Monitoring ===&lt;br /&gt;
* View order history and execution reports&lt;br /&gt;
* Monitor active orders&lt;br /&gt;
* Review trade activity by account or region&lt;br /&gt;
* Generate reports on trading performance&lt;br /&gt;
* Track order routing and fill statistics&lt;br /&gt;
&lt;br /&gt;
=== Administrative Tools ===&lt;br /&gt;
* User session management&lt;br /&gt;
* System configuration and settings&lt;br /&gt;
* Audit logs and activity tracking&lt;br /&gt;
* Service health monitoring&lt;br /&gt;
* Operational reports and analytics&lt;br /&gt;
&lt;br /&gt;
== Access Control ==&lt;br /&gt;
The Web Portal enforces permissions based on account roles:&lt;br /&gt;
&lt;br /&gt;
* '''Administrators''' have full access to all management functions&lt;br /&gt;
* '''Managers''' can manage accounts within their assigned groups&lt;br /&gt;
* '''Traders''' can view their own account details and activity&lt;br /&gt;
* '''Service''' accounts have restricted programmatic access&lt;br /&gt;
&lt;br /&gt;
All operations are authenticated through the Service Locator and logged for audit purposes.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Web Portal is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
WebPortal is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;WebPortal&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Order_Execution_Server&amp;diff=243</id>
		<title>Order Execution Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Order_Execution_Server&amp;diff=243"/>
		<updated>2025-12-01T22:25:42Z</updated>

		<summary type="html">&lt;p&gt;Kamal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Order Execution Server =&lt;br /&gt;
The Order Execution Server receives order submissions from clients, routes them to appropriate execution venues or brokers, and tracks the lifecycle of each order from submission through completion. It publishes execution reports to subscribed clients, enforces compliance rules and risk parameters, and maintains a persistent record of all order activity. By centralizing order routing and monitoring, the server ensures consistent application of trading controls while providing real-time visibility into order status across the system.&lt;br /&gt;
&lt;br /&gt;
The Order Execution Server integrates with the Service Locator for authentication, the Compliance Server for rule validation, the Risk Server for position and loss monitoring, and a MySQL database to persist order records and execution reports.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Order Execution Server is configured via a YAML file that defines network interfaces, database connection, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Order Execution Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20700&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20700&amp;quot;, &amp;quot;10.0.0.5:20700&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Order Execution Server to authenticate with the Service Locator.&lt;br /&gt;
  username: order_execution_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Order Execution Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
&lt;br /&gt;
=== Order Routing ===&lt;br /&gt;
The server routes orders to their specified destinations based on:&lt;br /&gt;
&lt;br /&gt;
* Destination configuration (venue, broker, or internal order type like MOE)&lt;br /&gt;
* Account permissions and entitlements&lt;br /&gt;
* Compliance rule validation&lt;br /&gt;
* Risk parameter enforcement&lt;br /&gt;
&lt;br /&gt;
Orders that violate compliance rules or risk limits are rejected before routing.&lt;br /&gt;
&lt;br /&gt;
=== Order Monitoring ===&lt;br /&gt;
Clients can subscribe to receive execution reports for:&lt;br /&gt;
&lt;br /&gt;
* Orders submitted by a specific account&lt;br /&gt;
* Individual orders by order ID&lt;br /&gt;
&lt;br /&gt;
Subscriptions enable real-time tracking of order activity across portfolios or trading desks.&lt;br /&gt;
&lt;br /&gt;
=== Compliance and Risk Enforcement ===&lt;br /&gt;
Before accepting an order, the server validates:&lt;br /&gt;
&lt;br /&gt;
* Compliance rules defined for the account or group&lt;br /&gt;
* Risk parameters including buying power and loss limits&lt;br /&gt;
* Account state (active, closed orders, disabled)&lt;br /&gt;
* Trading permissions and entitlements&lt;br /&gt;
&lt;br /&gt;
Orders that fail validation are immediately rejected with an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
=== Order Cancellation ===&lt;br /&gt;
Clients can request order cancellation. The server:&lt;br /&gt;
&lt;br /&gt;
# Validates cancel permission&lt;br /&gt;
# Routes cancel request to the destination&lt;br /&gt;
# Updates order state based on destination response&lt;br /&gt;
# Publishes final execution report&lt;br /&gt;
&lt;br /&gt;
== Utility Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== cancel_order.py ===&lt;br /&gt;
A utility for bulk order cancellation supporting multiple use cases:&lt;br /&gt;
&lt;br /&gt;
'''Cancel by order ID:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --order 12345&lt;br /&gt;
  --message &amp;quot;Manual cancellation&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Cancel by account and region:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --account trader1&lt;br /&gt;
  --region CA                      # Country code, venue, or security&lt;br /&gt;
  --begin &amp;quot;2024-01-01&amp;quot;&lt;br /&gt;
  --end &amp;quot;2024-12-31&amp;quot;&lt;br /&gt;
  --message &amp;quot;End of day cancel&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Cancel by region (all accounts):'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --region XTSE                    # Venue code&lt;br /&gt;
  --begin &amp;quot;2024-01-01&amp;quot;&lt;br /&gt;
  --end &amp;quot;2024-12-31&amp;quot;&lt;br /&gt;
  --connections 8                  # Parallel connections for performance&lt;br /&gt;
  --message &amp;quot;Market close&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script supports parallel processing using multiple service connections to efficiently cancel large numbers of orders.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
  --mysql_address 127.0.0.1:3306  # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin     # MySQL username&lt;br /&gt;
  --mysql_password secretpw       # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire            # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Order Execution Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
OrderExecutionServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;OrderExecutionServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Order_Execution_Server&amp;diff=242</id>
		<title>Order Execution Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Order_Execution_Server&amp;diff=242"/>
		<updated>2025-12-01T22:25:16Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Order Execution Server = The Order Execution Server receives order submissions from clients, routes them to appropriate execution venues or brokers, and tracks the lifecycle...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Order Execution Server =&lt;br /&gt;
The Order Execution Server receives order submissions from clients, routes them to appropriate execution venues or brokers, and tracks the lifecycle of each order from submission through completion. It publishes execution reports to subscribed clients, enforces compliance rules and risk parameters, and maintains a persistent record of all order activity. By centralizing order routing and monitoring, the server ensures consistent application of trading controls while providing real-time visibility into order status across the system.&lt;br /&gt;
&lt;br /&gt;
The Order Execution Server integrates with the Service Locator for authentication, the Compliance Server for rule validation, the Risk Server for position and loss monitoring, and a MySQL database to persist order records and execution reports.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Order Execution Server is configured via a YAML file that defines network interfaces, database connection, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Order Execution Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20700&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20700&amp;quot;, &amp;quot;10.0.0.5:20700&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Order Execution Server to authenticate with the Service Locator.&lt;br /&gt;
  username: order_execution_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Order Execution Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
&lt;br /&gt;
=== Order Routing ===&lt;br /&gt;
The server routes orders to their specified destinations based on:&lt;br /&gt;
&lt;br /&gt;
* Destination configuration (venue, broker, or internal order type like MOE)&lt;br /&gt;
* Account permissions and entitlements&lt;br /&gt;
* Compliance rule validation&lt;br /&gt;
* Risk parameter enforcement&lt;br /&gt;
&lt;br /&gt;
Orders that violate compliance rules or risk limits are rejected before routing.&lt;br /&gt;
&lt;br /&gt;
=== Order Monitoring ===&lt;br /&gt;
Clients can subscribe to receive execution reports for:&lt;br /&gt;
&lt;br /&gt;
* Orders submitted by a specific account&lt;br /&gt;
* Individual orders by order ID&lt;br /&gt;
&lt;br /&gt;
Subscriptions enable real-time tracking of order activity across portfolios or trading desks.&lt;br /&gt;
&lt;br /&gt;
=== Compliance and Risk Enforcement ===&lt;br /&gt;
Before accepting an order, the server validates:&lt;br /&gt;
&lt;br /&gt;
* Compliance rules defined for the account or group&lt;br /&gt;
* Risk parameters including buying power and loss limits&lt;br /&gt;
* Account state (active, closed orders, disabled)&lt;br /&gt;
* Trading permissions and entitlements&lt;br /&gt;
&lt;br /&gt;
Orders that fail validation are immediately rejected with an appropriate error message.&lt;br /&gt;
&lt;br /&gt;
=== Order Cancellation ===&lt;br /&gt;
Clients can request order cancellation. The server:&lt;br /&gt;
&lt;br /&gt;
# Validates cancel permission&lt;br /&gt;
# Routes cancel request to the destination&lt;br /&gt;
# Updates order state based on destination response&lt;br /&gt;
# Publishes final execution report&lt;br /&gt;
&lt;br /&gt;
== Utility Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== cancel_order.py ===&lt;br /&gt;
A utility for bulk order cancellation supporting multiple use cases:&lt;br /&gt;
&lt;br /&gt;
'''Cancel by order ID:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --order 12345&lt;br /&gt;
  --message &amp;quot;Manual cancellation&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Cancel by account and region:'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --account trader1&lt;br /&gt;
  --region CA                      # Country code, venue, or security&lt;br /&gt;
  --begin &amp;quot;2024-01-01&amp;quot;&lt;br /&gt;
  --end &amp;quot;2024-12-31&amp;quot;&lt;br /&gt;
  --message &amp;quot;End of day cancel&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Cancel by region (all accounts):'''&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python cancel_order.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --region XTSE                    # Venue code&lt;br /&gt;
  --begin &amp;quot;2024-01-01&amp;quot;&lt;br /&gt;
  --end &amp;quot;2024-12-31&amp;quot;&lt;br /&gt;
  --connections 8                  # Parallel connections for performance&lt;br /&gt;
  --message &amp;quot;Market close&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script supports parallel processing using multiple service connections to efficiently cancel large numbers of orders.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
  --mysql_address 127.0.0.1:3306  # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin     # MySQL username&lt;br /&gt;
  --mysql_password secretpw       # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire            # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Order Execution Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
SimulationOrderExecutionServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;SimulationOrderExecutionServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Risk_Server&amp;diff=241</id>
		<title>Risk Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Risk_Server&amp;diff=241"/>
		<updated>2025-12-01T22:18:57Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Risk Server = The Risk Server monitors account profit and loss, enforces risk limits, and manages account state transitions based on trading activity. It tracks each account...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Risk Server =&lt;br /&gt;
The Risk Server monitors account profit and loss, enforces risk limits, and manages account state transitions based on trading activity. It tracks each account's net position, buying power consumption, and realized/unrealized profit and loss. When an account exceeds its configured loss threshold, the server automatically transitions the account through risk states—from active trading to closed orders mode, and ultimately to disabled or liquidation if losses continue. By centralizing risk monitoring and enforcement, the server protects both individual accounts and the overall system from excessive exposure.&lt;br /&gt;
&lt;br /&gt;
The Risk Server integrates with the Service Locator for authentication, the Order Execution service to monitor trades, and a MySQL database to persist risk parameters and inventory snapshots.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Risk Server is configured via a YAML file that defines network interfaces, database connection, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Risk Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20600&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20600&amp;quot;, &amp;quot;10.0.0.5:20600&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Risk Server to authenticate with the Service Locator.&lt;br /&gt;
  username: risk_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Risk Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk Parameters ==&lt;br /&gt;
Each account is assigned risk parameters that govern its trading limits and risk enforcement behavior:&lt;br /&gt;
&lt;br /&gt;
* '''Currency''' - The currency used for risk calculations and loss limits&lt;br /&gt;
* '''Buying Power''' - Maximum amount of capital available for trading&lt;br /&gt;
* '''Allowed State''' - The risk state the account is permitted to operate in&lt;br /&gt;
* '''Net Loss Threshold''' - Maximum net loss before transitioning to closed orders mode&lt;br /&gt;
* '''Transition Time''' - Duration allowed in closed orders mode before automatic liquidation&lt;br /&gt;
&lt;br /&gt;
=== Risk States ===&lt;br /&gt;
Accounts progress through the following risk states based on their profit and loss:&lt;br /&gt;
&lt;br /&gt;
* '''Active''' - Normal trading with full permissions&lt;br /&gt;
* '''Closed Orders''' - No new orders allowed; existing positions may be reduced&lt;br /&gt;
* '''Disabled''' - Trading prohibited; positions must be manually managed&lt;br /&gt;
* '''Liquidation''' - Account positions are automatically liquidated&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
&lt;br /&gt;
=== Real-Time Risk Monitoring ===&lt;br /&gt;
The Risk Server continuously tracks:&lt;br /&gt;
&lt;br /&gt;
* Net position by security and currency&lt;br /&gt;
* Realized and unrealized profit and loss&lt;br /&gt;
* Buying power consumption&lt;br /&gt;
* Order and execution activity&lt;br /&gt;
&lt;br /&gt;
When an account's net loss exceeds its configured threshold, the server automatically transitions the account to closed orders mode and starts a timer. If the account does not return to profitability within the transition time, the server escalates to disabled or liquidation state.&lt;br /&gt;
&lt;br /&gt;
=== Inventory Management ===&lt;br /&gt;
The server maintains real-time inventory snapshots for each account, tracking:&lt;br /&gt;
&lt;br /&gt;
* Open positions by security&lt;br /&gt;
* Average cost basis&lt;br /&gt;
* Current market value&lt;br /&gt;
* Unrealized profit and loss&lt;br /&gt;
&lt;br /&gt;
Inventory updates occur on every execution report, ensuring accurate position tracking across all trading venues.&lt;br /&gt;
&lt;br /&gt;
=== Regional Risk Control ===&lt;br /&gt;
Risk parameters and state transitions can be scoped by region (country, venue, or security). This enables fine-grained control over risk exposure in specific markets or asset classes.&lt;br /&gt;
&lt;br /&gt;
== Utility Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== positions.py ===&lt;br /&gt;
Reports current positions for accounts in CSV format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python positions.py&lt;br /&gt;
  --config config.yml       # Configuration file&lt;br /&gt;
  --account trader1         # Specific account (optional; reports all if omitted)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Output format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Account,Security,Currency,Side,Open Quantity,Cost Basis&lt;br /&gt;
trader1,AAPL.NASDAQ,USD,Long,100,15000.00&lt;br /&gt;
trader1,TSLA.NASDAQ,USD,Short,50,12500.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== moe.py ===&lt;br /&gt;
Manual Order Entry (MOE) utility for opening or closing positions without market execution. These orders are synthetic and do not interact with external venues:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python moe.py&lt;br /&gt;
  --config config.yml           # Configuration file&lt;br /&gt;
  --positions positions.csv     # CSV file with positions to MOE&lt;br /&gt;
  --account trader1             # Specific account (optional)&lt;br /&gt;
  --region CA                   # Region filter (country/venue/security)&lt;br /&gt;
  --open                        # Open positions&lt;br /&gt;
  --close                       # Close positions&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The positions CSV file must have the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Account,Security,Currency,Side,Open Quantity,Cost Basis&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use cases:&lt;br /&gt;
* Opening initial positions for testing&lt;br /&gt;
* Closing positions during liquidation&lt;br /&gt;
* Adjusting positions after system recovery&lt;br /&gt;
&lt;br /&gt;
=== reset.py ===&lt;br /&gt;
Resets risk state for a specific region, clearing accumulated profit/loss tracking:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python reset.py&lt;br /&gt;
  --config config.yml       # Configuration file&lt;br /&gt;
  --region CA               # Region to reset (country code, venue, or security)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This utility is typically used at the start of a trading day or after maintenance periods to reset risk calculations.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
  --mysql_address 127.0.0.1:3306  # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin     # MySQL username&lt;br /&gt;
  --mysql_password secretpw       # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire            # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Risk Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
RiskServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;RiskServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Market_Data_Relay_Server&amp;diff=240</id>
		<title>Market Data Relay Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Market_Data_Relay_Server&amp;diff=240"/>
		<updated>2025-12-01T22:13:09Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Market Data Relay Server = The Market Data Relay Server provides load-balanced distribution of market data to end users. It acts as an intermediary layer between the Market...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Market Data Relay Server =&lt;br /&gt;
The Market Data Relay Server provides load-balanced distribution of market data to end users. It acts as an intermediary layer between the Market Data Server and client applications, receiving market data updates from the Market Data Server and relaying them to subscribed clients. By deploying multiple relay servers in parallel, the system can distribute client connections across instances, ensuring scalable and resilient market data delivery.&lt;br /&gt;
&lt;br /&gt;
The Market Data Relay Server integrates with the Service Locator for authentication and service registration. Multiple relay servers can operate concurrently to distribute load across the infrastructure.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Market Data Relay 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:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Market Data Relay Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:22300&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:22300&amp;quot;, &amp;quot;10.0.0.5:22300&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Market Data Relay Server to authenticate with the Service Locator.&lt;br /&gt;
  username: market_data_relay_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Market Data Relay Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Architecture ==&lt;br /&gt;
The market data distribution architecture consists of three tiers:&lt;br /&gt;
&lt;br /&gt;
# '''Feed Clients''' publish raw market data to the Market Data Server&lt;br /&gt;
# '''Market Data Server''' organizes, sequences, and persists market data&lt;br /&gt;
# '''Market Data Relay Servers''' distribute market data to end-user clients&lt;br /&gt;
&lt;br /&gt;
This architecture separates data processing from distribution, allowing the Market Data Server to focus on sequencing and storage while relay servers handle the potentially large number of client connections. Multiple relay servers can be deployed to distribute client load geographically or by capacity requirements.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Market Data Relay Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
MarketDataRelayServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;MarketDataRelayServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Market_Data_Server&amp;diff=239</id>
		<title>Market Data Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Market_Data_Server&amp;diff=239"/>
		<updated>2025-12-01T22:09:49Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Market Data Server = The Market Data Server receives market data from feed clients, organizes and persists the data, and provides query and subscription services to clients....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Market Data Server =&lt;br /&gt;
The Market Data Server receives market data from feed clients, organizes and persists the data, and provides query and subscription services to clients. It maintains real-time market data snapshots for each security, tracks security technicals (open, high, low, close, volume), and sequences all market data updates to ensure consistent ordering across the system. The server supports multiple market data types including best bid/offer quotes, book quotes, time and sales, and order imbalances.&lt;br /&gt;
&lt;br /&gt;
The Market Data Server integrates with the Service Locator for authentication and a MySQL database for historical data storage. It operates as two distinct services: a registry server for managing security metadata and subscriptions, and a feed server for receiving and distributing market data updates.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Market Data Server is configured via a YAML file that defines network interfaces for both services, database connection, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
registry_server:&lt;br /&gt;
  # Primary network interface and port the Market Data Registry Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20300&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the registry server is reachable at (for registration with Service Locator).&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20300&amp;quot;, &amp;quot;10.0.0.5:20300&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
feed_server:&lt;br /&gt;
  # Primary network interface and port the Market Data Feed Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20400&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the feed server is reachable at (for registration with Service Locator).&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20400&amp;quot;, &amp;quot;10.0.0.5:20400&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
# Countries for which market data is supported.&lt;br /&gt;
countries:&lt;br /&gt;
  - AU&lt;br /&gt;
  - CA&lt;br /&gt;
  - HK&lt;br /&gt;
  - JP&lt;br /&gt;
  - US&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Market Data Server to authenticate with the Service Locator.&lt;br /&gt;
  username: market_data_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Market Data Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
&lt;br /&gt;
=== Market Data Types ===&lt;br /&gt;
The server processes and distributes the following market data types:&lt;br /&gt;
&lt;br /&gt;
* '''BBO Quotes''' (Best Bid/Offer) - Top-of-book bid and ask prices with sizes&lt;br /&gt;
* '''Book Quotes''' - Full order book depth with multiple price levels per side&lt;br /&gt;
* '''Time and Sales''' - Executed trade prices, sizes, and timestamps&lt;br /&gt;
* '''Order Imbalances''' - Pre-opening and closing auction imbalance data&lt;br /&gt;
&lt;br /&gt;
=== Security Tracking ===&lt;br /&gt;
For each security, the server maintains:&lt;br /&gt;
&lt;br /&gt;
* Real-time market data snapshots combining BBO, book depth, and last trade&lt;br /&gt;
* Security technicals including open, high, low, close, and volume&lt;br /&gt;
* Sequence numbers ensuring consistent ordering of market data updates&lt;br /&gt;
* Source tracking to identify which feed client published each data point&lt;br /&gt;
&lt;br /&gt;
=== Data Sequencing ===&lt;br /&gt;
All market data updates are assigned monotonically increasing sequence numbers per security and data type. This ensures clients can detect gaps, maintain consistent ordering, and synchronize state reliably.&lt;br /&gt;
&lt;br /&gt;
=== Historical Data Storage ===&lt;br /&gt;
Market data is persisted to MySQL with indexed queries supporting:&lt;br /&gt;
&lt;br /&gt;
* Time range queries by security or venue&lt;br /&gt;
* Snapshot queries for initial state loading&lt;br /&gt;
* Efficient storage of high-frequency data streams&lt;br /&gt;
&lt;br /&gt;
== Utility Scripts ==&lt;br /&gt;
&lt;br /&gt;
=== add_security_info.py ===&lt;br /&gt;
A utility script to add or update security metadata in the system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python add_security_info.py&lt;br /&gt;
  --config config.yml       # Configuration file&lt;br /&gt;
  --symbol AAPL.NASDAQ      # Ticker symbol&lt;br /&gt;
  --name &amp;quot;Apple Inc.&amp;quot;       # Display name&lt;br /&gt;
  --sector Technology       # Sector (optional)&lt;br /&gt;
  --board_lot 100          # Board lot size&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== dump_data_store.py ===&lt;br /&gt;
A backup and restore utility supporting bidirectional data transfer between MySQL and SQLite:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python dump_data_store.py&lt;br /&gt;
  --config config.yml              # Configuration file&lt;br /&gt;
  --start &amp;quot;2024-01-01 00:00:00&amp;quot;   # Start time range&lt;br /&gt;
  --end &amp;quot;2024-12-31 23:59:59&amp;quot;     # End time range&lt;br /&gt;
  --output backup.db               # Export MySQL to SQLite&lt;br /&gt;
  --cores 8                        # Number of parallel workers&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or to restore from SQLite to MySQL:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python dump_data_store.py&lt;br /&gt;
  --config config.yml&lt;br /&gt;
  --start &amp;quot;2024-01-01 00:00:00&amp;quot;&lt;br /&gt;
  --end &amp;quot;2024-12-31 23:59:59&amp;quot;&lt;br /&gt;
  --input backup.db&lt;br /&gt;
  --cores 8&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The script uses multiprocessing to efficiently backup or restore large datasets across multiple securities and venues in parallel.&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
  --mysql_address 127.0.0.1:3306  # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin     # MySQL username&lt;br /&gt;
  --mysql_password secretpw       # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire            # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Market Data Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
MarketDataServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;MarketDataServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Definitions_Server&amp;diff=238</id>
		<title>Definitions Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Definitions_Server&amp;diff=238"/>
		<updated>2025-12-01T22:03:44Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Definitions Server = The Definitions Server provides centralized reference data for the trading platform. It disseminates system-wide definitions including country codes, cu...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Definitions Server =&lt;br /&gt;
The Definitions Server provides centralized reference data for the trading platform. It disseminates system-wide definitions including country codes, currencies, trading venues, order routing destinations, time zones, exchange rates, compliance rule schemas, and trading schedules. By centralizing these definitions, the server ensures consistent metadata across all components of the system.&lt;br /&gt;
&lt;br /&gt;
The Definitions Server integrates with the Service Locator for authentication and service registration. All reference data is loaded from YAML and CSV configuration files at startup.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Definitions Server is configured via a YAML file that defines network interfaces, Service Locator integration, and paths to reference data files. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Definitions Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20200&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20200&amp;quot;, &amp;quot;10.0.0.5:20200&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Definitions Server to authenticate with the Service Locator.&lt;br /&gt;
  username: definitions_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Definitions Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
&lt;br /&gt;
# Minimum version of the Spire client required to connect.&lt;br /&gt;
minimum_spire_version: &amp;quot;1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Name of the organization operating the platform.&lt;br /&gt;
organization: &amp;quot;Spire Trading Inc.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# NTP pool servers for time synchronization.&lt;br /&gt;
ntp_pool: [&amp;quot;0.pool.ntp.org:123&amp;quot;,&lt;br /&gt;
           &amp;quot;1.pool.ntp.org:123&amp;quot;,&lt;br /&gt;
           &amp;quot;2.pool.ntp.org:123&amp;quot;,&lt;br /&gt;
           &amp;quot;3.pool.ntp.org:123&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
# Paths to reference data files.&lt;br /&gt;
countries: countries.yml&lt;br /&gt;
currencies: currencies.yml&lt;br /&gt;
destinations: destinations.yml&lt;br /&gt;
venues: venues.yml&lt;br /&gt;
time_zones: date_time_zonespec.csv&lt;br /&gt;
&lt;br /&gt;
# Exchange rate definitions.&lt;br /&gt;
exchange_rates:&lt;br /&gt;
  - symbol: USD/CAD&lt;br /&gt;
    rate: 1.33&lt;br /&gt;
  - symbol: USD/AUD&lt;br /&gt;
    rate: 1.49&lt;br /&gt;
  - symbol: AUD/CAD&lt;br /&gt;
    rate: 0.89&lt;br /&gt;
  - symbol: HKD/CAD&lt;br /&gt;
    rate: 0.17&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reference Data Files ==&lt;br /&gt;
The Definitions Server loads reference data from the following files:&lt;br /&gt;
&lt;br /&gt;
=== countries.yml ===&lt;br /&gt;
Defines country codes according to ISO 3166 standard:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
countries:&lt;br /&gt;
  - name: Canada&lt;br /&gt;
    two_letter_code: CA&lt;br /&gt;
    three_letter_code: CAN&lt;br /&gt;
    code: 124&lt;br /&gt;
  - name: United States&lt;br /&gt;
    two_letter_code: US&lt;br /&gt;
    three_letter_code: USA&lt;br /&gt;
    code: 840&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A utility script (&amp;lt;code&amp;gt;update_countries.sh&amp;lt;/code&amp;gt;) is provided to download and update country definitions from the official ISO 3166 data source. The script uses &amp;lt;code&amp;gt;country_code_parser.py&amp;lt;/code&amp;gt; to parse the CSV data and generate the YAML file.&lt;br /&gt;
&lt;br /&gt;
=== currencies.yml ===&lt;br /&gt;
Defines currency codes, symbols, and identifiers:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
currencies:&lt;br /&gt;
  - code: CAD&lt;br /&gt;
    sign: $&lt;br /&gt;
    id: 124&lt;br /&gt;
  - code: USD&lt;br /&gt;
    sign: $&lt;br /&gt;
    id: 840&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== venues.yml ===&lt;br /&gt;
Defines trading venues (exchanges and markets) including their country, time zone, and currency:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
venues:&lt;br /&gt;
  - venue: XTSE&lt;br /&gt;
    country_code: CA&lt;br /&gt;
    time_zone: Eastern_Time&lt;br /&gt;
    currency: CAD&lt;br /&gt;
    description: Toronto Stock Exchange&lt;br /&gt;
    display_name: TSX&lt;br /&gt;
  - venue: XASX&lt;br /&gt;
    country_code: AU&lt;br /&gt;
    time_zone: Australian_Eastern_Standard_Time&lt;br /&gt;
    currency: AUD&lt;br /&gt;
    description: Australian Stock Market&lt;br /&gt;
    display_name: ASX&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== destinations.yml ===&lt;br /&gt;
Defines order routing destinations and their applicable venues:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
destinations:&lt;br /&gt;
  - id: TSX&lt;br /&gt;
    description: Toronto Stock Exchange&lt;br /&gt;
    venues:&lt;br /&gt;
      - XTSE&lt;br /&gt;
      - XTSX&lt;br /&gt;
  - id: NEOE&lt;br /&gt;
    description: Aequitas NEO Exchange&lt;br /&gt;
    venues:&lt;br /&gt;
      - NEOE&lt;br /&gt;
      - XCNQ&lt;br /&gt;
      - XTSE&lt;br /&gt;
      - XTSX&lt;br /&gt;
&lt;br /&gt;
# Preferred destinations specify default routing per venue&lt;br /&gt;
preferred_destinations:&lt;br /&gt;
  - venue: XTSE&lt;br /&gt;
    destination: TSX&lt;br /&gt;
  - venue: NEOE&lt;br /&gt;
    destination: NEOE&lt;br /&gt;
&lt;br /&gt;
# Manual order entry destination&lt;br /&gt;
manual_order_entry:&lt;br /&gt;
  id: MOE&lt;br /&gt;
  description: Manual Order Entry&lt;br /&gt;
  venues:&lt;br /&gt;
    - NEOE&lt;br /&gt;
    - XASX&lt;br /&gt;
    - XCNQ&lt;br /&gt;
    - XTSE&lt;br /&gt;
    - XTSX&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== date_time_zonespec.csv ===&lt;br /&gt;
Contains time zone database information in CSV format for accurate timestamp conversion across regions.&lt;br /&gt;
&lt;br /&gt;
=== trading_schedules.yml ===&lt;br /&gt;
Defines market hours, holidays, and trading events:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
trading_schedules:&lt;br /&gt;
  # Define closed days by weekday&lt;br /&gt;
  - venues: [XASX]&lt;br /&gt;
    time:&lt;br /&gt;
      weekdays: [Sat, Sun]&lt;br /&gt;
  &lt;br /&gt;
  # Define specific holiday dates&lt;br /&gt;
  - venues: [XASX]&lt;br /&gt;
    dates: [2020-01-01, 2020-04-10, 2020-12-25]&lt;br /&gt;
  &lt;br /&gt;
  # Define trading session times&lt;br /&gt;
  - venues: XASX&lt;br /&gt;
    events:&lt;br /&gt;
      - type: PRE_OPEN&lt;br /&gt;
        time: 7:00&lt;br /&gt;
      - type: OPEN&lt;br /&gt;
        time: 10:00&lt;br /&gt;
      - type: CLOSE&lt;br /&gt;
        time: 16:00&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template. The script also copies default reference data files if they do not already exist.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Definitions Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DefinitionsServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;DefinitionsServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Compliance_Server&amp;diff=237</id>
		<title>Compliance Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Compliance_Server&amp;diff=237"/>
		<updated>2025-12-01T21:59:57Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Compliance Server = The Compliance Server manages compliance rules and monitors rule violations for trading accounts. It maintains a repository of compliance rule definition...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Compliance Server =&lt;br /&gt;
The Compliance Server manages compliance rules and monitors rule violations for trading accounts. It maintains a repository of compliance rule definitions organized by directory entry, tracks rule states (active, passive, or deleted), and records violation events. By centralizing compliance rule administration and violation tracking, the server enforces consistent regulatory and risk management policies across the trading platform.&lt;br /&gt;
&lt;br /&gt;
The Compliance Server integrates with the Service Locator for authentication and permission verification, the Administration Server to validate administrator privileges, and a MySQL database to persist compliance rules and violation records.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Compliance Server is configured via a YAML file that defines network interfaces, database connection, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Compliance Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:21900&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:21900&amp;quot;, &amp;quot;10.0.0.5:21900&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Compliance Server to authenticate with the Service Locator.&lt;br /&gt;
  username: compliance_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Compliance Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
  --mysql_address 127.0.0.1:3306  # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin     # MySQL username&lt;br /&gt;
  --mysql_password secretpw       # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire            # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Functionality ==&lt;br /&gt;
The Compliance Server provides the following capabilities:&lt;br /&gt;
&lt;br /&gt;
=== Rule Management ===&lt;br /&gt;
Compliance rules are organized by directory entry (accounts or groups) and consist of:&lt;br /&gt;
* A unique rule identifier&lt;br /&gt;
* The associated directory entry&lt;br /&gt;
* A state (active, passive, or deleted)&lt;br /&gt;
* A compliance rule schema defining the rule logic&lt;br /&gt;
&lt;br /&gt;
Administrators can create, update, and delete compliance rules. Rule changes are immediately propagated to subscribed clients for real-time enforcement.&lt;br /&gt;
&lt;br /&gt;
=== Rule Monitoring ===&lt;br /&gt;
Clients with appropriate permissions can:&lt;br /&gt;
* Load existing compliance rules for a specific directory entry&lt;br /&gt;
* Subscribe to receive real-time updates when rules are added, modified, or deleted&lt;br /&gt;
&lt;br /&gt;
Subscriptions enable clients to maintain synchronized views of active compliance rules without polling.&lt;br /&gt;
&lt;br /&gt;
=== Violation Reporting ===&lt;br /&gt;
Administrators can report compliance rule violations, which are:&lt;br /&gt;
* Timestamped by the server&lt;br /&gt;
* Persistently stored in the database&lt;br /&gt;
* Available for audit and analysis&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Compliance Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ComplianceServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;ComplianceServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Charting_Server&amp;diff=236</id>
		<title>Charting Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Charting_Server&amp;diff=236"/>
		<updated>2025-12-01T21:52:36Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Charting Server = The Charting Server processes time series queries on market data and publishes ongoing updates to clients. It performs calculations such as candlestick agg...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Charting Server =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Charting Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:21400&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:21400&amp;quot;, &amp;quot;10.0.0.5:21400&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Charting Server to authenticate with the Service Locator.&lt;br /&gt;
  username: charting_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Charting Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;config.default.yml&amp;lt;/code&amp;gt; template.&lt;br /&gt;
&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0           # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5      # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000  # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED]     # Service password for authentication&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
The Charting Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
srv_YYYYMMDD_HH_MM_SS.log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ChartingServer is not running.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Exits immediately if the server is already running&lt;br /&gt;
* Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
* Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
* Starts the &amp;lt;code&amp;gt;ChartingServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
* Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
* Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
* Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
* Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
* Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
* Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Administration_Server&amp;diff=235</id>
		<title>Administration Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Administration_Server&amp;diff=235"/>
		<updated>2025-12-01T21:45:00Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;= Administration Server =  The Administration Server manages account-level authorization and operational metadata for Spire. It maintains each account's role (trader, manager,...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Administration Server =&lt;br /&gt;
&lt;br /&gt;
The Administration Server manages account-level authorization and operational metadata for Spire. It maintains each account's role (trader, manager, administrator, or service), market-data entitlements, risk parameters, and trading permissions. By centralizing these attributes, it enforces access control, entitlement visibility, and trading eligibility across the system.&lt;br /&gt;
The server integrates with the Service Locator to enumerate accounts and with a MySQL database to persist administrative data.&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
The Administration Server is configured via a YAML file that defines network interfaces, database connection, Service Locator integration, and market-data entitlements. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # Primary network interface and port the Administration Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20100&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # List of addresses the server is reachable at (for registration with Service Locator).&lt;br /&gt;
  # Typically includes both public-facing and local addresses.&lt;br /&gt;
  addresses: [&amp;quot;198.51.100.5:20100&amp;quot;, &amp;quot;10.0.0.5:20100&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: spireadmin&lt;br /&gt;
  &lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
  &lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # The address of the Service Locator (host:port).&lt;br /&gt;
  address: &amp;quot;10.0.0.5:20000&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  # The account username used by the Administration Server to authenticate with the Service Locator.&lt;br /&gt;
  username: administration_service&lt;br /&gt;
  &lt;br /&gt;
  # The password for the Administration Server's Service Locator account.&lt;br /&gt;
  password: admin_password&lt;br /&gt;
&lt;br /&gt;
entitlements:&lt;br /&gt;
  # Market-data entitlement definitions.&lt;br /&gt;
  # Each entitlement specifies pricing, applicable exchanges, and message types.&lt;br /&gt;
  - name: Demo Entitlements&lt;br /&gt;
    price: 0.00&lt;br /&gt;
    currency: USD&lt;br /&gt;
    group: demo_entitlements&lt;br /&gt;
    applicability:&lt;br /&gt;
      # source: the venue disseminating the market data&lt;br /&gt;
      # messages: market data message types&lt;br /&gt;
      #   BBO - best bid offer quotes&lt;br /&gt;
      #   BOOK - book quotes&lt;br /&gt;
      #   TAS - time and sales&lt;br /&gt;
      #   IMB - order imbalances&lt;br /&gt;
      - source: CHIC&lt;br /&gt;
        messages: [BBO, BOOK, TAS, IMB]&lt;br /&gt;
      - source: XTSE&lt;br /&gt;
        messages: [BBO, BOOK, TAS, IMB]&lt;br /&gt;
      - source: XTSX&lt;br /&gt;
        messages: [BBO, BOOK, TAS, IMB]&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation &amp;amp; Setup ==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided to generate the final &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt;.&lt;br /&gt;
The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; python setup.py&lt;br /&gt;
  --local 0.0.0.0 # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 198.51.100.5 # Global/public interface (optional)&lt;br /&gt;
  --address 10.0.0.5:20000 # Service Locator address (default: local_interface:20000)&lt;br /&gt;
  --password [REQUIRED] # Administration password&lt;br /&gt;
  --mysql_address 127.0.0.1:3306 # MySQL server address&lt;br /&gt;
  --mysql_username spireadmin # MySQL username&lt;br /&gt;
  --mysql_password secretpw # MySQL password (default: --password if omitted)&lt;br /&gt;
  --mysql_schema spire # MySQL schema&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Risk State Initialization Utility ==&lt;br /&gt;
&lt;br /&gt;
A reset script (&amp;lt;code&amp;gt;reset_risk_states.py&amp;lt;/code&amp;gt;) is provided to initialize or reset the risk state for all accounts and is typically run on a daily basis.&lt;br /&gt;
&lt;br /&gt;
== Operations ==&lt;br /&gt;
&lt;br /&gt;
The Administration Server is controlled using three operational scripts: &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt;.&lt;br /&gt;
Log files are generated in the format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; srv_YYYYMMDD_HH_MM_SS.log &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Upon startup, older log files are moved into the &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
=== check.sh ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;check.sh&amp;lt;/code&amp;gt; script verifies whether the server is currently running by inspecting the PID recorded in &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; and testing whether the associated process exists.&lt;br /&gt;
If the server is not running, it prints:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; AdministrationServer is not running. &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== start.sh ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;start.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
&lt;br /&gt;
Exits immediately if the server is already running&lt;br /&gt;
&lt;br /&gt;
Creates a &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt; directory if necessary&lt;br /&gt;
&lt;br /&gt;
Moves any existing &amp;lt;code&amp;gt;srv_*.log&amp;lt;/code&amp;gt; files into &amp;lt;code&amp;gt;logs/&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Starts the &amp;lt;code&amp;gt;AdministrationServer&amp;lt;/code&amp;gt; process in the background&lt;br /&gt;
&lt;br /&gt;
Writes the PID to &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reads network interfaces from &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; and waits until the server is listening on at least one configured address&lt;br /&gt;
&lt;br /&gt;
This ensures the server is fully initialized before the script exits.&lt;br /&gt;
&lt;br /&gt;
=== stop.sh ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;stop.sh&amp;lt;/code&amp;gt; script:&lt;br /&gt;
&lt;br /&gt;
Reads the PID from &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Sends &amp;lt;code&amp;gt;SIGINT&amp;lt;/code&amp;gt; to request a graceful shutdown&lt;br /&gt;
&lt;br /&gt;
Waits for termination using exponential backoff (up to 300 seconds)&lt;br /&gt;
&lt;br /&gt;
Sends &amp;lt;code&amp;gt;SIGKILL&amp;lt;/code&amp;gt; if the server fails to stop cleanly&lt;br /&gt;
&lt;br /&gt;
Appends a forced-termination message to the most recent log file (if applicable)&lt;br /&gt;
&lt;br /&gt;
Removes the &amp;lt;code&amp;gt;pid.lock&amp;lt;/code&amp;gt; file&lt;br /&gt;
&lt;br /&gt;
This guarantees consistent shutdown behavior across normal and exceptional conditions.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=NEOE_Market_Data_Feed_Client&amp;diff=233</id>
		<title>NEOE Market Data Feed Client</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=NEOE_Market_Data_Feed_Client&amp;diff=233"/>
		<updated>2025-02-25T16:32:10Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;The NEOE Market Data Feed Client disseminates real-time market data for the Aequitas NEO Exchange. It connects to the Service Locator for authentication and provides order boo...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The NEOE Market Data Feed Client disseminates real-time market data for the Aequitas NEO Exchange. It connects to the Service Locator for authentication and provides order book data, time and sales, and the consolidated best bid offer for the NEO Exchange. The feed is managed using start.sh, stop.sh, and check.sh scripts for service control.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
The feed is split into multiple channels for disseminating the CBBO, book, and trade data. Each channel can be found in its own subdirectory whose name starts with the neoe prefix, such as neoe_cbbo, neoe_cls and neoe_book for the CBBO, time and sales, and book feed respectively.&lt;br /&gt;
&lt;br /&gt;
The feed is configured via a YAML file (&amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt;) with the following structure and example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
service_locator:&lt;br /&gt;
  # Service Locator connection details&lt;br /&gt;
  address: &amp;quot;127.0.0.1:20000&amp;quot;&lt;br /&gt;
  username: &amp;quot;market_data_feed&amp;quot;&lt;br /&gt;
  password: &amp;quot;securepassword123&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Whether to log raw market data packets&lt;br /&gt;
enable_logging: false&lt;br /&gt;
&lt;br /&gt;
# Path to security definitions (relative to config)&lt;br /&gt;
symbol_list: &amp;quot;../symbols.yml&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Frequency of market data updates&lt;br /&gt;
sampling: 100ms&lt;br /&gt;
&lt;br /&gt;
# Retransmission settings&lt;br /&gt;
enable_retransmission: false&lt;br /&gt;
max_retransmissions: 10000&lt;br /&gt;
retransmission_block_size: 20000&lt;br /&gt;
&lt;br /&gt;
# Multicast network configuration&lt;br /&gt;
host: &amp;quot;233.102.209.247:61023&amp;quot;&lt;br /&gt;
interface: &amp;quot;192.168.0.100:61023&amp;quot;&lt;br /&gt;
retransmission_request_address: &amp;quot;142.201.149.44:61030&amp;quot;&lt;br /&gt;
retransmission_response_address: &amp;quot;142.201.149.44:61031&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Market Participant ID mappings&lt;br /&gt;
mpid_mappings:&lt;br /&gt;
  - source: 1&lt;br /&gt;
    name: ANON&lt;br /&gt;
  - source: 2&lt;br /&gt;
    name: RBCC&lt;br /&gt;
  - source: 3&lt;br /&gt;
    name: TRIS&lt;br /&gt;
  - source: 4&lt;br /&gt;
    name: VERS&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition there is a security master list of traded securities typically founds in the &amp;lt;code&amp;gt;symbols.yml&amp;lt;/code&amp;gt; file with the following format:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
  - symbol: AAPL                  # The ticker symbol assign.&lt;br /&gt;
    name: APPLE CDR (CAD HEDGED)  # The name of the security.&lt;br /&gt;
    board_lot: 100                # The security's board lot.&lt;br /&gt;
  - symbol: ABXX&lt;br /&gt;
    name: ABAXX TECHNOLOGIES INC.&lt;br /&gt;
    board_lot: 100&lt;br /&gt;
  - symbol: ABXX.WT&lt;br /&gt;
    name: ABAXX TECHNOLOGIES INC. WARRANTS&lt;br /&gt;
    board_lot: 100&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Changes can be made in this security master list and reloaded by restarting the NEOE CBBO feed.&lt;br /&gt;
&lt;br /&gt;
==Installation &amp;amp; Setup==&lt;br /&gt;
&lt;br /&gt;
===&amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; Script===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; Python script configures all of the channels at once and can be called as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python3 setup.py&lt;br /&gt;
  --local 192.168.0.100          # Local interface (default: auto-detected IP)&lt;br /&gt;
  --address 127.0.0.1:20000      # Service Locator address&lt;br /&gt;
  --username market_data_feed    # Service Locator username (default: market_data_feed)&lt;br /&gt;
  --password [REQUIRED]          # Service Locator password&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Operations==&lt;br /&gt;
&lt;br /&gt;
Log files are generated as srv_[YYYY][MM][DD]_[HH]_[MM]_[SS].log in the runtime directory, upon termination, non-empty log files are moved into the log/ subfolder, while empty log files are deleted.&lt;br /&gt;
&lt;br /&gt;
Each channel is managed through three core scripts:&lt;br /&gt;
&lt;br /&gt;
start.sh Starts the channel, does nothing if the channel is already running.&lt;br /&gt;
&lt;br /&gt;
stop.sh Stops the channel and waits for the channel to terminate.&lt;br /&gt;
&lt;br /&gt;
check.sh Verifies that the channel is running.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Uid_Server&amp;diff=232</id>
		<title>Uid Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Uid_Server&amp;diff=232"/>
		<updated>2025-02-05T00:20:32Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;The Uid Server is a centralized service responsible for generating batches of unique integers that can be used to identify items, such as database entries. The Uid Server regi...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Uid Server is a centralized service responsible for generating batches of unique integers that can be used to identify items, such as database entries. The Uid Server registers itself with the Service Locator as a &amp;lt;code&amp;gt;uid_server&amp;lt;/code&amp;gt; and ensures uniqueness by tracking allocated identifiers in a MySQL database.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
The Uid Server is configured via a YAML file that defines its network interface, data store settings, and Service Locator integration. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
server:&lt;br /&gt;
  # The network interface and port the Uid Server binds to.&lt;br /&gt;
  interface: &amp;quot;0.0.0.0:20900&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # List of addresses the server advertises for client connections.&lt;br /&gt;
  addresses: [&amp;quot;192.168.1.100:20900&amp;quot;, &amp;quot;0.0.0.0:20900&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # MySQL server address (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # MySQL credentials.&lt;br /&gt;
  username: uid_server&lt;br /&gt;
  password: securepassword123&lt;br /&gt;
  schema: uid_db&lt;br /&gt;
&lt;br /&gt;
service_locator:&lt;br /&gt;
  # Service Locator address for registration.&lt;br /&gt;
  address: &amp;quot;127.0.0.1:20000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # Uid Server credentials for Service Locator.&lt;br /&gt;
  username: uid_service&lt;br /&gt;
  password: adminpassword123&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Installation &amp;amp; Setup==&lt;br /&gt;
&lt;br /&gt;
A Python script automates configuration file generation. Usage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0                   # Local interface (default: auto-detected IP)&lt;br /&gt;
  --world 192.168.1.100             # Global interface (default: same as local)&lt;br /&gt;
  --address 127.0.0.1:20000         # Service Locator address&lt;br /&gt;
  --password [REQUIRED]             # Admin password for Service Locator&lt;br /&gt;
  --mysql_address 127.0.0.1:3306    # MySQL server address&lt;br /&gt;
  --mysql_username admin            # MySQL username (default: spireadmin)&lt;br /&gt;
  --mysql_password [OPTIONAL]       # MySQL password (default: same as admin password)&lt;br /&gt;
  --mysql_schema uid_db             # Database schema (default: spire)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Features:&lt;br /&gt;
&lt;br /&gt;
* Generates config.yml from config.default.yml template.&lt;br /&gt;
* Requires only the --password argument by default.&lt;br /&gt;
* Auto-detects local IP if --local is omitted.&lt;br /&gt;
&lt;br /&gt;
==Operations==&lt;br /&gt;
&lt;br /&gt;
Log files are generated as srv_[YYYY][MM][DD]_[HH]_[MM]_[SS].log in the runtime directory, upon termination, non-empty log files are moved into the log/ subfolder, while empty log files are deleted.&lt;br /&gt;
&lt;br /&gt;
The Uid Server is managed through three core scripts:&lt;br /&gt;
&lt;br /&gt;
start.sh&lt;br /&gt;
Starts the Uid server, does nothing if the server is already running.&lt;br /&gt;
&lt;br /&gt;
stop.sh&lt;br /&gt;
Stops an existing server instance and waits for the server to terminate.&lt;br /&gt;
&lt;br /&gt;
check.sh&lt;br /&gt;
Verifies that the server is running.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Service_Locator&amp;diff=231</id>
		<title>Service Locator</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Service_Locator&amp;diff=231"/>
		<updated>2025-02-04T19:55:47Z</updated>

		<summary type="html">&lt;p&gt;Kamal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Service Locator is a centralized server responsible for authenticating account logins, creating and managing user accounts, organizing accounts into directories, controlling permissions, and registering available services. It acts as a critical component for coordinating access control and service discovery. The Service Locator integrates with a MySQL database to persistently store account details, directory structures, permissions, and service registration data.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
The Service Locator is configured via a YAML file that defines its network interface and data store settings. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
# The network interface and port the Service Locator binds to.&lt;br /&gt;
interface: &amp;quot;0.0.0.0:20000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: service_locator&lt;br /&gt;
&lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: 1234&lt;br /&gt;
&lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: spire&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Installation &amp;amp; Setup==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided for convenience to configure the Service Locator and generate the &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; file. The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0                   # Local interface (default: auto-detected IP)&lt;br /&gt;
  --mysql_address 127.0.0.1:3306    # MySQL server address&lt;br /&gt;
  --mysql_username admin            # MySQL username (default: spireadmin)&lt;br /&gt;
  --mysql_password [REQUIRED]       # MySQL password (no default)&lt;br /&gt;
  --mysql_schema service_db         # Database schema (default: spire)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Operations==&lt;br /&gt;
&lt;br /&gt;
Log files are generated as srv_[YYYY][MM][DD]_[HH]_[MM]_[SS].log in the runtime directory, upon termination, non-empty log files are moved into the log/ subfolder, while empty log files are deleted.&lt;br /&gt;
&lt;br /&gt;
The Service Locator is managed through three core scripts:&lt;br /&gt;
&lt;br /&gt;
start.sh&lt;br /&gt;
Starts the Service Locator server, does nothing if the server is already running.&lt;br /&gt;
&lt;br /&gt;
stop.sh&lt;br /&gt;
Stops an existing server instance and waits for the server to terminate.&lt;br /&gt;
&lt;br /&gt;
check.sh&lt;br /&gt;
Verifies that the server is running.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Service_Locator&amp;diff=230</id>
		<title>Service Locator</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Service_Locator&amp;diff=230"/>
		<updated>2025-02-04T19:54:58Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;The Service Locator is a centralized server responsible for authenticating account logins, creating and managing user accounts, organizing accounts into directories, controlli...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Service Locator is a centralized server responsible for authenticating account logins, creating and managing user accounts, organizing accounts into directories, controlling permissions, and registering available services. It acts as a critical component for coordinating access control and service discovery. The Service Locator integrates with a MySQL database to persistently store account details, directory structures, permissions, and service registration data.&lt;br /&gt;
&lt;br /&gt;
==Configuration==&lt;br /&gt;
&lt;br /&gt;
The Service Locator is configured via a YAML file that defines its network interface and data store settings. Below is the structure of the configuration file with example values:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
---&lt;br /&gt;
# The network interface and port the Service Locator binds to.&lt;br /&gt;
interface: &amp;quot;0.0.0.0:20000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
data_store:&lt;br /&gt;
  # The address of the MySQL server (host:port).&lt;br /&gt;
  address: &amp;quot;127.0.0.1:3306&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  # The username for authenticating with MySQL.&lt;br /&gt;
  username: service_locator&lt;br /&gt;
&lt;br /&gt;
  # The password for the MySQL user.&lt;br /&gt;
  password: securepassword123&lt;br /&gt;
&lt;br /&gt;
  # The name of the database schema where data is stored.&lt;br /&gt;
  schema: service_locator_db&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Installation &amp;amp; Setup==&lt;br /&gt;
&lt;br /&gt;
A &amp;lt;code&amp;gt;setup.py&amp;lt;/code&amp;gt; script is provided for convenience to configure the Service Locator and generate the &amp;lt;code&amp;gt;config.yml&amp;lt;/code&amp;gt; file. The script supports the following arguments:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
python setup.py&lt;br /&gt;
  --local 0.0.0.0                   # Local interface (default: auto-detected IP)&lt;br /&gt;
  --mysql_address 127.0.0.1:3306    # MySQL server address&lt;br /&gt;
  --mysql_username admin            # MySQL username (default: spireadmin)&lt;br /&gt;
  --mysql_password [REQUIRED]       # MySQL password (no default)&lt;br /&gt;
  --mysql_schema service_db         # Database schema (default: spire)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Operations==&lt;br /&gt;
&lt;br /&gt;
Log files are generated as srv_[YYYY][MM][DD]_[HH]_[MM]_[SS].log in the runtime directory, upon termination, non-empty log files are moved into the log/ subfolder, while empty log files are deleted.&lt;br /&gt;
&lt;br /&gt;
The Service Locator is managed through three core scripts:&lt;br /&gt;
&lt;br /&gt;
start.sh&lt;br /&gt;
Starts the Service Locator server, does nothing if the server is already running.&lt;br /&gt;
&lt;br /&gt;
stop.sh&lt;br /&gt;
Stops an existing server instance and waits for the server to terminate.&lt;br /&gt;
&lt;br /&gt;
check.sh&lt;br /&gt;
Verifies that the server is running.&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=C%2B%2B_Style_Guide&amp;diff=29</id>
		<title>C++ Style Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=C%2B%2B_Style_Guide&amp;diff=29"/>
		<updated>2018-02-23T01:55:10Z</updated>

		<summary type="html">&lt;p&gt;Kamal: /* Development Environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article specifies the most general guidelines used for all Spire projects written using C++ as the primary programming language. Each individual project may extend or override the guidelines specified herein. The overall aim of this guideline is to provide consistency across the numerous projects developed by Spire in order to promote and benefit from modern C++ practices as well as tailor them to our specific requirements.&lt;br /&gt;
&lt;br /&gt;
In general, the guidelines are very specific and opinionated. This is done intentionally to ensure that every detail has been given proper consideration and that every line of code is written with care and diligence. It is taken as a prerequisite that writing robust, clean and maintainable code requires paying close attention to even the smallest of details. As such, when there are two or more ways to write or express any given statement or expression, be it using spaces or tabs, number of characters per line, purple or violet, the guideline will often require that one particular approach be used to the exclusion of others.&lt;br /&gt;
&lt;br /&gt;
Finally, this document is constantly evolving and as such older projects may not be up-to-date with the guidelines found here. In those circumstances one must use their best judgment about how to integrate these guidelines into older codebases. As a general principle, consistency should favor the local over the global, that is it is more important to be consistent with a function definition than within a file, and more important to be consistent within a file than within a directory, project, etc...&lt;br /&gt;
&lt;br /&gt;
=Core Guidelines=&lt;br /&gt;
This document should be seen as an extension to the Cpp Core Guidelines authored and maintained by Herb Sutter and Bjarne Stroustrup. After reviewing these guidelines one should then become familiar with the Cpp Core Guidelines as documented here:&lt;br /&gt;
&lt;br /&gt;
https://github.com/isocpp/CppCoreGuidelines&lt;br /&gt;
&lt;br /&gt;
Those guidelines specify the best practices for writing modern C++ code. In situations where there is a conflict between the Cpp Core Guidelines and the guidelines set forth in this document, this document takes precedence. For all known situations where a conflict exists, this document should explicitly indicate that conflict to avoid confusion.&lt;br /&gt;
&lt;br /&gt;
=Development Environment=&lt;br /&gt;
&lt;br /&gt;
The two primary development environments supported by Spire projects are Ubuntu Server 16.04 LTS and Windows 10. On Unix like systems the compiler of choice is g++ 5.4 and on Windows 10 it's Microsoft Visual Studio 2017 15.5.7. In order to support these two platforms, CMake is used to produce the appropriate project/make files for each platform.&lt;br /&gt;
&lt;br /&gt;
For source control, git is used and projects are to be hosted on [https://github.com/spiretrading Spire Trading's Github page].&lt;br /&gt;
&lt;br /&gt;
Each developer is welcome to use an editor of their choice. [https://www.visualstudio.com/downloads/ Visual Studio 2017] is typically used for Windows and [https://code.visualstudio.com/ Visual Studio Code] is typically used on Linux and Mac.&lt;br /&gt;
&lt;br /&gt;
=File Names=&lt;br /&gt;
&lt;br /&gt;
Use [https://en.wikipedia.org/wiki/Snake_case snake case] using all lower case letters for files and directories. The main exception is for CMake files which must use the name ''CMakeLists.txt''&lt;br /&gt;
&lt;br /&gt;
Header files should use the extension ''hpp''&lt;br /&gt;
&lt;br /&gt;
Source files should use the extension ''cpp''&lt;br /&gt;
&lt;br /&gt;
All files end with a single new line character.&lt;br /&gt;
&lt;br /&gt;
=Directory Structure=&lt;br /&gt;
&lt;br /&gt;
A project is broken down into one library component and one or more application components. These components are referred to as ''artifacts''. The library is written in a [https://en.wikipedia.org/wiki/Header-only header-only fashion], that is the implementation is provided directly in the header file rather than a separate .cpp source file. This allows for such libraries to easily be incorporated into other projects without the need for complex build configurations. Applications often use a mix of header only files and source files.&lt;br /&gt;
&lt;br /&gt;
The applications go into their own ''applications'' directory and the libraries into the ''library'' directory. Within each artifact is a ''build'' directory containing the build scripts and CMake files needed to build that artifact. Scripts for POSIX systems are found in the ''posix'' sub-directory and Windows build files are within the ''windows'' sub-directory. The build scripts specified are ''run_cmake'' to produce the platform specific build files (make files for POSIX and VS solutions for Windows), ''version'' to produce a header file that contains the version of the artifact produced and the ''build'' script which produces the artifact. In order to build an artifact, one first produces the build files for their platform by running the ''run_cmake'' script, and then they can run the ''build'' script afterwards to produce the artifact.&lt;br /&gt;
&lt;br /&gt;
Finally there is a top-level ''build'' directory for the project as a whole which produces all artifacts by recursively calling each artifact's individual build scripts. Additionally the top-level build directory also includes a ''setup'' script which downloads all third party dependencies. Some projects may also opt to include an ''install'' script which sets up a suitable development environment, and other scripts for continuous builds, deployment and testing.&lt;br /&gt;
&lt;br /&gt;
Assuming a project named tic_tac_toe consisting of applications tic_tac_toe_console and tic_tac_toe_ui sharing code common to both applications, the following directory structure should be used:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
tic_tac_toe                        # Root level directory.&lt;br /&gt;
  \applications                    # Contains all applications.&lt;br /&gt;
    \tic_tac_toe_console           # Contains the source for a console application.&lt;br /&gt;
      \build                       # Files/scripts used to build the console tic-tac-toe game.&lt;br /&gt;
        \config                    # Contains all CMake build files.&lt;br /&gt;
          CMakeLists.txt           # The CMake config file for the overall application.&lt;br /&gt;
          \tic_tac_toe_console     # Contains CMake build files for the main executable.&lt;br /&gt;
            \CMakeLists.txt        # The CMake config file for the executable.&lt;br /&gt;
        \posix                     # Contains scripts to build on POSIX systems.&lt;br /&gt;
          \build.sh                # Script used to build the application.&lt;br /&gt;
          \run_cmake.sh            # Script used to produce the make/build files.&lt;br /&gt;
          \set_env.sh              # Script defining the environment variables.&lt;br /&gt;
          \version.sh              # Script that produces the VERSION stamped header file.&lt;br /&gt;
        \windows                   # Contains scripts to build on Windows.&lt;br /&gt;
          \build.bat               # Script used to build the application.&lt;br /&gt;
          \run_cmake.bat           # Script used to produce the VS solution.&lt;br /&gt;
          \set_env.bat             # Script defining environment variables.&lt;br /&gt;
          \version.bat             # Script that produces the VERSION stamped header file.&lt;br /&gt;
      \source                      # Contains the C++ source files.&lt;br /&gt;
        \tic_tac_toe_console       # Contains the file defining the main function.&lt;br /&gt;
          \main.cpp                # Defines the main function.&lt;br /&gt;
        \source_dir_a              # Contains additional source files specific the console.&lt;br /&gt;
          \source_a.cpp            # C++ source code files.&lt;br /&gt;
          \source_b.cpp&lt;br /&gt;
          \source_c.cpp&lt;br /&gt;
        \source_dir_b              # Contains additional source files specific the console.&lt;br /&gt;
          \source_d.cpp&lt;br /&gt;
          \source_e.cpp&lt;br /&gt;
          \source_f.cpp&lt;br /&gt;
    \tic_tac_toe_ui                # Contains a GUI version of tic-tac-toe.&lt;br /&gt;
      \...                         # The structure is similar to the console application.&lt;br /&gt;
  \build                           # Contains build scripts to build the entire project.&lt;br /&gt;
    \posix                         # Contains scripts to build on POSIX systems.&lt;br /&gt;
      \build.sh                    # Builds all libraries and applications.&lt;br /&gt;
      \local_build.sh              # A helper script containing common build functions.&lt;br /&gt;
      \run_cmake.sh                # Produces all project make/build files.&lt;br /&gt;
      \setup.sh                    # Installs all third party dependencies.&lt;br /&gt;
    \windows                       # Contains scripts to build on Windows.&lt;br /&gt;
      \build.bat                   # Builds all libraries and applications.&lt;br /&gt;
      \run_cmake.bat               # Produces all VS solutions.&lt;br /&gt;
      \setup.bat                   # Installs all third party dependencies.&lt;br /&gt;
  \library                         # Contains the common library code.&lt;br /&gt;
    \build                         # Files/script used to build the library.&lt;br /&gt;
      \config                      # Contains all CMake build files.&lt;br /&gt;
        \CMakeLists.txt            # The CMake config file for the library.&lt;br /&gt;
        \dir_a                     # Contains CMake build files for library component A.&lt;br /&gt;
          \CMakeLists.txt          # The CMake config file to build component A and unit tests.&lt;br /&gt;
        \dir_b                     # Contains CMake build files for library component B.&lt;br /&gt;
          \CMakeLists.txt          # The CMake config file to build component B and unit tests.&lt;br /&gt;
      \posix                       # Contains scripts to build on POSIX systems.&lt;br /&gt;
        \build.sh                  # Script used to build the library.&lt;br /&gt;
        \run_cmake.sh              # Script used to produce make/build files.&lt;br /&gt;
        \set_env.sh                # Script defining the environment variables.&lt;br /&gt;
      \windows                     # Contains scripts to build on Windows.&lt;br /&gt;
        \build.bat                 # Script to build the library.&lt;br /&gt;
        \run_cmake.bat             # Script to produce the VS solution.&lt;br /&gt;
        \set_env.bat               # Script defining the environment variables.&lt;br /&gt;
    \include                       # Contains the library header files (.hpp)&lt;br /&gt;
      \tic_tac_toe&lt;br /&gt;
        \tic_tac_toe               # Contains the top-most generic library header files.&lt;br /&gt;
          \tic_tac_toe.hpp         # Header file containing generic forward declarations.&lt;br /&gt;
        \dir_a                     # Contains header files for library component A.&lt;br /&gt;
          \a.hpp                   # Header file containing forward declarations for component A.&lt;br /&gt;
          \a_header_1.hpp          # Header file for library component A.&lt;br /&gt;
          \a_header_2.hpp&lt;br /&gt;
          \a_header_3.hpp&lt;br /&gt;
        \dir_b&lt;br /&gt;
          \b.hpp                   # Header file containing forward declarations for component B.&lt;br /&gt;
          \b_header_1.hpp          # Contains header files for library component B.&lt;br /&gt;
          \b_header_2.hpp&lt;br /&gt;
          \b_header_3.hpp&lt;br /&gt;
    \source                        # Contains the library source files (.cpp)&lt;br /&gt;
      \tic_tac_toe                 # Dummy directory for the overall library.&lt;br /&gt;
        \dummy.cpp                 # Dummy source code file.&lt;br /&gt;
      \dir_a                       # Dummy directory for library component A.&lt;br /&gt;
        \dummy.cpp                 # Dummy source file.&lt;br /&gt;
      \dir_a_tester                # Contains unit tests for library component A.&lt;br /&gt;
        \a_header_1_tester.cpp     # Contains unit tests for definitions in a_header_1.hpp&lt;br /&gt;
        \a_header_2_tester.cpp&lt;br /&gt;
        \a_header_3_tester.cpp&lt;br /&gt;
        \main.cpp                  # The entry point for component A unit tests.&lt;br /&gt;
      \dir_b                       # Dummy directory for library component B.&lt;br /&gt;
        \dummy.cpp                 # Dummy source file.&lt;br /&gt;
      \dir_b_tester                # Contains unit tests for library component B.&lt;br /&gt;
        \b_header_1_tester.cpp     # Contains unit tests for definitions in b_header_a.hpp&lt;br /&gt;
        \b_header_2_tester.cpp&lt;br /&gt;
        \b_header_3_tester.cpp&lt;br /&gt;
        \main.cpp                  # The entry point for component B unit tests.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An example of the above directory structure containing a basic skeletal implementation of all files can be found here: https://github.com/spiretrading/tic_tac_toe&lt;br /&gt;
&lt;br /&gt;
=Header File Structure=&lt;br /&gt;
&lt;br /&gt;
==Include Guard==&lt;br /&gt;
Header files are structured first with an [https://en.wikipedia.org/wiki/Include_guard include guard] defined using capital letter snake case whose name consists of the project name appended to the directory name and finally the file name itself. As a note, all files end with a single new line character.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
#ifndef CPP_CHAT_SERVER_HPP&lt;br /&gt;
#define CPP_CHAT_SERVER_HPP&lt;br /&gt;
  ...&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Include Directives==&lt;br /&gt;
Next come the list of #include directives. Include files are ordered based on their category where the first category is standard C++ header files, the second category is external dependency header files, and finally the third category is project header files. Both standard and external dependency header files use angle brackets (#include &amp;lt;...&amp;gt;) and local project header files use quotes (#include &amp;quot;...&amp;quot;). Within each category files are listed in alphabetical order.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
#include &amp;lt;tuple&amp;gt;&lt;br /&gt;
#include &amp;lt;vector&amp;gt;&lt;br /&gt;
#include &amp;lt;boost/noncopyable.hpp&amp;gt;&lt;br /&gt;
#include &amp;quot;cpp_chat/cpp_chat.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;cpp_chat/definitions.hpp&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Namespaces==&lt;br /&gt;
After include directives the project's namespace is defined. All declarations and definitions must be contained within a namespace so as to avoid polluting the global namespace. Namespace definitions should be preceded by one single new line except when immediately following a namespace definition. The top level namespace is named after the project, and sub-namespaces may be used (although they should be used very sparingly).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
namespace cpp_chat {&lt;br /&gt;
namespace sub_chat_a {&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
namespace sub_chat_b {&lt;br /&gt;
namespace sub_sub_chat_a {&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
namespace cpp_chat_extra {&lt;br /&gt;
  ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One situation where nested namespaces are welcome and encouraged are for implementation details that do not form part of the namespace's public interface. These definitions are put in a nested namespace called ''details'' and go into a file of their own whose name contains the suffix ''details''. For example if the ''cpp_chat_server.hpp'' contains implementation details, then they should be included in the file ''cpp_chat_server_details.hpp'' and the definitions should go into the namespace ''cpp_chat::details''.&lt;br /&gt;
&lt;br /&gt;
=Layout=&lt;br /&gt;
&lt;br /&gt;
==Indentation==&lt;br /&gt;
Code is indented using 2 spaces per level, tabs are not permitted.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
int factorial(int n) {&lt;br /&gt;
  if(n == 0) {&lt;br /&gt;
    return 1;&lt;br /&gt;
  }&lt;br /&gt;
  return n * factorial(n - 1);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Line Structure==&lt;br /&gt;
Lines are limited to 80 characters. Exceptions to this rule are long include files and long string literals where breaking up the literal into multiple lines is not possible. In order to break up long statements into multiple lines the following rules are used:&lt;br /&gt;
&lt;br /&gt;
* Break the line at a comma, operator or opening bracket.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// Correct, line break at comma.&lt;br /&gt;
f(a, ..., b,&lt;br /&gt;
  c, ..., d);&lt;br /&gt;
&lt;br /&gt;
// Incorrect, line break after expression.&lt;br /&gt;
f(a, ..., b&lt;br /&gt;
  , c, ..., d);&lt;br /&gt;
&lt;br /&gt;
// Correct, line break after operator.&lt;br /&gt;
a + ... + b +&lt;br /&gt;
  c + ... + d;&lt;br /&gt;
&lt;br /&gt;
// Incorrect, line break after expression.&lt;br /&gt;
a + ... + b&lt;br /&gt;
  + c + ... + d;&lt;br /&gt;
&lt;br /&gt;
// Correct, line break after opening bracket.&lt;br /&gt;
f(&lt;br /&gt;
  a, ..., b, c, ..., d);&lt;br /&gt;
&lt;br /&gt;
// Incorrect, line break after function name.&lt;br /&gt;
f&lt;br /&gt;
  (a, ..., b, c, ..., d);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* For statements that begin new blocks of code (such as if/while/class...), in order to avoid confusing the line continuation with the code block, the line continuation is indented two extra levels. For example consider the following snippet of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
// Incorrect.&lt;br /&gt;
if(condition_a &amp;amp;&amp;amp; condition_b &amp;amp;&amp;amp; ... &amp;amp;&amp;amp;&lt;br /&gt;
  condition_c) {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;meow&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The line continuation on line 2 clashes with the code block on line 3. To avoid this clash the above code is indented as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
// Correct.&lt;br /&gt;
if(condition_a &amp;amp;&amp;amp; condition_b &amp;amp;&amp;amp; ... &amp;amp;&amp;amp;&lt;br /&gt;
    condition_c) {&lt;br /&gt;
  std::cout &amp;lt;&amp;lt; &amp;quot;meow&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The extra level of indentation in the line continuation makes it clear where the condition ends and the code block begins.&lt;br /&gt;
&lt;br /&gt;
==Braces==&lt;br /&gt;
&lt;br /&gt;
Braces are placed using a variant of the [http://wiki.c2.com/?OneTrueBraceStyle OTBS style]. The opening brace is placed on the same line as the declaring statement with one single space preceding it, and the closing brace is placed on a line of its own at the same level of indentation as the declaring statement. For if statements, the else/else if is placed on the same line as the closing brace. For do/while loops, the while is placed on the same line as the closing brace.&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
// Correct.&lt;br /&gt;
if(&amp;lt;cond&amp;gt;) {&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
} else {&lt;br /&gt;
  &amp;lt;default&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Correct.&lt;br /&gt;
do {&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
} while(&amp;lt;cond&amp;gt;);&lt;br /&gt;
&lt;br /&gt;
// Incorrect.&lt;br /&gt;
if(&amp;lt;cond&amp;gt;)&lt;br /&gt;
{&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
  &amp;lt;default&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
// Incorrect.&lt;br /&gt;
do&lt;br /&gt;
{&lt;br /&gt;
  &amp;lt;body&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
while(&amp;lt;cond&amp;gt;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Spacing==&lt;br /&gt;
&lt;br /&gt;
The following are correct use cases for white spaces:&lt;br /&gt;
&lt;br /&gt;
* Used for indentation.&lt;br /&gt;
* Used to surround binary operations.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
// Correct.&lt;br /&gt;
auto x = a + b;&lt;br /&gt;
auto y = 5;&lt;br /&gt;
&lt;br /&gt;
//! Incorrect&lt;br /&gt;
auto x = a+b;&lt;br /&gt;
auto y=5;&lt;br /&gt;
auto z= 5;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* One space is placed after a comma.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
// Correct.&lt;br /&gt;
f(1, 2);&lt;br /&gt;
int g(int a, int b);&lt;br /&gt;
&lt;br /&gt;
//! Incorrect&lt;br /&gt;
f(1,2);&lt;br /&gt;
int g(int a,int b);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Syntax=&lt;br /&gt;
&lt;br /&gt;
==Function Definitions==&lt;br /&gt;
&lt;br /&gt;
Functions declared and defined in header files are formatted as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
inline int f() {&lt;br /&gt;
  ...&lt;br /&gt;
  return 123;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
template&amp;lt;typename T&amp;gt;&lt;br /&gt;
bool g() {&lt;br /&gt;
  ...&lt;br /&gt;
  return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is they are declared as inline unless they are function templates in which case the inline specified is omitted.&lt;br /&gt;
&lt;br /&gt;
==Variable Declarations==&lt;br /&gt;
&lt;br /&gt;
Variables are declared so that only one variable is declared per line, the type of the variable should [https://herbsutter.com/2013/08/12/gotw-94-solution-aaa-style-almost-always-auto/ almost always use auto], and variables should almost always be initialized.&lt;br /&gt;
&lt;br /&gt;
Examples of simple declarations:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
auto x = 5;&lt;br /&gt;
auto y = a + b;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For complex initialization of values, use an [https://en.wikipedia.org/wiki/Immediately-invoked_function_expression immediately invoked lambda expression] as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
auto value = [&amp;amp;] {&lt;br /&gt;
  if(condition) {&lt;br /&gt;
    return 123;&lt;br /&gt;
  }&lt;br /&gt;
  return 321;&lt;br /&gt;
}();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Additional References=&lt;br /&gt;
&lt;br /&gt;
The bulk of this style guide focuses on syntax rather than good programming practices. The following list are reference materials (both online and published) for best practices on writing portable, efficient, and clean C++ code:&lt;br /&gt;
&lt;br /&gt;
* S. Meyers, ''Effective Modern C++''. 2014&lt;br /&gt;
* B. Stroustrup ''The C++ Programming Language (4th Edition)''. 2013&lt;br /&gt;
* [https://github.com/isocpp/CppCoreGuidelines Cpp Core Guidelines]&lt;br /&gt;
* [https://isocpp.org/ Standard C++ Blog]&lt;br /&gt;
* [https://cppcon.org/ CppCon - The C++ Conference]&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Query&amp;diff=3</id>
		<title>Query</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Query&amp;diff=3"/>
		<updated>2018-01-21T22:52:56Z</updated>

		<summary type="html">&lt;p&gt;Kamal: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Beam provides a series of classes to query historical and real time streaming data along a wide range of search criteria. It is one of the core APIs provided by Beam and used extensively in Spire to search through and disseminate market data and order executions.&lt;br /&gt;
&lt;br /&gt;
==Structure==&lt;br /&gt;
Much of the data stored by Spire is in the form of a time series. The data is grouped together based on an index, for example time and sales data is indexed by its ticker symbol, order's are indexed by the account the order belongs to etc... For every item there is both a timestamp and a sequence number associated with it (to identify which data was published first in the event that two items have the same timestamp).&lt;br /&gt;
&lt;br /&gt;
The most common type of query used in Spire to search through a time series is defined by the Beam::Queries::BasicQuery class. It consists of five components that are used to fully specify the type of data that is to be retrieved. Those five components are described in detail as follows:&lt;br /&gt;
&lt;br /&gt;
===Index===&lt;br /&gt;
Every data item to query over must be associated with a single index. Specifying the value of the index to query over is defined by the class Beam::Queries::IndexedQuery.&lt;br /&gt;
&lt;br /&gt;
===Range===&lt;br /&gt;
This component is defined by the class Beam::Queries::RangedIndex and it specifies the time range to search through as well as whether the query is strictly for historical data, real time data, or both. The class Beam::Queries::Range defines the semantics of a range and consists of a start value and an end value, both of which can be either a timestamp or a sequence number. Sequence numbers are defined by the class Beam::Queries::Sequence and it contains two special values which control the behavior of a query: LAST and PRESENT.&lt;br /&gt;
&lt;br /&gt;
If the end of a range is specified to be PRESENT then the query will return all matching values that are currently stored in the database. If the end of a range is specified to be LAST or +infinity then in addition to returning all currently matching values, the query will also return matching values published in real time as they arrive.&lt;br /&gt;
&lt;br /&gt;
Any other value used to mark the end of a range results in a strictly historical data query, even if the value denotes some point in the future.&lt;br /&gt;
&lt;br /&gt;
===Snapshot limit===&lt;br /&gt;
This specifies the maximusm number of historical data items to retrieve. This is typically used to prevent a query from returning too much data. The class Beam::Queries::SnapshotLimit contains two values, the size of the limit and the type of the limit. The size controls the maximum number of historical data items are returned by a query (with the special value of UNLIMITED if every value should be returned), as well as the type of snapshot. The type dictates whether items should be returned from the beginning of the series or the end of the series (the HEAD and TAIL respectively).&lt;br /&gt;
&lt;br /&gt;
For example to query for the very last item currently stored in a time series, one can use a range of [FIRST, PRESENT] and a snapshot limit whose type is TAIL and whose size is 1. Alternatively to query for the first 10 values in a time series one would use a range of [FIRST, PRESENT] and a snapshot limit with type HEAD and size 10.&lt;br /&gt;
&lt;br /&gt;
The class Beam::Queries::SnapshotLimitedQuery is the component used to indicate what the snapshot limit of a query should be. By default, this class specifies that no values are to be returned (its size is 0). This is because one is expected to be explicit about how much data is desired. The special value Beam::Queries::SnapshotLimit::Unlimited() can be used to explicitly indicate that there is no limit on how much data should be returned, however, it should be noted that the database engine handling the request may impose limits of its own regarding the maximum size of a snapshot.&lt;br /&gt;
&lt;br /&gt;
===Interruption policy===&lt;br /&gt;
When querying for real time data it is possible for the query to get interrupted, usually due to a disconnection. This component, defined by Beam::Queries::InterruptableQuery, specifies what action should be taken in the event of such an interruption. The possible recovery options are defined by the enumerator Beam::Queries::InterruptionPolicy as follows:&lt;br /&gt;
&lt;br /&gt;
RECOVER_DATA, the query should attempt to re-establish a connection to the database and recover any data that was published during the time that the query was interrupted.&lt;br /&gt;
IGNORE_CONTINUE, the query should attempt to re-establish a connection to the database but ignore any data that was published during the time that the query was interrupted. This is usually desirable when only live, real time data is desired as this option will omit any stale data published during the interruption.&lt;br /&gt;
BREAK_QUERY, the query should abort, indicating an exception. This is the default interruption policy.&lt;br /&gt;
&lt;br /&gt;
===Filter===&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
An example of a query for historical data might be to retrieve the first 1000 time and sales for MSFT.NSDQ from August 11th, 2016 to August 12th, 2016.&lt;br /&gt;
&lt;br /&gt;
===C++===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=c++ line=line&amp;gt;&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;quot;Nexus/MarketDataService/SecurityMarketDataQuery.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;Nexus/ServiceClients/ApplicationServiceClients.hpp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Beam::Network::SocketThreadPool socketThreadPool;&lt;br /&gt;
  Beam::Threading::TimerThreadPool timerThreadPool;&lt;br /&gt;
&lt;br /&gt;
  // Connect to the service.&lt;br /&gt;
  Nexus::ApplicationServiceClients serviceClients{&lt;br /&gt;
    Beam::Network::IpAddress{&amp;quot;127.0.0.1&amp;quot;, 20000}, &amp;quot;username&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;, Beam::Ref(socketThreadPool), Beam::Ref(timerThreadPool)};&lt;br /&gt;
  serviceClients.Open();&lt;br /&gt;
  auto&amp;amp; marketDataClient = serviceClients.GetMarketDataClient();&lt;br /&gt;
&lt;br /&gt;
  // Build the query.&lt;br /&gt;
  auto query = Nexus::MarketDataService::SecurityMarketDataQuery();&lt;br /&gt;
  query.SetIndex(Nexus::ParseSecurity(&amp;quot;MSFT.NSDQ&amp;quot;));&lt;br /&gt;
  query.SetRange(Beam::TimeService::ToUtcTime(&lt;br /&gt;
    boost::posix_time::ptime{boost::gregorian::date{2016 , 8, 11}}),&lt;br /&gt;
    Beam::TimeService::ToUtcTime(&lt;br /&gt;
    boost::posix_time::ptime{boost::gregorian::date{2016, 8, 12}}));&lt;br /&gt;
  query.SetSnapshotLimit(Beam::Queries::SnapshotLimit::Type::HEAD, 1000);&lt;br /&gt;
&lt;br /&gt;
  // Build the Queue to store the results.&lt;br /&gt;
  auto queue = std::make_shared&amp;lt;Beam::Queue&amp;lt;Nexus::TimeAndSale&amp;gt;&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
  // Submit the query to the market data service.&lt;br /&gt;
  marketDataClient.QueryTimeAndSales(query, queue);&lt;br /&gt;
&lt;br /&gt;
  // Print the results&lt;br /&gt;
  try {&lt;br /&gt;
    while(true) {&lt;br /&gt;
      std::cout &amp;lt;&amp;lt; queue-&amp;gt;Top().m_price &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
      queue-&amp;gt;Pop();&lt;br /&gt;
    }&lt;br /&gt;
  } catch(const Beam::PipeBrokenException&amp;amp;) {}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=python line=line&amp;gt;&lt;br /&gt;
import beam&lt;br /&gt;
import nexus&lt;br /&gt;
import datetime&lt;br /&gt;
&lt;br /&gt;
# Connect to the service.&lt;br /&gt;
service_clients = nexus.ApplicationServiceClients(&lt;br /&gt;
  beam.network.IpAddress('127.0.0.1', 20000),&lt;br /&gt;
  'username', 'password')&lt;br /&gt;
&lt;br /&gt;
service_clients.open()&lt;br /&gt;
market_data_client = service_clients.get_market_data_client()&lt;br /&gt;
&lt;br /&gt;
# Build the query.&lt;br /&gt;
query = nexus.market_data_service.SecurityMarketDataQuery()&lt;br /&gt;
query.index = nexus.parse_security('MSFT.NSDQ')&lt;br /&gt;
query.range = beam.queries.Range(beam.time_service.to_utc_time(&lt;br /&gt;
  datetime.datetime(2016, 8, 11)), beam.time_service.to_utc_time(&lt;br /&gt;
  datetime.datetime(2016, 8, 12)))&lt;br /&gt;
query.snapshot_limit = beam.queries.SnapshotLimit(&lt;br /&gt;
  beam.queries.SnapshotLimit.Type.HEAD, 1000)&lt;br /&gt;
&lt;br /&gt;
# Build the Queue to store the results.&lt;br /&gt;
queue = beam.Queue()&lt;br /&gt;
&lt;br /&gt;
# Submit the query to the market data service.&lt;br /&gt;
market_data_client.query_time_and_sales(query, queue)&lt;br /&gt;
&lt;br /&gt;
# Print the results&lt;br /&gt;
try:&lt;br /&gt;
  while True:&lt;br /&gt;
    print queue.top().price&lt;br /&gt;
    queue.pop()&lt;br /&gt;
except:&lt;br /&gt;
  pass&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Query&amp;diff=2</id>
		<title>Query</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Query&amp;diff=2"/>
		<updated>2018-01-21T22:22:35Z</updated>

		<summary type="html">&lt;p&gt;Kamal: Created page with &amp;quot;Beam provides a series of classes to query historical and real time streaming data along a wide range of search criteria. It is one of the core APIs provided by Beam and used...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Beam provides a series of classes to query historical and real time streaming data along a wide range of search criteria. It is one of the core APIs provided by Beam and used extensively in Spire to search through and disseminate market data and order executions.&lt;br /&gt;
&lt;br /&gt;
==Structure==&lt;br /&gt;
Much of the data stored by Spire is in the form of a time series. The data is grouped together based on an index, for example time and sales data is indexed by its ticker symbol, order's are indexed by the account the order belongs to etc... For every item there is both a timestamp and a sequence number associated with it (to identify which data was published first in the event that two items have the same timestamp).&lt;br /&gt;
&lt;br /&gt;
The most common type of query used in Spire to search through a time series is defined by the Beam::Queries::BasicQuery class. It consists of five components that are used to fully specify the type of data that is to be retrieved. Those five components are described in detail as follows:&lt;br /&gt;
&lt;br /&gt;
===Index===&lt;br /&gt;
Every data item to query over must be associated with a single index. Specifying the value of the index to query over is defined by the class Beam::Queries::IndexedQuery.&lt;br /&gt;
&lt;br /&gt;
===Range===&lt;br /&gt;
This component is defined by the class Beam::Queries::RangedIndex and it specifies the time range to search through as well as whether the query is strictly for historical data, real time data, or both. The class Beam::Queries::Range defines the semantics of a range and consists of a start value and an end value, both of which can be either a timestamp or a sequence number. Sequence numbers are defined by the class Beam::Queries::Sequence and it contains two special values which control the behavior of a query: LAST and PRESENT.&lt;br /&gt;
&lt;br /&gt;
If the end of a range is specified to be PRESENT then the query will return all matching values that are currently stored in the database. If the end of a range is specified to be LAST or +infinity then in addition to returning all currently matching values, the query will also return matching values published in real time as they arrive.&lt;br /&gt;
&lt;br /&gt;
Any other value used to mark the end of a range results in a strictly historical data query, even if the value denotes some point in the future.&lt;br /&gt;
&lt;br /&gt;
===Snapshot limit===&lt;br /&gt;
This specifies the maximum number of historical data items to retrieve. This is typically used to prevent a query from returning too much data. The class Beam::Queries::SnapshotLimit contains two values, the size of the limit and the type of the limit. The size controls the maximum number of historical data items are returned by a query (with the special value of UNLIMITED if every value should be returned), as well as the type of snapshot. The type dictates whether items should be returned from the beginning of the series or the end of the series (the HEAD and TAIL respectively).&lt;br /&gt;
&lt;br /&gt;
For example to query for the very last item currently stored in a time series, one can use a range of [FIRST, PRESENT] and a snapshot limit whose type is TAIL and whose size is 1. Alternatively to query for the first 10 values in a time series one would use a range of [FIRST, PRESENT] and a snapshot limit with type HEAD and size 10.&lt;br /&gt;
&lt;br /&gt;
The class Beam::Queries::SnapshotLimitedQuery is the component used to indicate what the snapshot limit of a query should be. By default, this class specifies that no values are to be returned (its size is 0). This is because one is expected to be explicit about how much data is desired. The special value Beam::Queries::SnapshotLimit::Unlimited() can be used to explicitly indicate that there is no limit on how much data should be returned, however, it should be noted that the database engine handling the request may impose limits of its own regarding the maximum size of a snapshot.&lt;br /&gt;
&lt;br /&gt;
===Interruption policy===&lt;br /&gt;
When querying for real time data it is possible for the query to get interrupted, usually due to a disconnection. This component, defined by Beam::Queries::InterruptableQuery, specifies what action should be taken in the event of such an interruption. The possible recovery options are defined by the enumerator Beam::Queries::InterruptionPolicy as follows:&lt;br /&gt;
&lt;br /&gt;
RECOVER_DATA, the query should attempt to re-establish a connection to the database and recover any data that was published during the time that the query was interrupted.&lt;br /&gt;
IGNORE_CONTINUE, the query should attempt to re-establish a connection to the database but ignore any data that was published during the time that the query was interrupted. This is usually desirable when only live, real time data is desired as this option will omit any stale data published during the interruption.&lt;br /&gt;
BREAK_QUERY, the query should abort, indicating an exception. This is the default interruption policy.&lt;br /&gt;
&lt;br /&gt;
===Filter===&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
An example of a query for historical data might be to retrieve the first 1000 time and sales for MSFT.NSDQ from August 11th, 2016 to August 12th, 2016.&lt;br /&gt;
&lt;br /&gt;
===C++===&lt;br /&gt;
#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;quot;Nexus/MarketDataService/SecurityMarketDataQuery.hpp&amp;quot;&lt;br /&gt;
#include &amp;quot;Nexus/ServiceClients/ApplicationServiceClients.hpp&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
  Beam::Network::SocketThreadPool socketThreadPool;&lt;br /&gt;
  Beam::Threading::TimerThreadPool timerThreadPool;&lt;br /&gt;
&lt;br /&gt;
  // Connect to the service.&lt;br /&gt;
  Nexus::ApplicationServiceClients serviceClients{&lt;br /&gt;
    Beam::Network::IpAddress{&amp;quot;127.0.0.1&amp;quot;, 20000}, &amp;quot;username&amp;quot;,&lt;br /&gt;
    &amp;quot;password&amp;quot;, Beam::Ref(socketThreadPool), Beam::Ref(timerThreadPool)};&lt;br /&gt;
  serviceClients.Open();&lt;br /&gt;
  auto&amp;amp; marketDataClient = serviceClients.GetMarketDataClient();&lt;br /&gt;
&lt;br /&gt;
  // Build the query.&lt;br /&gt;
  auto query = Nexus::MarketDataService::SecurityMarketDataQuery();&lt;br /&gt;
  query.SetIndex(Nexus::ParseSecurity(&amp;quot;MSFT.NSDQ&amp;quot;));&lt;br /&gt;
  query.SetRange(Beam::TimeService::ToUtcTime(&lt;br /&gt;
    boost::posix_time::ptime{boost::gregorian::date{2016 , 8, 11}}),&lt;br /&gt;
    Beam::TimeService::ToUtcTime(&lt;br /&gt;
    boost::posix_time::ptime{boost::gregorian::date{2016, 8, 12}}));&lt;br /&gt;
  query.SetSnapshotLimit(Beam::Queries::SnapshotLimit::Type::HEAD, 1000);&lt;br /&gt;
&lt;br /&gt;
  // Build the Queue to store the results.&lt;br /&gt;
  auto queue = std::make_shared&amp;lt;Beam::Queue&amp;lt;Nexus::TimeAndSale&amp;gt;&amp;gt;();&lt;br /&gt;
&lt;br /&gt;
  // Submit the query to the market data service.&lt;br /&gt;
  marketDataClient.QueryTimeAndSales(query, queue);&lt;br /&gt;
&lt;br /&gt;
  // Print the results&lt;br /&gt;
  try {&lt;br /&gt;
    while(true) {&lt;br /&gt;
      std::cout &amp;lt;&amp;lt; queue-&amp;gt;Top().m_price &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
      queue-&amp;gt;Pop();&lt;br /&gt;
    }&lt;br /&gt;
  } catch(const Beam::PipeBrokenException&amp;amp;) {}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
===Python===&lt;br /&gt;
import beam&lt;br /&gt;
import nexus&lt;br /&gt;
import datetime&lt;br /&gt;
&lt;br /&gt;
# Connect to the service.&lt;br /&gt;
service_clients = nexus.ApplicationServiceClients(&lt;br /&gt;
  beam.network.IpAddress('127.0.0.1', 20000),&lt;br /&gt;
  'username', 'password')&lt;br /&gt;
&lt;br /&gt;
service_clients.open()&lt;br /&gt;
market_data_client = service_clients.get_market_data_client()&lt;br /&gt;
&lt;br /&gt;
# Build the query.&lt;br /&gt;
query = nexus.market_data_service.SecurityMarketDataQuery()&lt;br /&gt;
query.index = nexus.parse_security('MSFT.NSDQ')&lt;br /&gt;
query.range = beam.queries.Range(beam.time_service.to_utc_time(&lt;br /&gt;
  datetime.datetime(2016, 8, 11)), beam.time_service.to_utc_time(&lt;br /&gt;
  datetime.datetime(2016, 8, 12)))&lt;br /&gt;
query.snapshot_limit = beam.queries.SnapshotLimit(&lt;br /&gt;
  beam.queries.SnapshotLimit.Type.HEAD, 1000)&lt;br /&gt;
&lt;br /&gt;
# Build the Queue to store the results.&lt;br /&gt;
queue = beam.Queue()&lt;br /&gt;
&lt;br /&gt;
# Submit the query to the market data service.&lt;br /&gt;
market_data_client.query_time_and_sales(query, queue)&lt;br /&gt;
&lt;br /&gt;
# Print the results&lt;br /&gt;
try:&lt;br /&gt;
  while True:&lt;br /&gt;
    print queue.top().price&lt;br /&gt;
    queue.pop()&lt;br /&gt;
except:&lt;br /&gt;
  pass&lt;/div&gt;</summary>
		<author><name>Kamal</name></author>
		
	</entry>
</feed>