The DEMOFEED application is a simplified data server. It supports multiple clients on a single computer, with updates shared between all clients.

The feed is not designed to be scalable, extensible or robust. It is designed only for demonstration purposes.

Commands

The following commands are supported:

Command Description
GET Gets a single data item (which may be scalar or array)
SET Sets a single data item
FIND Gets a list of securities whose codes match the search string
ADVISE Registers interest in a single data item, so that the client will receive an update message whenever the value changes.
UNADVISE Unregisters interest in a data item, so that update messages for the item are no longer sent to the client.
GET_UPDATES Gets all queued update messages concerning changes to items in which the client has registered interest.
SAVE_DATA Saves all data from the database to a text file
RESTORE_DATA Restores saved data from a text file, optionally clearing all current data

Fields

The feed server contains a small in-memory database of securities. The table below lists the fields available for each security.

ID Name Type Description
0 Code String Unique code for security
1 Name String Name of security
2 Bid Floating-point Latest bid price
3 Ask Floating-point Latest ask price
4 Series Vector of floating-point Series of traded prices
5 Latency Integer The number of milliseconds the feed should delay before responding to GET commands for the security.
6 Dictionary List Data dictionary. (This is only available if the security code is "!".)

API

The client API for the feed consists of a single class, FeedConnection, which supports two-way communication with the feed. The application and its client API are self-contained, and do not rely in the XLL+ run-time libraries.

The methods are summarized below.

int Connect();
Connects to the data feed.
int Disconnect();
Disconnects from the data feed.
int Get(const wchar_t* pszSecurityCode, int nPropertyId, wstring& strValue, timestamp_type& tsValue);
Gets a single value, in text format, from the data feed.
int Set(const wchar_t* pszSecurityCode, int nPropertyId, const wchar_t* pszValue);
Publishes a single value, in text format, to the data feed.
int Find(const wchar_t* pszSecurityCodeSearch, std::vector<std::wstring>& astrCodes);
Gets a list of securities whose codes match the search string
int Advise(const wchar_t* pszSecurityCode, int nPropertyId);
Registers interest in a single data item, so that the client will receive an update message whenever the value changes.
int Unadvise(const wchar_t* pszSecurityCode, int nPropertyId);
Unregisters interest in a data item, so that update messages for the item are no longer sent to the client.
int StartListener();
Starts a background thread to listen for updates. This thread will call the OnGetUpdates() virtual method whenever an update is received to an item for which Advise() has been called.
void StopListener();
Stops the listener thread. Updates will no longer be passed to OnGetUpdates().
virtual void OnGetUpdates(const std::vector<FeedMessage>& updates);
Called by the listener thread when updates to items of interest are received.

Database

The demo feed server loads an initial data set from a data file if one is specified on the command line. If no data file is specified, or if the specified data file is not found, the following data-set is loaded:

Code Name Bid Ask Series Latency
MGC MegaCorp 100 101.5 99.0;99.5;101.0;100.0;100.25 0
CD Cheesedale 50 52 49.0;49.5;51.0;50.0;50.25 0

Usage

To run the data server, run it at the command-line, e.g.:

DATAFEED

Optionally, specify a data file in the same directory as the file DATAFEED.EXE:

DATAFEED -o data2.txt

You can specify the level of information written to the command line using the –l option. The level should be ERROR, WARNING, INFO, DEBUG or TRACE.

DATAFEED -l INFO

To stop the data server, just type Control+C at the command-line.

See Also