mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-05 01:23:33 +08:00
ae97e75388
Instead of calculating the position values for each stat result, e.g. gross_exposure, net_liquidity etc.; get the positions upfront and then calculate the period and position stats in order, passing each value explicitly to the ones that follow it in the dependency chain. e.g. the gross_value depends on the long_value and the short_value, which called the position_values property for calculating both the long_value and the short_value. Removing the repeated calls to position_values (and position_exposures) removes the need for the caching the last sale prices and position amounts in separate vectors, since it is inexpensive enough to read those values off of the positions dictionary held in the position tracker. This patch gives a small gain to ~500 sized portfolios, but the main intent is to clear the path to not storing last_sale_prices on the position objects at all. Removing all of the caching layer in this class makes that change easier to apply. Removing the extra calls to position_values also made this class easier to step through/reason about when splicing in the new last sale price access, as well.