TRACE Engine

Document Sample
TRACE Engine Powered By Docstoc
					TRACE Engine Overview




                       Version 1.0

   Last Revised: February 20, 2002
1 Background
Secondary market transactions in eligible fixed income securities are to be sent to the TRACE
system of NASDAQ. For an overview of the interface between the existing trading system of
RSCO and TRACE, please refer to earlier documents TRACE_initial_1.doc and
TRACE_trading_interface_1.doc.
This document describes the functionality of TraceEngine program and also describes in brief,
"how to run" it.


2 Message Flow




_______________________________________________________________________________
Draft Version 1.0    April 16, 2010   Page 2 of 9          6f791470-771d-47b6-bfb1-
2bedfb963644.doc
2.1       Messages from Trading System to NASD
          TIBListener process would capture messages of the given subject and put them in a file.
          TraceEngine would pick up messages from this file. The file name is specified in shell
           init.TraceEngine against shell variable TRACE_TRD_IN_FILE.
          TraceEngine would generate appropriate messages and write to file, the name of which
           is in variable TRACE_SIM_OUT_FILE.
          CTCI Write Client process would pick up messages from here and send it to CTCI Server
           process. CTCI Write Client picks up the file name from the command line parameters.
          CTCI Server would send the messages to NASD Server

2.2       Messages from NASD to Trading System
          CTCI Server would receive the responses received from NASD Server and hand it over
           to CTCI Read Client process.
          CTCI Read Client would put them in a file specified on the command line while initiating
           the process.
          TraceEngine looks as shell variable TRACE_SIM_IN_FILE for name of the file containing
           the responses from NASD.
          Whenever appropriate, TraceEngine would format the response and write in a file given
           by shell variable TRACE_TRD_OUT_FILE.
          TIB Sender process would pick up the response messages from here and broadcast it
           over the network under the configured subject.


3 Installation
3.1       File Creation
          cd to directory where you want to install TraceEngine
          uncompress the installation file you have received
           e.g. uncompress trace20.cpio.Z
           A file with name trace20.cpio should get created.
          extract from the cpio archive
           e.g. cpio -idv -I trace20.cpio
           This would create trace2.0 directory and also create the necessary subdirectory
           structure under it.

3.2       Directory Structure and Files
After cpio extraction, you would see the following files-


Sub-Directory and Contents           Description
TRACE/bin                            subdirectory for executables
TraceEngine                          Trace Engine executable



_______________________________________________________________________________
Draft Version 1.0         April 16, 2010    Page 3 of 9             6f791470-771d-47b6-bfb1-
2bedfb963644.doc
Directory             Contains               Files
TRACE/bin             executables            TraceEngine- executable for TraceEngine
TRACE/data/eng        data formats,          bcal.def- format for BCAL allege message from
                      configuration files    NASD
                      for message types,
                                             bcan.def- format for allege message BCAN
                      token dictionary
                                             bcen.def- format for BCEN message
                                             bcnw.def- format for BCNW message
                                             cxl.rej.def- format of a Reject response from
                                             NASD for a Cancel message
                                             mod.rej.def- format of a Reject response for a
                                             No-Was message
                                             new.rej.def- format of a Reject response for a
                                             new trade.
                                             trace_msg_type_info- information on position
                                             of message types
                                             tracetoken_dictionary- token dictionary
                                             tracein.fmt- details of which format file to use
                                             for what message types (for messages coming
                                             from NASD)
                                             traceout.fmt- message type and corresponding
                                             format files (for messages going to NASD)
                                             cancel.out- format of Cancel message going to
                                             NASD
                                             modify.out- format for No-Was message
                                             new.out- format for a new trade message
                                             going to NASD
TRACE/log             log files              TraceEngine.stderr- log of Trace Engine
TRACE/sh              shell scripts          init.TraceEngine- main script of Trace Engine
                                             TraceDb.env- database related environment
                                             variables
                                             TraceEngine.env- definition of sub-directory
                                             related environment variables of Trace Engine
TRACE/src/code/Eng    source code            TokenValidationFunctions.c and
                                             TokenValidationFunctions.h- code to validated
                                             msg from Trading system
                                             TraceDbFunctions.c and TraceDbFunctions.h-
                                             functions handling database interaction
