Contents
- Introduction
- Overview
- Information Request Messages
- Action Messages
- Real-time File Update Messages
- Real-time Last Record Update
Messages
Introduction
Tradeworks Software offers several QCollector data retrieval
products, with each product built for a specific market data feed
service. All QCollector programs support the QCollector Data
Interface described in this document. The QCollector Data
Interface allows other Windows applications to interface with
QCollector and receive notifications of QCollector events such as
data file updates. Other applications can also instruct QCollector
to perform specific actions such as retrieving data for a security
or keeping a specific security's data file updated in
real-time.
QCollector's data files make up a very simple flat-file
database your applications can freely access in real-time or
offline, to chart, process, and analyze market data. Using the
QCollector Data Interface is much simpler than developing your
own application database to store and access data from the
market data feeds APIs you want to support. Users only need
QCollector and a subscription to the market data feed they
want to access.
Overview
The QCollector Data Interface uses Windows messages and the Windows Global Atom Table to share information
between QCollector and other Windows programs. This is a simple,
efficient, and reliable way for your application to communicate
with QCollector. Atoms are references to data strings which are
used to pass values between QCollector and other programs.
There are three groups of messages in the QCollector Data
Interface:
- Information Requests - Your application can query
QCollector for information about QCollector portfolios, the items
in the portfolios, and the items being updated in real-time in the
QCollector timed udpates list.
- Actions - This group of messages allows your application
to instruct QCollector to retrieve data for a symbol, add a symbol
to or remove a symbol from the timed udpates list, or clear all of
the symbols from the timed udpates list.
- File Update Notification Messages - QCollector uses this
group of messages to notify applications when data files have been
updated on a QCollector timed update cycle . Each message will
include information about the individual data files which were
updated such as the symbol associated with the data file and the
data file's fully qualified path and file name. Your application
must subscribe with QCollector to receive File Update Notification
messages, and on receipt of a notification message, would typically
read data from the refreshed data file for use in your program.
- Last Record Update Notification Messages - QCollector
uses this group of messages to send the last record from each data
file that was updated on a QCollector timed update cycle . The
message will include the symbol, interval, file name and the
complete last record (i.e. O,H,L,C,V) from the updated data file.
Your application subscribes with QCollector to receive these Last
Record Update Notification messages, and might typically use these
messages to set and trigger alerts, or perhaps just read the 'Last'
price field to keep a quote sheet updated.
To work with the QCollector Data Interface messages you simply call
the Windows RegisterWindowMessage function passing the text
definition for the message you want to use and then store the
returned value in a variable. This value now defines a Windows
message which you can use in your program.
wm_QCollectorClientDataRequest :=
RegisterWindowMessage('QCOLLECTOR_CLIENT_DATA_REQUEST');
QCollector also registers these messages with Windows. (In this
document the messages making up the QCollector Data Interface are
referred to by the text that is used when the message is registered
with Windows, as in QCOLLECTOR_CLIENT_DATA_REQUEST.)
You only need to register the messages your program will
actually be using.
Note: A simple demo program with Delphi source code
demonstrating all of the message handling described here can be
downloaded from the Developers
page at the Tradeworks Software web site.
Information Request Messages
| |
QCOLLECTOR_CLIENT_PORTFOLIO_LIST_REQUEST -
Send this message to request a list of the QCollector portfolios. When
QCollector receives this message it will save a list of portfolio
information to a data file (see example below) in the QCollector
application data folder. Set LParam to the window handle (HWnd) where
you want the portfolio list request complete message to be sent.
WParam is not used.
When you submit a client data request to QCollector you need
to include the portfolio name or portfolio folder for which the data
request applies. You can retrieve this information with this message.
It isn't necessary to request the portfolio list before every client data
request but if you encounter an error you might want to send this
message to refresh your list because a user could delete or rename
a portfolio.
QCOLLECTOR_PORTFOLIO_LIST_REQUEST_COMPLETE
- QCollector will send this message to the HWnd that requested the
portfolio list. LParam is an Atom holding one string value - the
full path and file name for the portfolio list data file, which
will be located in the local application data folder.
QCollector deletes the Atom when SendMessage returns. On receipt of
this message your application can read the portfolio list file to
get information about QCollector portfolios required for client
data requests.
The data in the portfolio list file saved by QCollector is plain
text with one line for each portfolio formatted as follows:
{QCollector portfolio name}|{('A' or 'M' for Ascii or
MetaStock data format)}|{folder}
Each field value is separated with the vertical bar ("|")
character. An example portfolio list file could be:
My Stocks|A|C:\Data\MyStocks
MetaStock1|M|C:\MsData\MetaStock1
T&S|A|C:\Data\T&S
QCOLLECTOR_CLIENT_PORTFOLIO_ITEMS_REQUEST Send
this message to QCollector to retrieve a list of all items in a
QCollector portfolio. The name or folder path for the QCollector
portfolio you want to read must be set as Atom in WParam. (See
portfolio list request message above to retrieve a list of
QCollector portfolios.) Set LParam to the window handle (HWnd)
where you want the portfolio item list request complete message to
be sent.
When QCollector receives this message it will create a list for
the portfolio items including the symbol, interval, title and data
file name for each item, and save the list to a temp file in the
QCollector application data folder. This list is particularly useful
for Ascii format portfolios because it allows users to select an
item by symbol or title rather than just by file name.
QCOLLECTOR_PORTFOLIO_ITEMS_REQUEST_COMPLETE -
QCollector sends this message to the HWnd that requested the
portfolio items list. LParam is an Atom holding one string value -
the full path and file name for the portfolio item list temp file, which
will be located in the local application data folder.
QCollector deletes the Atom when SendMessage returns.
The data in the portfolio item list file is plain text with one
line for each item formatted as follows:
{symbol}|{(interval)}|{title}|{data file name}|{spare(0)}
- Symbol - for that item.
- Interval - D, W, M, Y for Daily, Weekly, Monthly, and if
applicable, Yearly, or a number for intraday minutes. '0' for time
and sales data items.
- Title - Company name or description for the item.
- Data file name - the data file for the item (no path,
use the portfolio folder).
- Spare - for future use.
Each field value is separated with the vertical bar ("|")
character. An example portfolio item list:
IBM|15|International Business Machines|IBM_15.csv|0
MSFT|1|Microsoft Corporation|MSFT_1.csv|0
ADBE|DAILY|Adobe Systems Incorporated|ADBE_D.csv|0
QCOLLECTOR_CLIENT_REALTIME_SYMBOL_LIST_REQUEST
- Send this message to QCollector to retrieve a list of all items
in the QCollector timed updates list (QCollector timed updates data
files for symbols in on a timed interval.). When QCollector
receives this message it will save the symbol, interval and title
for each item to a file in the QCollector application data folder.
LParam holds the HWnd where you want the real time symbol list
request complete message sent. WParam is not used. Your application
can read the information from this file when it receives the
real-time symbol list request complete message below.
QCOLLECTOR_REALTIME_SYMBOL_LIST_REQUEST_COMPLETE
- QCollector sends this message to the HWnd that requested the
list. LParam is an Atom holding one string value - the full path
and file name for the list data file. QCollector deletes the Atom
when SendMessage returns. On receipt of this message your
application can read the list file to get information about all the
items in the QCollector timed updates list.
The data in the list file saved by QCollector is plain text with
one line for each item formatted as follows:
{symbol}|{interval)}|{title}
Each field value is separated with the vertical bar ("|")
character. For example:
ADBE|5|Adobe Systems Incorporated
INTC|D|Intel Corporation
|
Action Messages
| |
Action messages include client data request messages and
messages to remove items from the timed udpates list.
Client data request messages are sent from your application to
QCollector to retrieve data for a symbol. Each data request must
include a QCollector portfolio name or portfolio folder path, so
you should request the portfolio list (see above) from QCollector
at least once before sending a data request.
When QCollector processes a client data request it will create a new
item in the QCollector portfolio unless an item matching the symbol
and interval (and in the case of Ascii data files, file name) is
found to already exist in that portfolio. If a matching item is
found in the target portfolio QCollector will simply bring the data
file for the existing item up to date and then send the data
request complete message.
When adding a new item to a portfolio, QCollector looks for any
saved default portfolio item properties, and if found, will use them to
create a new item. If the user hasn't saved any default item properties the item will be
added to a portfolio with the default portfolio properties.
Saved default properties can include whether or not to store volume
or open interest in the data file, start and end session times,
etc. In most cases this will not change any essential formatting of
the data in the data files.
QCOLLECTOR_CLIENT_DATA_REQUEST - Send this
message to QCollector to request data for a symbol. WParam must
hold the Atom with the formatted data request string. Set LParam to
the HWnd where you want the data request complete message to be
sent.
The data request string must be formatted as follows, but all on
one line:
{ID string}|{symbol}|{interval}|{days back}|
{collect now (0,1)}|{add to timed updates (0,1)}|{spare(0)}|
{portfolio name or portfolio folder path}
- ID string - user defined. This string will be returned
with the data request complete message. Your application can use
this string value to track multiple data requests if required. Set
to '0' if not required.
- Symbol - submitted to the data feed servers.
- Interval - D, W, M, Y for Daily, Weekly, Monthly, and if
applicable, Yearly, or a number for intraday minutes. Use '0' for
time and sales data items (see note below).
- Days back - calendar days back to start data file. If
zero, then start at beginning of current day.
- Collect now - 1 to collect data for the item
immediately, else 0. If '0' then the item will be added to
QCollector portfolio (if it doesn't already exist) without data
being collected. Items may be added this way when offline.
- Timed updates - 1 to add symbol to timed updates list,
else 0. When '1' the symbol will be added to the timed updates
list. Timed updates can be running, paused, or stopped. If timed
updates are running, the data file for this item will now be
updated in real-time.
- Spare - (0) for future use.
- Portfolio name or portfolio folder path - a new item
will added to the specified QCollector portfolio using the
properties included in the data request.
Each field value is separated with the vertical bar ("|")
character.
If the data request interval is '0' (zero), and the target
portfolio is a time and sales data Ascii portfolio, QCollector will
create a new item in the portofolio if no existing item matches the
data request. If the user has saved default properties for time and
sales data items they will be used when adding the new item to the
portfolio. Otherwise, a new time and sales item for the symbol will
be created that collects trade price and size only.
If the data request uses a non-zero value for the interval, and
the target portfolio is a time and sales portfolio, the data
request will fail.
When sending an Atom to QCollector always use SendMessage, never
PostMessage. QCollector will read the Atom immediately and you
should delete the Atom when SendMessage returns.
Return Values
- Returns 1 if QCollector successfully
received and parsed the message. The data request has been sent to
the servers and your app will receive the data request complete
message when the data is ready.
- Returns -1 if there was a problem with
the format of the submitted request. No data request complete
message will be sent back to your application. Further information
about the problem may be found in the QCollector Event Log.
- Returns 0 if QCollector never received
the message. No data request complete message will be sent back to
your application.
Formatted client data request example 1:
Details: Request daily data for $INDU, going back 100 days. Collect
the data immediately and save in portfolio folder named
"C:\Data\Indexes". Do not add to timed updates list.
0148855|IBM|D|100|1|0|0|C:\Data\Indexes
Formatted client data request example 2:
Details: Request 5 minute intrade data for IBM, going back 10 days.
Collect the data immediately and save in portfolio named "My
Stocks". Add portfolio item to timed updates list.
0|IBM|5|10|1|1|0|My Stocks
QCOLLECTOR_DATA_REQUEST_COMPLETE -
QCollector sends this message to your application when a previously
submitted data request has completed, meaning the data file has
been updated and is ready for reading. LParam is the Atom with
string information for the previous request. WParam is not
used.
The Atom data string will be formatted as follows:
{ID string}|{full path and file name to the data file}
- ID string - user defined, as was set when request was
submitted.
- Full path and file name to the updated data file in the
portfolio folder specified by the client data request.
Example:
014588|C:\Data\Stocks\IBM_5.csv
Note: You should not assume there will be data in the data file,
or even that the data file will exist. A symbol may have been
submitted for which no data was available, such as an expired
futures contract, or a defunct stock symbol, or a symbol for which
the user's account is not enabled. Further information about failed
data requests may be found in the QCollector Event Log.
QCOLLECTOR_CLIENT_REMOVE_REALTIME_SYMBOL_REQUEST
- Send this message to QCollector to have an item removed from the
QCollector timed updates list. WParam must hold the Atom with the
formatted request string. There is no "request complete" message so
LParam is not used. SendMessage will return 1 if the request succeeds.
The request string must be formatted as follows:
{symbol}|{interval}
- Symbol for security
- Interval - D, W, M, Y for Daily, Weekly, Monthly, and if
applicable, Yearly, or a number for intraday minutes. Use 0 for time and sales data items.
When QCollector processes the request it will search through the
items in the timed updates list and remove the first one with a
matching symbol and interval. Timed updates can be running or not
running. (Hint: Get a list of all items in the timed updates list
before sending this request.)
QCOLLECTOR_CLIENT_CLEAR_REALTIME_SYMBOLS -
Send this message to QCollector to clear all items from the
QCollector timed updates list. There is no "request complete"
message; SendMessage will return 1 if the
request succeeds.
|
Real-time File Update Notification Messages
| |
These messages are used to receive notifications when files are
updated with real-time streaming data using the QCollector
Timed Updates feature.
QCOLLECTOR_REGISTER_FOR_FILE_UPDATES - Send
this message to QCollector to register to receive the file update
notification messages. LParam holds the window handle you want
QCollector to send the messages to.
QCOLLECTOR_UNREGISTER_FOR_FILE_UPDATES - Send
this message to QCollector when you no longer want to receive file
update notification messages. LParam holds the window handle to
unregister.
QCOLLECTOR_FILE_UPDATE - After all data files
have been updated on a timed update cycle QCollector will send this
message out once for each file that was updated. LParam is a handle
to a Global Atom that contains info in text format about the file
that was updated. The Atom text string includes the symbol, the
record interval, and the fully qualified path and data file name
for the security that was updated. A comma and a semi-colon are
used as separator characters. Your application can parse this
string to get the separate pieces of information. See the examples
following.
QCOLLECTOR_ALL_FILES_UPDATED - QCollector
sends this message to each registered client just once after all
data files have been updated in the timed update cycle, and after
all individual file update notification messages have been sent.
LParam holds the number of data files that were updated.
Applications must register these four messages with Windows by
calling the RegisterWindowMessage API function. QCollector also
registers these messages with Windows. The example projects show
how this is done.
Example 1: An ASCII format data file named "MSFT_5.CSV" in
folder "C:\Data\Ascii\Stocks\" stores data for symbol "MSFT" in
records with 5 minute bars. When the file is updated on a timed
update by QCollector the text in the global Atom sent by QCollector
will be "MSFT,5;C:\Data\Stocks\MSFT_5.CSV"
Example 2: A MetaStock format data file in a folder named
"C:\Data\MS\Stocks\" stores data for a security with symbol "ADBE".
The data is stored in a file named "F6.dat" and the record interval
is Daily. The text in the global Atom sent by QCollector will be
"ADBE,D;C:\Data\MS\Stocks\F6.dat".
Important! After receiving these messages, do not delete the
Atom by calling GlobalDeleteAtom; QCollector will do that when the
message handling function returns.
|
Real-time Last Record Update Notification Messages
| |
These messages are used to receive notifications when files are
updated with real-time streaming data using the QCollector
Timed Updates feature, and to receive the last record from
each udpated data file.
QCOLLECTOR_REGISTER_FOR_LAST_RECORD_UPDATE -
Sends this message to QCollector to register to receive the last
record update notification messages. LParam holds the window handle
you want QCollector to send the messages to.
QCOLLECTOR_UNREGISTER_FOR_LAST_RECORD_UPDATE -
Send this message to QCollector when you want to stop receiving the
last record update notification messages. LParam holds the window
handle to unregister.
QCOLLECTOR_LAST_RECORD_UPDATE - When
QCollector updates the data files on a timed update cycle it saves
a text string with information about the last data record that was
updated. For all data files this text string begins with the
symbol, the interval, and the data file name (no path) all
delimited with tab characters. For MetaStock format data files the
rest of the string is the date, time, open, high, low, close and
volume values of the last data record with all fields again
delimited by tab characters. For ASCII format data files the rest
of the string is the exact text of the last record in the ASCII
data file which will include whatever delimiter characters are
specified for use in that particular portfolio. This also applies
to advanced time and sales data files.
After all the data files have been updated on the timed update
cycle QCollector sends out one last record update message for each
data file that was updated, to each client registered to receive
the messages. The message LParam is a handle to a Global Atom that
contains the data string the updated file.
Example 4: QCollector updates a data file named "IBM_5.CSV"
storing five minute interval records in comma-separated ASCII
format. The QCOLLECTOR_LAST_RECORD_UPDATE message is sent to
subscribed applications each time the data file is updated on the
timed update cycle. The text extracted from the global Atom sent
with the message could be
"IBM{tab}5{tab}IBM_5.CSV{tab}05/19/2002,10:30:00,112,112.5,111.5,112.25,23500".
Important: For MetaStock format data files the date format used
in the QCOLLECTOR_LAST_RECORD_UPDATE message will be the
ShortDateFormat set in the user's Windows Regional settings. The
time format will always be "hh:mm:ss" without regard to the user's
regional settings. All messages for ASCII format symbols use the
date and time as stored in the last record of the data file. For
all messages the date and time are the date and time for the last
data record updated and not the current date and time. If the
record interval for the data file being updated is Daily or greater
the time will be "00:00:00" and should be ignored. Daily record
intervals will be identified with a "D" in the second field, weekly
will be "W", quarterly will be "Q", yearly will be "Y".
Important: Do not delete the Windows Global Atom by calling
GlobalDeleteAtom; QCollector will do that when the message handling
function returns.
|
You can have QCollector begin running timed udpates when the
program starts up by adding a switch to the command line in the
Windows shortcut properties. See the QCollector Help topic "Command Line"
for instructions.
There are three example projects included with the QCollector
Developer Package which this document is a part of; a Delphi
project, a Visual Basic project, and a Visual C++ project. You can
access these example projects at the Tradeworks
Software web site.
Return to Top
Copyright © 2000-2004 Tradeworks Software
|