<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.spiretrading.com/index.php?action=history&amp;feed=atom&amp;title=Definitions_Server</id>
	<title>Definitions Server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.spiretrading.com/index.php?action=history&amp;feed=atom&amp;title=Definitions_Server"/>
	<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Definitions_Server&amp;action=history"/>
	<updated>2026-04-07T12:35:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.spiretrading.com/index.php?title=Definitions_Server&amp;diff=238&amp;oldid=prev</id>
		<title>Kamal: Created page with &quot;= Definitions Server = The Definitions Server provides centralized reference data for the trading platform. It disseminates system-wide definitions including country codes, cu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.spiretrading.com/index.php?title=Definitions_Server&amp;diff=238&amp;oldid=prev"/>
		<updated>2025-12-01T22:03:44Z</updated>

		<summary type="html">&lt;p&gt;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;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&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>
</feed>