_______________________________________________________________________________
Draft Version 1.0    April 16, 2010   Page 4 of 9           6f791470-771d-47b6-bfb1-
2bedfb963644.doc
                                            TraceFunctions.c and TraceFunctions.h-
                                            common functions
                                            TraceMain.c and TraceMain.h- main code for
                                            Trace Engine
TRACE/src/def        table definitions      trace_allege_trade.def- sql script to create
                                            table for storing allege trade details
                                            trace_trade.def- sql script to create table for
                                            storing normal trade details
TRACE/src/sp         stored procedures      add_trace_alleged_trade.sp- inserts an allege
                                            trade record
                                            add_trace_cross_ref.sp- updates the cross
                                            reference field for a given reference number
                                            add_trace_cross_ref_for_mod.sp- updates
                                            cross reference for a given control number
                                            add_trace_trade.sp- inserts a trade record
                                            delete_trace_trade.sp- deletes a trade
                                            ret_trace_alleged_trd_cnt.sp- retrieves an
                                            allege trade
                                            retrieve_trace_cross_ref.sp- gets a cross
                                            reference number for a given reference number
                                            retrieve_trace_key_fields.sp- gets key fields of
                                            a trade
                                            retrieve_trace_original_ref.sp- retrieves
                                            backward linked reference number
                                            retrieve_trace_reversal.sp- retrieves trade
                                            details
                                            retrieve_trace_trade.sp- retrieves status for a
                                            trade
                                            retrieve_trace_trade_by_cnt.sp- retrieves
                                            status of a trade for a given control number
                                            up_trace_alleged_stat_by_cnt.sp- updates
                                            status of an allege trade for a given control
                                            number
                                            update_trace_for_no_cntl.sp- updates all fields
                                            for a control number
                                            update_trace_for_rej.sp- updates rejection
                                            details for a message
                                            update_trace_status.sp- updates trade status
                                            update_trace_trade.sp- updates control
                                            number and append modifier for a trade
                                            update_trace_trade_status_for_mod.sp-
                                            update trade status for a given control number
_______________________________________________________________________________
Draft Version 1.0   April 16, 2010   Page 5 of 9           6f791470-771d-47b6-bfb1-
2bedfb963644.doc
3.3       Configuration
After extracting files, you need to make the following changes to configuration-
1. Shell script init.TraceEngine-
              INSTALLDIR                  assign the name of the directory in which TRACE
               sub-directory resides
              LD_LIBRARY_PATH             modify as per the locations of SYBASE and TIBRV directories
              TRACE_TRD_IN_FILE           name of file with messages coming from Trading system
              TRACE_SIM_IN_FILE           file with messages coming from NASD through CTCI
              TRACE_TRD_OUT_FILE file with responses going to Trading system
              TRACE_SIM_OUT_FILE file with messages going to NASD through CTCI
              KEY                   shared memory key- should be unique across all shared
               memory applications running on one machine
2. Environment variables in TraceDb.env
          DEFAULT_USER             user name for database connectivity
          DEFAULT_PASSWD           password
          DEFAULT_SERVER           sybase server


4 Functionality
The following table describes in brief, the way Addition, Modification and Deletion of trades is
handled in TraceEngine.
Event                                              Action


1. New trade from Trading system
1a- Receipt of trade with message type                perform basic validations; In case of any
'A'                                                    discrepancy, send a reject message to Trading
                                                       system
                                                      send immediate acknowledgement to Trading
                                                       system (message type 'I')
                                                      insert trade in database with status 'O'
                                                      format and send message to NASD with function
                                                       as 'U'
1b- BCEN from NASD- Acceptance of                     update trade status to 'T' in database
trade
                                                      send message to Trading system with message
                                                       type 'E' and control number as received from
                                                       NASD
or

_______________________________________________________________________________
Draft Version 1.0         April 16, 2010       Page 6 of 9           6f791470-771d-47b6-bfb1-
2bedfb963644.doc
1b- Reject from NASD for new trade             update trade status to 'R' in database
                                               send reject message to Trading system with
                                                message type 'R' and with reject reason


2. Same day Deletion
2a- Receipt of deletion transaction from       update database with status 'A'
Trading system (message type 'D') for
                                               send message to NASD with function 'C'
a trade reported today
2b- BCAN from NASD, acceptance of              update database with status 'C'
cancellation
                                               send message to Trading system with message
                                                type 'C'
