QERROR - MSG for 1b -
TIME check on 17x ??
- are we getting ALL the data ????
**loose data on startup - 2k !
split into 4 files - if open after X secs - doit
Fip messages - ditto
redo exchgs to use pTmpo ??

bate codes - left as sigle chrs for now - but also code for multi....

All lines ended with NL
All Exchs mapped to 2-4 chr Code
Delay field is in always so marked as the 3rd field - in mins
Each field separated by a PIPE - looks like the only chr NOT used...
(Exch Code) | (STOX Code) | (delay) | (bate) (data) [opt... | (bate) (data) ]
Still to do
    - actual data conversions....
    - Use their bate codes ??
    stripped the market code for NYSE/AMEX/NASDAQ

;List of Exchange Codes
; * means ALL Market Centres
exchange:0Ba    CANa
exchange:0Bf    FOREX
exchange:0Bm    CANm
exchange:0Bt    CANt

exchange:0D*    NYSE
exchange:0E*    AMEX
exchange:0F*    NASDAQ

; ComStock Service Messages
;exchange:1B     MSG

exchange:13*    CBOT

exchange:16a    SWX
exchange:16h    HK
exchange:16t    OSLO
exchange:16u    STKHM

exchange:17d    AMS
exchange:17g    MIL
exchange:17k    FRK
exchange:17l    LSEl
exchange:17n    LSEn
exchange:17q    MATIF
exchange:17r    PAR
exchange:17s    LSEs
exchange:17u    LSEu

; Timechecks
exchange:1F     TIME

; a - Ask
; b - Bid
; c - Correction
; f - flags
; g - Alert
; i - Incremental Volume
; m - currency
; v - Cumulative Volume
; w - Previous Day's Volume

    actual conversions
        dbl bate numbers have a comma after
    need to have ALL a bate/data before processing..


This program connects to the Comstock server, Logons on, tells the server which
Exchangesand Fields are to be accessed and what needs to be stuffed on the
WatchList. Occasional dump of all or certain fields of particular exchanges
(called Snapshotting Financial Instruments).

Incoming files are dumped into spool/2brouted for 'iproute' to decide where to
send and process. Generally Magazine text file are sent to the editorial box
while financial data is reprocessed and stuffed in a database.

For a list of magazines available plus details of fields, exchanges etc, please
refer to the Comstock documentation. That is a polite way of saying you need
the book!

It uses a parameter file, tables/setup/COMSTOCK, to describe what to setup :
Syntax are :
    ; comment line

    field-separator:    default: pipe '|'

    snap:(name) time:(time) contract:(contract) dest:(dest) [allfields:]
    manual:(name)   contract:(contract)
    fields: (optional) is a series of field names.
        Normally the defaults are reasonable which are :

    name is used for manuals only; for snaps it is for your use.
    time is 4 digit, 24 hour format (ie no dots, colons etc).
        Not used for Manuals.
    contract is any valid contract. Generally this is a all stox for
        an exchange ("S*EX" is S for LSE, *EX meaning all stox)
        If more than one contract is required, use a comma to separate
    allfields: (optional) is to extract ALL data for each stox requested.
        You are NOT advised to do that too often.

    manual:lse  contract:S*EX
    manual:liffe    contract:L*EX

    ; big one of ALL data at 6am
    snap:lse.check  time:0600   contract:S*EX   allfields:
    snap:lse.noon   time:1200   contract:S*EX

Input Parameters (all optional) :
    -s : Comstock Server hostname       default: "cmstk"
    -p : Comstock Server port number        default: 1000
    -P : Sparc port number          default: 9222
    -q : Snapshot NOW queue         default: spool/cmstksnap
    -o : Output queue           default: spool/2brouted
    -v : Print the version number and exit


--The parameter file is read once on startup.

--Only if we are connected, logged on and have finished setup, will we snapshot

--If the Comstock server logs us off - like at 2am every morning - we wait and
try to reconnect automatically.

--Magazines data files are sent to a DU (destination) of ComstockmagABC where
ABC is the first 3 letters of the magazine.

--To trigger manuals, a file with a FILENAME containing a header field of
CM:(name) is stuffed in the cmstksnap queue where name is the same as the
manual name. Eg:
    touch /fip/spool/cmstksnap/#SN:okboys#CM:lse
will trigger a manual of "lse" if one exists in the parameter file.

--Normal Startup sequence is as follows :
    1. Connect to Comstock server
    2. Logon
    3. wait for Comstock system quality messages
    4. Load which fields we want for our snap shots
    5. Load the magazine numbers we want to sample

The FIP log will show:

Thu May  9 02:07:10 ipcmstk !s : Logon ok - Starting Setup 
Thu May  9 02:07:10 ipcmstk !z : Comstock System Message      
Thu May  9 02:07:10 ipcmstk !z : Comstock System Message C3
Thu May  9 02:07:10 ipcmstk !z : Status Feed Status : 0 : Ok
Thu May  9 02:07:11 ipcmstk !z : Status Database Quality : 0 : all Ok
Thu May  9 02:07:13 iproute !i : Comstock   Comstock7679 CTL : Comstocksysmsg 
Thu May  9 02:07:13 iproute !i : Comstock   COMSTOCK7680 CTL : COMSTOCKsysmsg 
Thu May  9 02:07:13 iproute !i : COMSTOCK   COMSTOCK7681 CTL : COMSTOCKsysmsg 
Thu May  9 02:07:23 ipcmstk !z : Load Fields for Shares 
Thu May  9 02:07:23 ipcmstk !z : Command Succeeded 
Thu May  9 02:07:26 ipcmstk !z : Load Magazines requested 
Thu May  9 02:07:26 ipcmstk !z : Command Succeeded 
Thu May  9 02:07:28 ipcmstk !z : Setup Completed successfully 


On the Sparc, we need queues spool/cmstksnap for manual snaps
    plus tables/setup/Comstock for parameter file
    plus tables/route/Comstock for routings
    plus correct destinations in tables/sys/USERS
    For Magazines, check tables/xchg/Comstock2XXX
    For FinInst, check 'ipxcmstk' is also running / in SYSTEM

On the Comstock server, change the hostname, IP address, Port number for the
    plus an entry for each Sparc - IP address and Port number.

(copyright) 2017 and previous years FingerPost Ltd.