def test_create_settlement_ref_count(self):
        org = self.store.lookup("organization:name", "First Bank")["ref-count"]
        org2 = self.store.lookup("organization:name",
                                 "Second Bank")["ref-count"]
        transaction = BondTransaction({
            "UpdateType":
            "CreateSettlement",
            'Updates': [{
                "UpdateType":
                "CreateSettlement",
                "order_id":
                "123453716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })

        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        new_org = self.store.lookup("organization:name",
                                    "First Bank")["ref-count"]
        new_org2 = self.store.lookup("organization:name",
                                     "Second Bank")["ref-count"]

        self.assertEquals(org + 1, new_org)
        self.assertEquals(org2 + 1, new_org)
예제 #2
0
    def test_coupon_exists(self):
        org = self.store.lookup("organization:name", "Second Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")
        date = datetime.datetime(2015, 4, 1)
        self._set_clock(2015, 4, 1, 1)
        self.assertFalse(Family._coupon_exists(self.store, bond, org, date))

        transaction = BondTransaction({
            'Updates': [{
                'UpdateType': 'CreateReceipt',
                'PaymentType': 'Coupon',
                'BondID': bond['object-id'],
                'PayeeID': org['object-id'],
                'CouponDate': "04/01/2015"
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        org = self.store.lookup("organization:name", "Second Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")
        self.assertTrue(Family._coupon_exists(self.store, bond, org, date))
예제 #3
0
    def test_generate_coupons_coupon(self):
        self._set_clock(2015, 4, 1, 1)
        signingkey = signed_object.generate_signing_key()
        ident = signed_object.generate_identifier(signingkey)
        node = Node(identifier=ident,
                    signingkey=signingkey,
                    address=("localhost", 10021))
        node.is_peer = True
        path = tempfile.mkdtemp()
        gossip = Gossip(node)
        journal = Journal(node,
                          gossip,
                          gossip.dispatcher,
                          consensus=DevModeConsensus(),
                          data_directory=path)
        journal.global_store.TransactionStores['/BondTransaction'] = \
            self.store
        # creates a redemption
        updates = Family._generate_coupons(journal)

        self.assertNotEquals(updates, [])

        transaction = BondTransaction(updates[0])
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        org_usd_holding = self.store["34d813716009ca1786222a44347ccff"
                                     "258a4ab6029d936664fde0d13f23992b5"]
        self.assertEquals(org_usd_holding["amount"], 25000.0)
    def test_create_holding_refcounts(self):
        org = self.store.lookup("organization:name", "Test Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")
        org_refcount_before = org["ref-count"]
        bond_refcount_before = bond["ref-count"]

        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType": "CreateHolding",
                "owner_id": org["object-id"],
                "asset_type": "Bond",
                "asset_id": bond["object-id"],
                "amount": 10000
            }]
        })
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        org = self.store.lookup("organization:name", "Test Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")

        self.assertEquals(org_refcount_before + 1, org["ref-count"])
        self.assertEquals(bond_refcount_before + 1, bond["ref-count"])
 def test_create_bond_valid(self):
     transaction = BondTransaction({
         "UpdateType":
         "CreateBond",
         'Updates': [{
             "UpdateType": "CreateBond",
             "amount_outstanding": 42671000000,
             'corporate_debt_ratings': {
                 "Fitch": "AAA",
                 "Moodys": "AAA",
                 "S&P": "AA+"
             },
             "coupon_rate": 1.375,
             "coupon_type": "Fixed",
             "coupon_frequency": "Quarterly",
             "cusip": "912828R77",
             "face_value": 1000,
             "isin": "US912828R770",
             "first_settlement_date": "01/11/2012",
             "first_coupon_date": "03/01/2012",
             "maturity_date": "01/11/2022",
             "issuer": "T"
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         transaction.apply(self.store)
     except InvalidTransactionError:
         self.fail("This should be valid")
예제 #6
0
    def test_libor_update_invalid_value_one_week(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 'invalid rate',
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HBYQ8UxaSl6tTv2Ab3Hctki7kl+G8qBthr+4vVXRvJhMrppcEA3'
                          'CMtm3OitDoYsqmB6MC0WiFqqgSzOEiqJmPUg=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #7
0
    def test_libor_update_invalid_value_three_month(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 'invalid rate',
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HO+xNW91CfhWVrvBKyk2P0rak82TPG8ZSsBucI3QhSXT7SegQd'
                          'y/Sq0dTZC+31rGQgMVdylbXLSO++aIb9OP0y8=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #8
0
    def test_libor_update_invalid_value_two_month(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 'invalid rate',
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HCi5tDerqxHZ8han4SmTqMsbKN1JscETRCqYDU3gNQSofp'
                          't8fm25i5xyo7EwBXDlxpcOyU5em8DVQOGsdyx8jXk=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #9
0
    def test_libor_update_invalid_value_one_year(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 'invalid rate'
                },
                signature='HDRqSWSJN8wCPMGITZLx0pW/ccqsMDYnnG9mbRUL3x1O8bz'
                          'tfGmgkD9n+6OQgb/glO52zuJdFIFV5ehCdr4L0Ug=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #10
0
    def test_libor_update_invalid_value_one_month(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 'invalid rate',
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G+eKJzXQBJCEgIj3ZZ46mfp73WqECskUBh4JPjFIMy9D2EAW0'
                          '2ry7VN1NA6r4ZPf2dGtRY50yHSLrRwf/3Yn0gs=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #11
0
    def test_libor_update_signature_does_not_match(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': '0.1',
                    'OneWeek': '0.1',
                    'OneMonth': '0.1',
                    'TwoMonth': '0.1',
                    'ThreeMonth': '0.1',
                    'SixMonth': '0.1',
                    'OneYear': '0.1',
                },
                signature='hjoq7knkzlxo4qubsjslfarl1ej/qso0ar4zsucd5xguniuvqjv'
                          'zj5lrqhayi5tqvniqxai0lkt31zqsztgojxw=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #12
0
    def test_libor_update_invalid_value_overnight(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 'invalid rate',
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HLwpLLCM0TdAOdyj/zpR4LUNp7QQosVTBBTqEq71zZkjKZ3a5y'
                          'SqRqFAC8Wgv9VQHyRbScLXJxFOG7xH83SxLYc=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
    def test_libor_update_not_signed(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': '0.1',
                    'OneWeek': '0.1',
                    'OneMonth': '0.1',
                    'TwoMonth': '0.1',
                    'ThreeMonth': '0.1',
                    'SixMonth': '0.1',
                    'OneYear': '0.1'
                },
                signature=None)

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #14
0
    def test_libor_update_date_in_the_future(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2100-01-01',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G/gl8XhptfXUGih7X4g4s8EeXNXpX+qz7yEHd6ah1xXyrica2p'
                          'pdePFikWb9wbR5rOnvKC8FDAIg8CadhAaizt0=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
    def test_libor_update_invalid_value_one_year(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        libor_key = TestCreateLIBORUpdate.libor_key
        libor_public_key = signing.generate_pubkey(libor_key)
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 'invalid rate'
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #16
0
    def test_libor_update_invalid_value_six_month(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-24',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 'invalid rate',
                    'OneYear': 0.1
                },
                signature='HHlwEyzhFYP53vg2tE44snVyAD4UUIzElBiaiNUPZLKrkGmO'
                          '5TLHHmRJ8RvTAkxL5elIicRiNwOKc7JI0Zjkn5o=')

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #17
0
    def test_libor_update_missing_date(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date=None,
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature="G78QicusrNO9l8Yxt/qJGX0TxkVh0ftSiW9dYkQPL5qYctd"
                          "pb4Cq3GR15gT6DeHj0ujFcf4CK+Pu0Sqe77Zi92Y=")

        transaction = BondTransaction()
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #18
0
 def _set_clock(self, year, month, day, num):
     date = time.mktime(datetime.date(year, month, day).timetuple())
     transaction = BondTransaction({
         'Updates': [{
             'UpdateType': 'Clock',
             'Blocknum': num,
             'PreviousBlockId': 0,
             'Timestamp': date
         }]
     })
     transaction.sign_object(self.key)
     transaction.check_valid(self.store)
     transaction.apply(self.store)
 def test_create_holding_owner_id(self):
     transaction = BondTransaction({
         "UpdateType":
         "CreateHolding",
         'Updates': [{
             "UpdateType":
             "CreateHolding",
             "owner_id":
             "BadOrganization",
             "asset_type":
             "Currency",
             "asset_id":
             "USD",
             "amount":
             10000,
             "object_id":
             "34d813716009ca1786222a44347ccff258a4ab6029" +
             "d936664fde0d13f23992b6"
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("Bad Organization")
     except InvalidTransactionError:
         pass
 def test_create_holding_asset_other(self):
     org = self.store.lookup("organization:name", "Test Bank")
     transaction = BondTransaction({
         "UpdateType":
         "CreateHolding",
         'Updates': [{
             "UpdateType":
             "CreateHolding",
             "owner_id":
             org["object-id"],
             "asset_type":
             "Cookies",
             "asset_id":
             "Coco Chip",
             "amount":
             10000,
             "object_id":
             "34d813716009ca1786222a44347ccff258a4ab6029" +
             "d936664fde0d13f23992b6"
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("Unknown asset-type")
     except InvalidTransactionError:
         pass
예제 #21
0
 def test_delete_quote(self):
     transaction = BondTransaction({
         "UpdateType": "DeleteQuote",
         'Updates': [{
             "UpdateType": "DeleteQuote",
             "ObjectId": "3932250c4877136ee99bf76e5ffbb50b7f"
             "bd46d6788340d29422abcdabcdabcd"
         }]
     })
     try:
         transaction.sign_object(self.key)
         transaction.check_valid(self.store)
         transaction.apply(self.store)
     except InvalidTransactionError:
         self.fail("This should be valid")
예제 #22
0
    def test_matching_no_quotes(self):
        signingkey = signed_object.generate_signing_key()
        ident = signed_object.generate_identifier(signingkey)
        node = Node(identifier=ident, signingkey=signingkey,
                    address=("localhost", 10003))
        node.is_peer = True
        path = tempfile.mkdtemp()
        gossip = Gossip(node)
        journal = Journal(node,
                          gossip,
                          gossip.dispatcher,
                          consensus=DevModeConsensus(),
                          data_directory=path)

        org2 = self.store.lookup("organization:name", "Second Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")
        transaction = BondTransaction({
            "UpdateType": "CreateOrder",
            'Updates': [{
                "UpdateType": "CreateOrder",
                "Action": "Buy",
                "OrderType": "Market",
                "FirmId": org2["object-id"],
                "Isin": bond["isin"],
                "Quantity": 100000,
                "object_id": "123453716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        journal.global_store.TransactionStores['/BondTransaction'] = \
            self.store
        matched_orders = _generate_match_orders(journal)
        self.assertEquals(matched_orders, [])
예제 #23
0
    def test_create_quote_ref_count(self):
        transaction = BondTransaction({
            "UpdateType": "CreateQuote",
            'Updates': [{
                "UpdateType": "CreateQuote",
                "Firm": "ABCD",
                "Cusip": "912828R77",
                "BidPrice": "98-05.875",
                "BidQty": 24000,
                "AskPrice": "98-06.875",
                "AskQty": 24000
            }]
        })
        try:
            transaction.sign_object(self.key)
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        firm = self.store.lookup("organization:pricing-source", "ABCD")
        self.assertEquals(firm["ref-count"], 2)
 def test_create_settlement_order_id(self):
     transaction = BondTransaction({
         "UpdateType":
         "CreateSettlement",
         'Updates': [{
             "UpdateType": "CreateSettlement",
             "order_id": "bad Id"
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("No Order found")
     except InvalidTransactionError:
         pass
예제 #25
0
    def test_matching_no_order(self):
        signingkey = signed_object.generate_signing_key()
        ident = signed_object.generate_identifier(signingkey)
        node = Node(identifier=ident, signingkey=signingkey,
                    address=("localhost", 10004))
        node.is_peer = True
        path = tempfile.mkdtemp()
        gossip = Gossip(node)
        journal = Journal(node,
                          gossip,
                          gossip.dispatcher,
                          consensus=DevModeConsensus(),
                          data_directory=path)
        transaction = BondTransaction({
            "UpdateType": "CreateQuote",
            'Updates': [{
                "UpdateType": "CreateQuote",
                "Firm": "ABCD",
                "Isin": "US912828R770",
                "BidPrice": "101",
                "BidQty": 250000,
                "AskPrice": "101",
                "AskQty": 250000,
                "object_id": "555553716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        journal.global_store.TransactionStores['/BondTransaction'] = \
            self.store
        matched_orders = _generate_match_orders(journal)
        self.assertEquals(matched_orders, [])
예제 #26
0
    def test_create_redemption(self):
        self._set_clock(2016, 4, 1, 1)
        org = self.store.lookup("organization:name", "Second Bank")
        bond = self.store.lookup("bond:cusip", "912828R77")
        coupon = Family._create_redemption(self.store, bond, org)
        self.assertIsNotNone(coupon)
        transaction = BondTransaction(coupon)
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        first_bond = self.store["34d813716009ca1786222a44347ccff258a4ab6029" +
                                "d936664fde0d13f239org1"]["amount"]
        second_bond = self.store["34d813716009ca1786222a44347ccff258a4ab6029" +
                                 "d936664fde0d13f23992b7"]["amount"]
        first_usd = self.store["34d813716009ca1786222a44347ccff258a4ab6029" +
                               "d936664fde0d13f23992b5"]["amount"]
        second_usd = self.store["34d813716009ca1786222a44347ccff258a4ab6029" +
                                "d936664fde0d13f23org1"]["amount"]
        self.assertEquals(first_bond, 200000)
        self.assertEquals(second_bond, 0)
        self.assertEquals(first_usd, 100000)
        self.assertEquals(second_usd, 100000000 - 100000)
예제 #27
0
 def test_create_receipt_update_bad_type(self):
     org = self.store.lookup("organization:name", "Second Bank")
     bond = self.store.lookup("bond:isin", "US912828R770")
     transaction = BondTransaction({
         'Updates': [{
             'UpdateType': 'CreateReceipt',
             'PaymentType': 'PayOut',
             'BondID': bond['object-id'],
             'PayeeID': org['object-id']
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("PaymentType is not Coupon or Redemption")
     except InvalidTransactionError:
         pass
예제 #28
0
 def test_create_quote_bond(self):
     transaction = BondTransaction({
         "UpdateType": "CreateQuote",
         'Updates': [{
             "UpdateType": "CreateQuote",
             "Firm": "ABCD",
             "BidPrice": "98-05.875",
             "BidQty": 25000,
             "AskPrice": "98-06.875",
             "AskQty": 25000
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("No Bond ")
     except InvalidTransactionError:
         pass
예제 #29
0
 def test_create_receipt_update_early_redemption(self):
     self._set_clock(2015, 4, 1, 1)
     org = self.store.lookup("organization:name", "Second Bank")
     bond = self.store.lookup("bond:isin", "US912828R770")
     transaction = BondTransaction({
         'Updates': [{
             'UpdateType': 'CreateReceipt',
             'PaymentType': 'Redemption',
             'BondID': bond['object-id'],
             'PayeeID': org['object-id']
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("Early Redemption")
     except InvalidTransactionError:
         pass
예제 #30
0
 def test_create_quote_bad_firm(self):
     transaction = BondTransaction({
         "UpdateType": "CreateQuote",
         'Updates': [{
             "UpdateType": "CreateQuote",
             "Firm": "ABD",
             "Isin": "US912828R770",
             "BidPrice": "98-05.875",
             "BidQty": 25000,
             "AskPrice": "98-06.875",
             "AskQty": 25000
         }]
     })
     transaction.sign_object(self.key)
     try:
         transaction.check_valid(self.store)
         self.fail("Incorrect Organization")
     except InvalidTransactionError:
         pass