Problem Statement Consider a inter dealer-broker network which various financial stock brokers use to execute customer stock trading orders. Everytime a customer needs to buy/sell a stock; it reaches out to its designated broker who then uses this broker-network to buy/sell the stock at the current market price. When the trade gets executed between two customers through brokers, it gets assigned a unique identifier called ââ?¬Å?TransIdââ?¬Â?. While trades get executed during the day, money settlement between the customers happens at the end of the day. To find out how much money needs to be transferred between buying/selling customers, every broker produces following report at end of day, which lists customer specific transactions as below:
Report from Broker Alpha
TransId Security Currency Volume Price TransType CustomerId
1112 114CD USD 100000 16.72 BUY 447FG
1113 121XQ EUR 50000 45.24 SELL 432DF
1114 178AA CHF 80000 24.00 BUY 444AK
Report from Broker Beta
TransId Security Currency Volume Price TransType CustomerId
1112 114CD USD 100000 16.72 SELL 852KS
1115 136RT GBP 50000 63.568 BUY 851GF
This data is first fed into a third-party Reconciliation System that first reconciles transaction data from various brokers based on the ââ?¬Å?TransIdââ?¬Â?. Reconciled trades are then fed into a central Accounting System that generates payment orders.
You need to write code ââ?¬Å?ONLYââ?¬Â? for this Reconciliation System (not Accounting System) based on the specifications below. Specifications The trade data from a broker is in the form of a CSV file (comma separated values), with the following fields: ââ?¬Â¢ TransId ââ?¬â?? Unique identifier for the transaction/trade. It will be same for a set of matching transactions. ââ?¬Â¢ Security ââ?¬â?? Financial security identifier (e.g. for Reliance stocks, this would be RIL). ââ?¬Â¢ Currency ââ?¬â?? 3-letter currency code for the transaction/trade. ââ?¬Â¢ Volume ââ?¬â?? Number of units of the traded security. ââ?¬Â¢ Price ââ?¬â?? Unit price of the traded security. ââ?¬Â¢ TransType ââ?¬â?? Type of transaction/trade from customerââ?¬â?¢s perspective. - BUY or SELL. For a valid trade, if one customer has ââ?¬Å?BUYââ?¬Â? for a security, then there must be another customer having ââ?¬Å?SELLââ?¬Â?. ââ?¬Â¢ CustomerId ââ?¬â?? Broker specific identifier for the customer who raised trade request with the broker. The system should be able to perform the following functions: ââ?¬Â¢ Load the trade data files from various brokers, and match transactions data. ââ?¬Â¢ Transaction data should be ââ?¬Å?matchedââ?¬Â? based on ââ?¬Å?TransIdââ?¬Â?. Following fields should be compared for differences: 1. Security 2. Currency 3. Volume 4. Price (Price data should be matched by rounding up to 2 decimal places) ââ?¬Â¢ If differences are found, output should be written to a differences file in the following format: TransId, Security, BrokerAName, BrokerBName, DiffFieldName, ValueA, ValueB ââ?¬Â¢ The above differences should be sorted by ââ?¬Å?Securityââ?¬Â? in the output differences file. ââ?¬Â¢ If for a given TransId, an opposite matching trade is not found, then that data should be stored in a separate file, so that it could be processed in the next dayââ?¬â?¢s run. Here we assume that the matching transaction might arrive in the next runââ?¬â?¢s input file from the other broker. (Hint: Consider this pending data as the additional file to be processed for comparison) ââ?¬Â¢ If the system is not able to find any disparities between the transaction data from multiple brokers during a process run, then the message ââ?¬Å?No differences found for last process runââ?¬Â? should be written to the output. Exception Scenarios: ââ?¬Â¢ If the ââ?¬Å?Currencyââ?¬Â? for a transaction is not a 3-letter code, then return a user-friendly error and log to a common exception output, but the process should continue to run for rest of the transactions within that file. ââ?¬Â¢ If the ââ?¬Å?TransTypeââ?¬Â? is either BUY or SELL for both sides of a transaction, then return a user-friendly error and log to a common exception output, but the process should continue to run for rest of the transactions.
Other Instructions Please keep following instructions in mind: � Do not write boiler-plate code for reading/writing from the file. Mock the function that does these things. � The solution should be scalable enough to accommodate input transaction files from multiple brokers, and considering that each broker could have hundreds of transactions in corresponding input file. The solution should be able to run the whole comparison process in minimum time possible.
Evaluation criteria � Code Completeness/ Correctness � Code Structure and quality: Modularity, usage of OO principles, size of classes/functions, class/function/variable names, package/class structure � Choice of data structures � Unit Test cases � Coding productivity (more time you take to submit the exercise, lesser you will score) Better you perform on this criteria, higher you will score.
Ads