Example #1
0
    def test_wash_against_small_replacement(self):
        lots = lots_lib.Lots([self.loss, self.small_first_gain])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        # Create the split lot.
        split_lot = copy.deepcopy(disallowed_loss)
        split_lot.num_shares = 4
        split_lot.basis *= 4. / 10.
        split_lot.adjusted_basis *= 4. / 10.
        split_lot.proceeds *= 4. / 10.
        final_lots.add(split_lot)

        disallowed_loss.num_shares = 6
        disallowed_loss.basis *= 6. / 10.
        disallowed_loss.adjusted_basis *= 6. / 10.
        disallowed_loss.proceeds *= 6. / 10.
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 6
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]
        replacement.adjusted_basis = 106
        replacement.adjusted_buy_date -= (self.loss.sell_date -
                                          self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
Example #2
0
    def test_wash_against_large_replacement(self):
        lots = lots_lib.Lots([self.loss, self.large_first_gain])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 10
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]

        # Create the split lot.
        split_lot = copy.deepcopy(replacement)
        split_lot.num_shares = 8
        split_lot.basis = int(round(split_lot.basis * 8. / 18.))
        split_lot.adjusted_basis = int(
            round(split_lot.adjusted_basis * 8. / 18.))
        split_lot.proceeds = int(round(split_lot.proceeds * 8. / 18.))
        final_lots.add(split_lot)

        replacement.num_shares = 10
        replacement.basis = int(round(replacement.basis * 10. / 18.))
        replacement.adjusted_basis = int(
            round(replacement.adjusted_basis * 10. / 18.))
        replacement.proceeds = int(round(replacement.proceeds * 10. / 18.))
        replacement.adjusted_basis += 10
        replacement.adjusted_buy_date -= (self.loss.sell_date -
                                          self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
    def test_wash_against_large_replacement(self):
        lots = lots_lib.Lots([self.loss, self.large_first_gain])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 10
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]

        # Create the split lot.
        split_lot = copy.deepcopy(replacement)
        split_lot.num_shares = 8
        split_lot.basis = int(round(split_lot.basis * 8. / 18.))
        split_lot.adjusted_basis = int(round(split_lot.adjusted_basis * 8. /
                                             18.))
        split_lot.proceeds = int(round(split_lot.proceeds * 8. / 18.))
        final_lots.add(split_lot)

        replacement.num_shares = 10
        replacement.basis = int(round(replacement.basis * 10. / 18.))
        replacement.adjusted_basis = int(round(replacement.adjusted_basis * 10.
                                               / 18.))
        replacement.proceeds = int(round(replacement.proceeds * 10. / 18.))
        replacement.adjusted_basis += 10
        replacement.adjusted_buy_date -= (
            self.loss.sell_date - self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
    def test_wash_against_small_replacement(self):
        lots = lots_lib.Lots([self.loss, self.small_first_gain])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        # Create the split lot.
        split_lot = copy.deepcopy(disallowed_loss)
        split_lot.num_shares = 4
        split_lot.basis *= 4./10.
        split_lot.adjusted_basis *= 4./10.
        split_lot.proceeds *= 4./10.
        final_lots.add(split_lot)

        disallowed_loss.num_shares = 6
        disallowed_loss.basis *= 6./10.
        disallowed_loss.adjusted_basis *= 6./10.
        disallowed_loss.proceeds *= 6./10.
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 6
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]
        replacement.adjusted_basis = 106
        replacement.adjusted_buy_date -= (
            self.loss.sell_date - self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
Example #5
0
    def test_no_wash_if_no_replacement_shares(self):
        lots = lots_lib.Lots(
            [self.loss, self.very_early_gain, self.very_late_gain])

        final_lots = copy.deepcopy(lots)
        loss = final_lots.lots()[0]
        loss.loss_processed = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
    def test_no_wash_if_no_replacement_shares(self):
        lots = lots_lib.Lots([self.loss, self.very_early_gain,
                              self.very_late_gain])

        final_lots = copy.deepcopy(lots)
        loss = final_lots.lots()[0]
        loss.loss_processed = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
Example #7
0
    def test_wash_against_subsequent_loss(self):
        lots = lots_lib.Lots([self.loss, self.later_loss])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 10
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]
        replacement.adjusted_basis = 150
        replacement.adjusted_buy_date -= (self.loss.sell_date -
                                          self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
    def test_wash_against_subsequent_loss(self):
        lots = lots_lib.Lots([self.loss, self.later_loss])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        disallowed_loss.adjustment_code = 'W'
        disallowed_loss.adjustment = 10
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]
        replacement.adjusted_basis = 150
        replacement.adjusted_buy_date -= (
            self.loss.sell_date - self.loss.buy_date)
        replacement.replacement_for = ['_1']
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)
Example #9
0
    def test_wash_against_unsold(self):
        lots = lots_lib.Lots([self.loss, self.unsold])

        final_lots = copy.deepcopy(lots)
        disallowed_loss = final_lots.lots()[0]
        disallowed_loss.adjustment_code = "W"
        disallowed_loss.adjustment = 10
        disallowed_loss.loss_processed = True
        replacement = final_lots.lots()[1]
        replacement.adjusted_basis = 140
        replacement.adjusted_buy_date -= (self.loss.sell_date -
                                          self.loss.buy_date)
        replacement.replacement_for = ["_1"]
        replacement.is_replacement = True

        wash.wash_one_lot(self.loss, lots)
        self.assertSameLots(lots, final_lots)