'If there is a capital change for a given dt, this means the the change
occurs before `handle_data` on the given dt. In the case of the
change being a target value, the change will be computed on the
portfolio value according to prices at the given dt
`portfolio_value_adjustment`, if specified, will be removed from the
portfolio_value of the cumulative performance when calculating deltas
from target capital changes.'

def calculate_capital_changes(self, dt, emission_rate, is_interday, portfolio_value_adjustment=0.0):

    try:
        capital_change = self.capital_changes[dt]
    except KeyError:
        return
    if (emission_rate == 'daily'):
        self.perf_tracker.position_tracker.sync_last_sale_prices(self.trading_calendar.previous_minute(dt), False, self.data_portal)
    self.perf_tracker.prepare_capital_change(is_interday)
    if (capital_change['type'] == 'target'):
        target = capital_change['value']
        capital_change_amount = (target - (self.updated_portfolio().portfolio_value - portfolio_value_adjustment))
        self.portfolio_needs_update = True
        log.info(('Processing    capital    change    to    target    %s    at    %s.    Capital    change    delta    is    %s' % (target, dt, capital_change_amount)))
    elif (capital_change['type'] == 'delta'):
        target = None
        capital_change_amount = capital_change['value']
        log.info(('Processing    capital    change    of    delta    %s    at    %s' % (capital_change_amount, dt)))
    else:
        log.error(("Capital    change    %s    does    not    indicate    a    valid    type    ('target'    or    'delta')" % capital_change))
        return
    self.capital_change_deltas.update({dt: capital_change_amount})
    self.perf_tracker.process_capital_change(capital_change_amount, is_interday)
    (yield {'capital_change': {'date': dt, 'type': 'cash', 'target': target, 'delta': capital_change_amount}})
