def test_match_repeat3(self):
     list_a, list_b = create_list3()
     matched_list, unmatched_items = match_repeat(list_a, list_b, is_matched)
     self.assertEqual(len(matched_list), 3)
     self.assertEqual(len(unmatched_items), 0)
     self.assertEqual(matched_list[0], (1, -1))
     self.assertEqual(matched_list[1], (3, -3))
     self.assertEqual(matched_list[2], (1, -1))
 def test_match_repeat4(self):
     list_a, list_b = create_list4()
     matched_list, unmatched_items = match_repeat(list_a, list_b, is_matched)
     self.assertEqual(len(matched_list), 3)
     self.assertEqual(len(unmatched_items), 2)
     self.assertEqual(matched_list[0], (1, -1))
     self.assertEqual(matched_list[1], (3, -3))
     self.assertEqual(matched_list[2], (2.0625, -2))
     self.assertEqual(unmatched_items[0], 4)
     self.assertEqual(unmatched_items[1], 8)
Exemple #3
0
def create_position_date(positions, bond_issues):
    """
	Match tax lots in trustee records to buy trade records, so that we can
	populate the date of the matched tax lots to the settlement date of
	the trade record.
	"""
    matched, unmatched = match_repeat(positions, bond_issues,
                                      map_position_bond_issue)
    for (position, bond_issue) in matched:
        position['date'] = bond_issue['Issue date']

    # for position in positions:
    # 	position['Portfolio'] = map_portfolio_code(position['Portfolio'])

    return positions, unmatched
Exemple #4
0
def create_tax_lot_date(trustee_records, trade_records):
    """
	Match tax lots in trustee records to buy trade records, so that we can
	populate the date of the matched tax lots to the settlement date of
	the trade record.
	"""
    matched, unmatched = match_repeat(trustee_records, trade_records,
                                      map_trade_tax_lot)
    for (trustee_record, trade_record) in matched:
        trustee_record['date'] = convert_datetime_to_string(
            trade_record['SettleDate'])

    for trustee_record in unmatched:
        trustee_record['date'] = ''

    return trustee_records, unmatched