Reconciliation is a term Addepar uses for a set of correctness and consistency measures applied to the data we receive and use in financial calculations. One of the most common reconciliation checks is called unit reconciliation, which answers the question:
Does the transaction history add up to the number of shares the bank says I have?
For example, if the bank said I had 100 shares of Apple at the end of yesterday, and I bought 20 shares of Apple today, then we expect the bank to report 120 shares at the end of today. This surprisingly isn't always the case. The bank may send incomplete data, we may be parsing it incorrectly, or there may be events like corporate actions or trade settlement lag that cause an inconsistency.
Unit reconciliation is very important because numbers that don't add up shouldn't be trusted for any metrics.
----
Write a function that takes three lists of strings as input:
* DO-POS
- describes the positions in the account at the end of day 0. Each record is a space-separated pair of symbol and shares.
For example, "AAPL 10" means 10 shares of AAPL were held at the end of day 0, and "Cash 123.45" means we had $123.45 in the account at the end of day 0.
* D1-TRN
- describes the transactions that occurred in the account on day 1. Each record is a space-separated collection. The first column is the transaction code, remaining columns depend on the given transaction code.
* D1-POS
- describes the positions in the account at the end of day 1, and has the same format as 'DO-POS'.
The function should output a list of positions with unit reconciliation errors:
* Each record is a space-separated pair of symbol and difference between the actual quantities and the expected ones.
* Only positions with unit reconciliation problems should appear in the list.
* The list should be empty if no reconciliation issues are found.
* For example: "GOOG 20" indicates we ended up the day with 20 extra shares of GOOG that were not explained by the intra-day transactions, while "Cash -20" shows that we ended the day with 20 fewer units of cash than expected.
To start us off, let's support two basic transaction types and a single cash currency (assume USD for currency):
* Buy [BY]
- Besides the first two generic fields, two additional ones: units and total value
- For example, "AAPL BY 10 1234.56" means 10 shares of AAPL were bought for a total cost of $1234.56
Sell [SL]
* Same as 'BY' case, but sells shares for dollars
### Sample Input
["AAPL 100", "GOOG 200", "Cash 10"] # DO-POS
["AAPL SL 50 30000", "GOOG BY 10 10000"] # D1-TRN
["AAPL 50", "GOOG 220", "Cash 20000"] # D1-POS
### Sample Output
["GOOG 10", "Cash -10"]