예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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
예제 #5
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
예제 #6
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
예제 #7
0
    def test_libor_update_duplicate_date(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='G38pbExUmKqKzdC07QJS1OJSglnpLKGr+PMu4muigey37CdT2P'
                          '7d0PBQxmaWNjtsADdPxQAS5FhtHOQbtD41fkU=')

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

        try:
            transaction.check_valid(store)
        except InvalidTransactionError:
            self.fail('This transaction should be valid')

        transaction.apply(store)

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #8
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
예제 #9
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
    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
    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
예제 #12
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
예제 #13
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
예제 #14
0
    def setUp(self):
        self.key = signed_object.generate_signing_key()
        participant = CreateParticipantUpdate("CreateParticipant", "testuser")
        object_id = participant._object_id
        transaction = BondTransaction({})
        transaction._updates = [participant]
        self.store = ObjectStore()
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
        sub = self.store.lookup("participant:username",
                                "testuser")["object-id"]

        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "Test Bank",
                "ticker":
                "T",
                "pricing_source":
                "ABCD",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
    def test_libor_update(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': 0.1
                },
                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)
        except InvalidTransactionError as e:
            self.fail('This transaction should be valid\n error:' + str(e))

        try:
            store.lookup('libor:date', '2016-05-24')
            self.fail('LIBOR data for 2016-05-24 should not be in store')
        except KeyError:
            pass

        transaction.apply(store)

        self.assertIsNotNone(store.lookup('libor:date', '2016-05-24'))

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-25',
                rates={
                    'Overnight': '0.1',
                    'OneWeek': '-0.1',
                    'OneMonth': '0',
                    'TwoMonth': 0.1,
                    'ThreeMonth': -0.1,
                    'SixMonth': 0,
                    'OneYear': 1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
        except InvalidTransactionError as e:
            self.fail('This transaction should be valid\n error: ' + str(e))

        try:
            store.lookup('libor:date', '2016-05-25')
            self.fail('LIBOR data for 2016-05-25 should not be in store')
        except KeyError:
            pass

        transaction.apply(store)

        self.assertIsNotNone(store.lookup('libor:date', '2016-05-25'))
예제 #16
0
    def setUp(self):
        self.key = signed_object.generate_signing_key()
        participant = CreateParticipantUpdate("CreateParticipant", "testuser")
        object_id = participant._object_id
        transaction = BondTransaction({})
        transaction._updates = [participant]
        self.store = ObjectStore()
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
        sub = self.store.lookup("participant:username",
                                "testuser")["object-id"]

        self._set_clock(1994, 10, 4, 0)

        # add another organization
        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "First Bank",
                "ticker":
                "T",
                "pricing_source":
                "ABCD",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "Second Bank",
                "ticker":
                "I",
                "pricing_source":
                "EFGH",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        transaction = BondTransaction({
            "UpdateType":
            "CreateBond",
            'Updates': [{
                "UpdateType": "CreateBond",
                "amount_outstanding": 42671000000,
                'corporate_debt_ratings': {
                    "Fitch": "AAA",
                    "Moodys": "AAA",
                    "S&P": "AA+"
                },
                "coupon_rate": 1,
                "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/01/2016",
                "issuer": "T"
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        org = self.store.lookup("organization:name", "Second Bank")
        # add holding?
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org["object-id"],
                "asset_type":
                "Currency",
                "asset_id":
                "USD",
                "amount":
                0,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b5"
            }]
        })
        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")

        bond = self.store.lookup("bond:cusip", "912828R77")
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org["object-id"],
                "asset_type":
                "Bond",
                "asset_id":
                bond["object-id"],
                "amount":
                100000,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        org1 = self.store.lookup("organization:name", "First Bank")
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org1["object-id"],
                "asset_type":
                "Currency",
                "asset_id":
                "USD",
                "amount":
                100000000,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23org1"
            }]
        })
        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")

        bond = self.store.lookup("bond:cusip", "912828R77")
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org1["object-id"],
                "asset_type":
                "Bond",
                "asset_id":
                bond["object-id"],
                "amount":
                100000,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f239org1"
            }]
        })
        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")
    def test_libor_update_invalid_date(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-01-32',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                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

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-12-32',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HG/+Byml9CU13jdMD9TvOtlNlLvAO5jzBGUqoJGSng2ksojoh8'
                          'mUxYKJ4rTE5pZ4Q1S+lHRLuQLVgprhQkY25eQ=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2015-02-29',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-02-30',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-13-30',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G4JyMWYLEWwwSQlOLHWDclAKB2kXersC/cuc3VbzyRTJ92Nj'
                          'e2nGPgSIsQzQ4uR94r9pYi1S6E4z7zQrdwCCKlg=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-00-15',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-01-00',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

        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 test_libor_update_invalid_date_format(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='05/24/2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G9AKVsz3JlT/apjOieVwFc8PYkIXu787S0JkIYNY59GTI7h'
                          '0pLP5SVqxycXkXJg+xtR8lK5vT0JeNAoYxpg3bzI=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='05-24-2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G7OL7YDOVHzOevEaGgg1PvnpxiRhws7vdut3F1RUdMXDNH6gH'
                          'sY9nk/Zt+WwQYo/4QhZOY6CO0Inv5HUi8MyrPo=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='May 24, 2016',
                rates={
                    'OneWeek': 0.1,
                    'Overnight': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HOV3d7ESaywjUB3c3qPcV4DBKKpZR0tokeILinSEVdapNi2y7m'
                          'NYrhAXjdgzbPzTGFmp0btjAPVFFUvzYKgOYvo=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='24-May-2016',
                rates={
                    'OneWeek': 0.1,
                    'Overnight': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HEnC3vEdBhBcHAndjgouHj4T+ILyOX2PTCveiShIb8VK0woyM'
                          '4UheSM4f2ucv8Xj/ySMhAl16JQYaDk6mZ7fARI=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='May 24 2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature="G9tsTDOQG/dG1f1rrduq7/rBxYqmWujbM7iMUuJc94pe1Ue7kt"
                          "gbxlIqzND/+sxWR+PjtCKlzcN/AmW1MyBSAfs=")

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='24 May 2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HAjOWJgM9yP20fJ4pqD3x3dCrutwIYs0u3PepaWqNZXYC8L13'
                          'xbqaCJ3/6vNX6BZRi9BD03t9VXxkmKHI6m/SOM=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1,
                },
                signature='HM6jsivVl3OUszzyh8cjo68fLHlPsIj3kyxJ0u0CiwVDzXyKF'
                          '0K8cpS3FvoYX9xOfG1i8jtxiMt0+EkAjJHxvP8=')

        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_date_format(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='05/24/2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                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

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='05-24-2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G7OL7YDOVHzOevEaGgg1PvnpxiRhws7vdut3F1RUdMXDNH6gH'
                          'sY9nk/Zt+WwQYo/4QhZOY6CO0Inv5HUi8MyrPo=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='May 24, 2016',
                rates={
                    'OneWeek': 0.1,
                    'Overnight': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='24-May-2016',
                rates={
                    'OneWeek': 0.1,
                    'Overnight': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='May 24 2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='24 May 2016',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1,
                },
                libor_public_key=libor_public_key)
        update.sign_update_object(libor_key)

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
예제 #20
0
    def test_libor_update_invalid_date(self):
        key = signed_object.generate_signing_key()
        store = ObjectStore()
        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-01-32',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature="G+9NKjqnXnEtMbYWbuUeiQqk3dcCdEKi1lf0V3W5/XwTnp5UwA"
                          "eRcyeLALzsDhdnC3/qX2dBjewrA8vLFBOBNMw=")

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-12-32',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HG/+Byml9CU13jdMD9TvOtlNlLvAO5jzBGUqoJGSng2ksojoh8'
                          'mUxYKJ4rTE5pZ4Q1S+lHRLuQLVgprhQkY25eQ=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2015-02-29',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G9+MiYwYtErSOAd7FsWhda3pP9/iuNt+XWmHWdHk8Qs0qzCC'
                          'ZxCjoM8onOalFwP9a0QtIQOnCOuhU8XpUOez6qk=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-02-30',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G48nBn9dGbSDsN5NlEXVo30AE8AoAda5s9YzgSC1IO81GiB32'
                          'O9kSPts+z7PGsdAhAOnv5OvTzsUVIntPBQwJ44=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-13-30',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='G4JyMWYLEWwwSQlOLHWDclAKB2kXersC/cuc3VbzyRTJ92Nj'
                          'e2nGPgSIsQzQ4uR94r9pYi1S6E4z7zQrdwCCKlg=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-00-15',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HE6eRRqetDR2hFYxUf9dY/H9LmN13yWL5FKnx+g9ME1WF/oB52'
                          'OZlq0dIBwRemFA7tlN0jWgFgpBHrIG5E0avzk=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-01-00',
                rates={
                    'Overnight': 0.1,
                    'OneWeek': 0.1,
                    'OneMonth': 0.1,
                    'TwoMonth': 0.1,
                    'ThreeMonth': 0.1,
                    'SixMonth': 0.1,
                    'OneYear': 0.1
                },
                signature='HC29Ih92jlFIj/C5zD8ulPpvkEsNKXfXOk6I4FTqsdAyq+H8igh'
                          '76evTLbgpF5AQ956I7gGt4ACNUXdjMdH19QQ=')

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

        try:
            transaction.check_valid(store)
            self.fail('This transaction should be invalid')
        except InvalidTransactionError:
            pass
    def setUp(self):
        self.key = signed_object.generate_signing_key()
        participant = CreateParticipantUpdate("CreateParticipant", "testuser")
        object_id = participant._object_id
        transaction = BondTransaction({})
        transaction._updates = [participant]
        self.store = ObjectStore()
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
        sub = self.store.lookup("participant:username",
                                "testuser")["object-id"]

        transaction = BondTransaction({
            'Updates': [{
                'UpdateType': 'Clock',
                'Blocknum': 0,
                'PreviousBlockId': 0,
                'Timestamp': time.time()
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        # add another organization
        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "First Bank",
                "ticker":
                "T",
                "pricing_source":
                "ABCD",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "Second Bank",
                "ticker":
                "I",
                "pricing_source":
                "EFGH",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        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)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        org = self.store.lookup("organization:name", "First Bank")
        # add holding?
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org["object-id"],
                "asset_type":
                "Currency",
                "asset_id":
                "USD",
                "amount":
                0,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b5"
            }]
        })
        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")

        bond = self.store.lookup("bond:cusip", "912828R77")
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org["object-id"],
                "asset_type":
                "Bond",
                "asset_id":
                bond["object-id"],
                "amount":
                2500000,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        org2 = self.store.lookup("organization:name", "Second Bank")
        transaction = BondTransaction({
            "UpdateType":
            "CreateHolding",
            'Updates': [{
                "UpdateType":
                "CreateHolding",
                "owner_id":
                org2["object-id"],
                "asset_type":
                "Currency",
                "asset_id":
                "USD",
                "amount":
                2500000,
                "object_id":
                "34d813716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b6"
            }]
        })
        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")

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

        transaction = BondTransaction({
            "UpdateType":
            "CreateQuote",
            'Updates': [{
                "UpdateType":
                "CreateQuote",
                "Firm":
                "ABCD",
                "Isin":
                "US912828R770",
                "BidPrice":
                "101",
                "BidQty":
                250000,
                "AskPrice":
                "101",
                "AskQty":
                250000,
                "object_id":
                "555553716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        try:
            transaction.sign_object(self.key)
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")

        org2 = self.store.lookup("organization:name", "Second Bank")
        transaction = BondTransaction({
            "UpdateType":
            "CreateOrder",
            'Updates': [{
                "UpdateType":
                "CreateOrder",
                "Action":
                "Buy",
                "OrderType":
                "Limit",
                "FirmId":
                org2["object-id"],
                "Isin":
                bond["isin"],
                "Quantity":
                100000,
                "LimitPrice":
                "98-05.875",
                "LimitYield":
                0.015,
                "QuoteId":
                "555553716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7",
                "object_id":
                "123453716009ca1786222a44347ccff258a4ab6029" +
                "d936664fde0d13f23992b7"
            }]
        })
        # quote-id
        transaction.sign_object(self.key)
        try:
            transaction.check_valid(self.store)
            transaction.apply(self.store)
        except InvalidTransactionError:
            self.fail("This should be valid")
    def setUp(self):
        self.key = signed_object.generate_signing_key()
        participant = CreateParticipantUpdate("CreateParticipant", "testuser")
        object_id = participant._object_id
        transaction = BondTransaction({})
        transaction._updates = [participant]
        self.store = ObjectStore()
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
        sub = self.store.lookup("participant:username",
                                "testuser")["object-id"]
        transaction = BondTransaction({
            'Updates': [{
                'UpdateType': 'Clock',
                'Blocknum': 0,
                'PreviousBlockId': 0,
                'Timestamp': time.time()
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        transaction = BondTransaction({
            "UpdateType":
            "CreateOrganization",
            'Updates': [{
                "UpdateType":
                "CreateOrganization",
                "name":
                "Test Bank",
                "ticker":
                "T",
                "pricing_source":
                "ABCD",
                "industry":
                "Test",
                "authorization": [{
                    "ParticipantId": sub,
                    "Role": "marketmaker"
                }]
            }]
        })
        transaction.sign_object(self.key)
        transaction.check_valid(self.store)
        transaction.apply(self.store)

        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)
        transaction.check_valid(self.store)
        transaction.apply(self.store)
예제 #23
0
    def test_libor_update(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='G38pbExUmKqKzdC07QJS1OJSglnpLKGr+PMu4muigey37CdT2P7'
                          'd0PBQxmaWNjtsADdPxQAS5FhtHOQbtD41fkU=')

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

        try:
            transaction.check_valid(store)
        except InvalidTransactionError:
            self.fail('This transaction should be valid')

        try:
            store.lookup('libor:date', '2016-05-24')
            self.fail('LIBOR data for 2016-05-24 should not be in store')
        except KeyError:
            pass

        transaction.apply(store)

        self.assertIsNotNone(store.lookup('libor:date', '2016-05-24'))

        update = \
            CreateLIBORUpdate(
                update_type='CreateLIBOR',
                date='2016-05-25',
                rates={
                    'Overnight': '0.1',
                    'OneWeek': '-0.1',
                    'OneMonth': '0',
                    'TwoMonth': 0.1,
                    'ThreeMonth': -0.1,
                    'SixMonth': 0,
                    'OneYear': 1
                },
                signature='GzcrWBTv180bCZcKkluVOSPcqNbNrcLCj3FocJH9uliKkl+3yNR'
                          'yhj5DAIsTWOY2ZwrcDVEMOp1P1jJpfctst6I=')
        transaction._updates = [update]
        transaction.sign_object(key)

        try:
            transaction.check_valid(store)
        except InvalidTransactionError:
            self.fail('This transaction should be valid')

        try:
            store.lookup('libor:date', '2016-05-25')
            self.fail('LIBOR data for 2016-05-25 should not be in store')
        except KeyError:
            pass

        transaction.apply(store)

        self.assertIsNotNone(store.lookup('libor:date', '2016-05-25'))