or                                          
2b- Rejection from NASD for                    reinstate trade status to 'T' in database
cancellation transaction of 2a
                                               send reject message to Trading system


3- Next day Deletion
3a- Receipt of deletion transaction from       update database with status 'B'
Trading system (message type 'D') for
                                               generate a reversal message with reference
a trade reported Yesterday or earlier
                                                number suffixed with 'R'
                                               insert the message as a new trade in database
                                               send it to NASD with function 'U'
3b- BCEN from NASD, acceptance of              update reversal trade record in database with
reversal trade                                  status 'T'
                                               update earlier trade in database with status 'V'
                                               send message to Trading system with message
                                                type 'C'
or
3b- Rejection from NASD for reversal           update reversed trade in database with status 'R'
trade
                                               reinstate status of original trade to 'T'
                                               send reject message to Trading system


4- Normal Modify
4a- Receipt of trade modification from         update database status to 'M'
Trading system for a trade reported
                                               create another record with new details
today and key fields (like contra party)
are not changed                                send a No-Was message to NASD
4b- BCNW from NASD- acceptance of              update database status to 'T'
No-Was message
                                               update original trade status to 'N'
_______________________________________________________________________________
Draft Version 1.0      April 16, 2010   Page 7 of 9            6f791470-771d-47b6-bfb1-
2bedfb963644.doc
                                               send message to Trading system with message
                                                type 'N'
or
4b- Reject from NASD for No-Was                update database status to 'R'
message
                                               reinstate original trade status to 'T'
                                               send reject message to trading system


5- Key Field Modification
5a- Receipt of a trade modification            update database status to 'Z'
from Trading system for a trade
                                               create another record with new details
reported today and key fields are
changed                                        send a Cancel message to NASD for earlier trade
5b- BCAN- cancel accepted by NASD              update earlier trade status to 'Y'
                                               send new trade message to NASD
5c- BCEN- new trade accepted by                update earlier trade status to 'C'
NASD
                                               update new trade status to 'T'
                                               send message to Trading system with message
                                                type 'N'
or
5b- Rejection of cancellation by NASD          reinstate earlier trade status to 'T'
                                               send reject message to Trading System


6- Next day Modification
6a- Receipt of a trade modification            update database status to 'X'
from Trading system for a trade
                                               generate a reversal transaction and store in
reported yesterday or earlier
                                                database with reference number suffixed with 'R'
                                               create a new trade and insert in database
                                               send reversal to NASD
6b- BCEN- reversal accepted by NASD            update original trade status to 'W'
                                               update reversed trade status to 'T'
                                               send new trade message to NASD
6c- BCEN- new trade accepted by                update original trade status to 'V'
NASD
                                               update new trade status to 'T'
                                               send message to Trading system with message
                                                type 'N'
or
6b- Rejection by NASD for reversal of          reinstate original trade status to 'T'
_______________________________________________________________________________
Draft Version 1.0    April 16, 2010     Page 8 of 9            6f791470-771d-47b6-bfb1-
2bedfb963644.doc
trade
                                                send reject message to Trading System




5 Tips for Analysis
When the results are not what were expected, these are the places one can look at-
       TRACE_TRD_OUT_FILE- It contains messages going back to trading system. If a
        message fails basic initial validations, it would be written to file. It would also have the
        reject reason in it.
       Database- view_trace_txn.sp- displays all fields for a trade for a given reference
        number. Check especially columns status, control_number, cross_ref_no, as_of,
        trade_date, entry_date, date_time_status and rej_reason.
       TRACE_SIM_OUT_FILE- File with messages going to NASD. Any transaction has to fall
        in one of the six cases described under Functionality. So, one can find out what it
        should be in this file.
       Log- Trace Engine log file $INSTALLDIR/TRACE/log/TraceEngine.stderr would indicate
        what functions were called and how the control traversed through the code.


<< end of document >>




_______________________________________________________________________________
Draft Version 1.0      April 16, 2010    Page 9 of 9           6f791470-771d-47b6-bfb1-
2bedfb963644.doc

				
Jun Wang Jun Wang Dr
About Some of Those documents come from internet for research purpose,if you have the copyrights of one of them,tell me by mail vixychina@gmail.com.Thank you!