MAINT: Refactor application of capital changes

Previously, on the dt of a capital change, we use the un-updated
prices to find the ending performance of the previous subperiod and
then got the new prices to determine the portfolio value used to
calculate the delta, without actually updating the performance
before applying the capital change. This logic is confusing and
unintuitive. Instead, save the ending performance as we do previously,
but have temp values for the starting current subperiod value.
Update those temp values after processing the capital change
This commit is contained in:
Andrew Liang
2016-08-01 11:51:45 -04:00
parent a937d6e6b1
commit 98f3fc9326
5 changed files with 42 additions and 35 deletions
+3 -4
View File
@@ -2264,12 +2264,11 @@ shares in position"
pt.execute_transaction(txn)
pp.handle_execution(txn)
# sync prices and calculate performance before we introduce a capital
# change
# sync prices before we introduce a capital change
pt.sync_last_sale_prices(trades[2].dt, False, data_portal)
pp.calculate_performance()
pp.subdivide_period(1000.0)
pp.initialize_subperiod_divider()
pp.set_current_subperiod_starting_values(1000.0)
pt.sync_last_sale_prices(trades[-1].dt, False, data_portal)
pp.calculate_performance()