コード例 #1
0
class ForeignExchangeTest(unittest.TestCase):
    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.asset_manager_id = random.randint(1, 2**31 - 1)
        self.fx_forward = generate_fx_forward(
            asset_manager_id=self.asset_manager_id)
        self.asset_id = self.fx_forward.asset_id
        self.assets_interface = AssetsInterface(environment=ENVIRONMENT)

    def tearDown(self):
        pass

    def test_ForeignExchange(self):
        fx = generate_foreignexchange(asset_id='USDJPY')
        self.assertEqual(type(fx), ForeignExchange)
        self.assertEqual(self.fx_forward.pricing_method(), 'Derived')

    def test_ForeignExchangeForward(self):
        self.assertEqual(type(self.fx_forward), ForeignExchangeForward)

    def test_ForeignExchangeSpot(self):
        fx_spot = generate_fx_spot(asset_manager_id=self.asset_manager_id)
        self.assertEqual(type(fx_spot), ForeignExchangeSpot)

    def test_Persistence(self):
        self.assets_interface.new(self.fx_forward)
        fx_forward = self.assets_interface.retrieve(
            asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(fx_forward, self.fx_forward)
コード例 #2
0
class ForeignExchangeTest(unittest.TestCase):

    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.asset_manager_id = random.randint(1, 2**31-1)
        self.fx_forward = generate_fx_forward(asset_manager_id=self.asset_manager_id)
        self.asset_id = self.fx_forward.asset_id
        self.assets_interface = AssetsInterface(environment=STAGE)

    def tearDown(self):
        pass

    def test_ForeignExchange(self):
        fx = generate_foreignexchange(asset_id='USDJPY')
        self.assertEqual(type(fx), ForeignExchange)
        self.assertEqual(self.fx_forward.pricing_method(), 'Derived')

    def test_ForeignExchangeForward(self):
        self.assertEqual(type(self.fx_forward), ForeignExchangeForward)

    def test_ForeignExchangeSpot(self):
        fx_spot = generate_fx_spot(asset_manager_id=self.asset_manager_id)
        self.assertEqual(type(fx_spot), ForeignExchangeSpot)

    def test_Persistence(self):
        self.assets_interface.new(self.fx_forward)
        fx_forward = self.assets_interface.retrieve(asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(fx_forward, self.fx_forward)

    def test_rates(self):
        examples = [
            (('SGD', 'USD'),
             {'forward_rate': Decimal('1.354'), 'spot_reference': Decimal('1.356')},
             {'fwd_points': Decimal('-20')}),
            (('SGD', 'USD'),
             {'spot_reference': Decimal('1.356'), 'fwd_points': Decimal('-20')},
             {'forward_rate': Decimal('1.354')}),
            (('SGD', 'USD'),
             {'forward_rate': Decimal('1.354'), 'fwd_points': Decimal('-20')},
             {'spot_reference': Decimal('1.356')}),
        ]
        for a, kw, expect in examples:
            expect.update(kw)
            result = calculate_rates(*a, **kw)
            self.assertEqual(result, expect)
コード例 #3
0
class BondTest(unittest.TestCase):
    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.asset_manager_id = random.randint(1, 2**31 - 1)
        self.bond = generate_bond(asset_manager_id=self.asset_manager_id)
        self.asset_id = self.bond.asset_id
        self.assets_interface = AssetsInterface(environment=ENVIRONMENT)

    def tearDown(self):
        pass

    def test_Bond(self):
        self.assertEqual(type(self.bond), BondGovernment)

    def test_Persistence(self):
        self.assets_interface.new(self.bond)
        bond = self.assets_interface.retrieve(
            asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(bond, self.bond)
コード例 #4
0
class ForeignExchangeTest(unittest.TestCase):

    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.asset_manager_id = random.randint(1, 2**31-1)
        self.fx_forward = generate_fx_forward(asset_manager_id=self.asset_manager_id)
        self.asset_id = self.fx_forward.asset_id
        self.assets_interface = AssetsInterface()

    def tearDown(self):
        pass

    def test_ForeignExchangeOption(self):
        self.assertEqual(type(self.fx_forward), ForeignExchangeForward)

    def test_Persistence(self):
        self.assets_interface.new(self.fx_forward)
        fx_forward = self.assets_interface.retrieve(asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(fx_forward, self.fx_forward)
コード例 #5
0
class FutureTest(unittest.TestCase):

    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.maxDiff = None
        self.asset_manager_id = random.randint(1, 2**31-1)
        self.future = generate_future(asset_manager_id=self.asset_manager_id)
        self.asset_id = self.future.asset_id
        self.assets_interface = AssetsInterface()

    def tearDown(self):
        pass

    def test_Future(self):
        self.assertEqual(type(self.future), Future)

    def test_Persistence(self):
        self.assets_interface.new(self.future)
        future = self.assets_interface.retrieve(asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(future, self.future)
コード例 #6
0
class ForeignExchangeOptionTest(unittest.TestCase):
    def setUp(self):
        self.longMessage = True  # Print complete error message on failure
        self.asset_manager_id = random.randint(1, 2**31 - 1)
        self.fx_option = generate_fx_option(
            asset_manager_id=self.asset_manager_id)
        self.asset_id = self.fx_option.asset_id
        self.assets_interface = AssetsInterface(environment=STAGE)

    def tearDown(self):
        pass

    def test_ForeignExchangeOption(self):
        self.assertEqual(type(self.fx_option), ForeignExchangeOption)

    def test_Optionality(self):
        self.assertEqual(type(self.fx_option.strike), Decimal)
        self.assertIn(self.fx_option.option_type, ['Put', 'Call'])

    def test_Persistence(self):
        self.assets_interface.new(self.fx_option)
        fx_option = self.assets_interface.retrieve(
            asset_manager_id=self.asset_manager_id, asset_id=self.asset_id)
        self.assertEqual(fx_option, self.fx_option)