'A note about cost-basis in zipline: all positions are considered
to share a cost basis, even if they were executed in different
transactions with different commission costs, different prices, etc.
Due to limitations about how zipline handles positions, zipline will
currently spread an externally-delivered commission charge across
all shares in a position.'

@expect_types(asset=Asset)
def adjust_commission_cost_basis(self, asset, cost):

    if (asset != self.asset):
        raise Exception('Updating    a    commission    for    a    different    asset?')
    if (cost == 0.0):
        return
    if (self.amount == 0):
        return
    prev_cost = (self.cost_basis * self.amount)
    if isinstance(asset, Future):
        cost_to_use = (cost / asset.multiplier)
    else:
        cost_to_use = cost
    new_cost = (prev_cost + cost_to_use)
    self.cost_basis = (new_cost / self.amount)
