Xignite Off-Hours Cache

Cache Service

This application installs as a windows service and runs in the background to build and manage a cache of recent off-hours stock values that are not otherwise available from the Xignite API. 

The cache is intended to keep data to service requests for the current day up to the previous 24 hours. It requests off-hours values from the Xignite API during off-hours only.

The cache service actively checks the current values of the requested stocks and if there is new data it records it as a value in it's data store. However if a stock is not active there will be no data available for that stock to display in a chart. The more active a stock is the more data points will be accumulated and the more data there will be to display on a chart.

Server Time Note

Please note that it is important that the time on the computer that the service is installed on be correct. The service only actively checks for off-hours data during off-hours. During market hours and at times when no off-hours trading occurs the service only checks the time and then continues waiting for the off-hours market to begin. For details on what times are considered off-hours see the Off-Hours Defined section.

Installation

A installer app is provided that installs and starts the service automatically. If it is uninstalled the service will be stopped and removed. You can see the service running in the Windows Services list.

This is what the properties page for the service will look like. 

Removal

If you need to remove the cache service you can easily do this using the Control Panel - Uninstall Programs option and remove the Xignite Cache.

Settings

Xignite API Key

Note that the cache does require a valid Xignite API key to run. The Xignite Finance Player Client app will pass on the API key it uses to the cache service so that they both use the same valid key.

Other Settings

Some other settings are also saved in a settings file in the ProgramData folder. These include the service hosted IP/name address, port, and run delay.

📁 C:\ProgramData\Bannister Lake\Xignite Cache

Changes to the settings file will take effect the next time the service is started.

Logs

The app will write logs for each day it is running to the ProgramData folder: 

📁 C:\ProgramData\Bannister Lake\Xignite Cache\logs

Performance and Debug log messages can be enabled and disabled using the Xignite Finance Player Client

Automatic Backup

The service holds the active cache data and stock list in memory for quick retrieval while it's running.

The list of stocks and current cache data are also occasionally saved to a backup file in the ProgramData folder. 

📁 C:\ProgramData\Bannister Lake\Xignite Cache\cache.xml
📁 C:\ProgramData\Bannister Lake\Xignite Cache\stocks.txt

This allows the service to be stopped and restarted without losing data that had already been accumulated. However if the service is stopped during off-hours you may miss out on stock values that occur while the service is stopped.

When?

The following describes when the service will save its active stock list and data cache to files:

Stock List

  • Service shutdown

  • When off-hours end

Data Cache

  • Service shutdown

  • After every 5 xignite api calls - it saves if new data has been received

  • When off-hours end

Stock List

The list of stocks that are selected for off-hours caching are saved to the 📄 stocks.txt file in this folder both when the service is shutting down and when off-hours end:

📁 C:\ProgramData\Bannister Lake\Xignite Cache

If already you have a list of stocks that you want to use from another machine or say a copy of the ticker stock list - you can manually edit this file and when the service is started - it will read the list and start caching all stocks in the list. See details in the next section:

Manually Edit the Stock List

To manually edit the list of symbols in the data file 📄 stocks.txt

  1. Create a copy of the file

  2. Edit it by adding and removing symbols as desired - one symbol per line

  3. Stop the cache service (it will save it's current list to the data file)

  4. Overwrite the existing data file with your modified copy

  5. Restart the cache service

  6. The cache app will start with the new list of stocks

  7. Re-open the Cache stocks window to see the updated list in the client app

Command Line Control

The service can be stopped and started using windows command line statements:

Use CMD prompt with Administrator rights
:: STOP service net stop BLXigniteCache :: START service net start BLXigniteCache

Off-Hours Defined

The off-hours are currently defined based on the documentation from the Xignite API. (verified Feb 18, 2021 / version 7.0.0)

https://www.xignite.com/product/BATS-real-time-stock-quotes-data#/DeveloperResources/request/GetExtendedQuotes

 Data coverage for these output values include Pre-Market hours 4:00 a.m. to 9:30 a.m. EST and After Market hours 4:00 p.m. to 8:00 p.m. EST