Spreadsheet: 599690d1543254679-most-efficient-way-doing-calculations-based-on-large-matrices-portfolio-test
Sheet: Example

 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | # OF INSTRUMENTS |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | COST |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | OUTPUT |  | Date | 2018-12-03 00:00:00
 | Closing prices |  |  |  |  |  |  | Ingoing values |  |  |  |  | Transactions |  |  |  |  |  |  |  |  | Account A |  |  |  |  |  |  | Account B |  |  |  |  |  |  | Portfolio |  |  |  |  |  |  | Account A |  |  |  |  |  |  | Account B |  |  |  |  |  |  | Portfolio |  |  |  |  |  |  | Account A |  |  |  |  |  |  |  |  |  | Account B |  |  |  |  |  |  |  |  |  | Portfolio
 | Date | Instrument A | Instrument B | Instrument C | Instrument D | Instrument E |  | Instrument | Account | # | Cost |  | Date | Instrument | Account | Transaction type | # | Price | Courtage | Liquidity |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | Instrument | # | Price | Price change | Market value | Cost | Unrealized profit/loss | Value change | Part of Account |  | Instrument | # | Price | Price change | Market value | Cost | Unrealized profit/loss | Value change | Part of Account |  | Instrument | # | Price | Price change | Market value | Cost | Unrealized profit/loss | Value change | Part of Account
 |  | 100 | 50 | 150 | 200 | 76 |  | Instrument A | Account A | 115 | 10350 |  | 2018-11-23 00:00:00 | Instrument A | Account A | Buy | 30 | 100.36 | 99
 |  | 100.38 | 51.4 | 149.89 | 201.74 | 76.03 |  | Instrument B | Account A | 310 | 24800 |  | 2018-11-28 00:00:00 | Instrument B | Account B | Sell | 10 | 76.5 | 99
 |  | 99.96 | 51.81 | 149.75 | 201.09 | 76.21 |  | Instrument C | Account A | 0 | 0 |  | 2018-12-03 00:00:00 | Instrument A | Account B | Buy | 100 | 100 | 99
 |  | 99.89 | 51.95 | 149.6 | 203.82 | 76.51 |  | Instrument D | Account A | 0 | 0 |  | 2018-12-03 00:00:00 | Instrument B | Account A | Buy | 250 | 77 | 99
 |  | 100.08 | 53.11 | 149.61 | 202.64 | 76.68 |  | Instrument E | Account A | 100 | 60000 |  | 2018-12-04 00:00:00 | Instrument A | Account B | Sell | 15 | 100 | 99
 |  | 100.09 | 53.39 | 149.74 | 200.96 | 76.49 |  | Instrument A | Account B | 300 | 30300 |  | 2018-12-06 00:00:00 | Instrument C | Account B | Buy | 900 | 149.98 | 99
 |  | 100.09 | 54.02 | 149.8 | 198.07 | 76.59 |  | Instrument B | Account B | 30 | 1890 |  | 2018-12-10 00:00:00 | Instrument E | Account A | Sell | 100 | 77 | 99
 |  | 99.9 | 54.04 | 149.87 | 196.74 | 77.05 |  | Instrument C | Account B | 0 | 0 |  | 2018-12-14 00:00:00 | Instrument D | Account A | Buy | 1000 | 194 | 150
 |  | 100.1 | 54.02 | 150.01 | 197.11 | 77.45 |  | Instrument D | Account B | 200 | 50000 |  | 2018-12-20 00:00:00 | Instrument A | Account B | Buy | 50 | 100.85 | 50
 |  | 100.46 | 54.59 | 149.97 | 194.42 | 77.29 |  | Instrument E | Account B | 0 | 0 |  | 2018-12-20 00:00:00 | Instrument B | Account A | Sell | 50 | 50.78 | 50
 |  | 100.16 | 55.81 | 149.97 | 191.71 | 77.1 |  |  |  |  |  |  | 2018-12-21 00:00:00 | Instrument A | Account A | Sell | 100 | 100.48 | 99
 |  | 100.27 | 55.05 | 149.86 | 194.59 | 76.88 |  |  |  |  |  |  | 2018-12-26 00:00:00 | Instrument C | Account A | Buy | 20 | 150.29 | 99
 |  | 100.57 | 54.79 | 149.84 | 197.24 | 76.78 |  |  |  |  |  |  | 2018-12-28 00:00:00 | Instrument B | Account B | Buy | 435 | 78 | 99
 |  | 100.71 | 55.05 | 149.78 | 193.82 | 76.85 |  |  |  |  |  |  | 2018-12-31 00:00:00 | Instrument D | Account B | Sell | 200 | 203 | 200
 |  | 100.32 | 53.62 | 149.88 | 193.52 | 77.11 |  |  |  |  |  |  | 2018-12-31 00:00:00 | Instrument A | Account B | Sell | 435 | 101.35 | 200
 |  | 100.56 | 52.75 | 149.93 | 193.78 | 77.55
 |  | 100.82 | 52.02 | 149.96 | 196.48 | 77.36
 |  | 100.89 | 51.71 | 150.02 | 199.64 | 77.66
 |  | 100.74 | 50.76 | 150.08 | 200.71 | 77.56
 |  | 101.08 | 51.88 | 150.12 | 202.66 | 77.68
 |  | 100.8 | 53.19 | 150.15 | 204.32 | 77.2
 |  | 100.46 | 52.68 | 150.27 | 202.56 | 77
 |  | 100.89 | 52.25 | 150.23 | 204.5 | 76.57
 |  | 101.06 | 51.36 | 150.18 | 205.95 | 76.66
 |  | 101.19 | 51.93 | 150.22 | 205.06 | 76.71
 |  | 101.61 | 51.13 | 150.22 | 202.01 | 77.15
 |  | 101.29 | 52.06 | 150.15 | 201.03 | 77.54
 |  | 101.39 | 51.22 | 150.08 | 201.37 | 77.72