Пример #1
0
 def test_is_liquidated(self):
     fund = Fund('F1', {'XXX': 10, 'YYY': 10}, 5, 2, 3)
     self.assertFalse(fund.is_in_margin_call())
     fund.is_liquidating = True
     self.assertTrue(fund.is_in_margin_call())
     fund.is_liquidating = False
     self.assertFalse(fund.is_in_margin_call())
    def test_update_funds(self):
        assets = {
            'XXX': Asset(1, 20, 1.5, 'XXX'),
            'YYY': Asset(1, 20, 1.5, 'yyy')
        }
        f1 = Fund('F1', {'XXX': 10, 'YYY': 10}, 5, 2, 0.25)
        f2 = Fund('F1', {'XXX': 5, 'YYY': 4}, 5, 2, 0.25)
        f3 = Fund('F1', {'XXX': 20, 'YYY': 4}, 5, 2, 4)

        network = AssetFundsNetwork({
            'f1': f1,
            'f2': f2,
            'f3': f3
        }, assets, MockMarketImpactTestCalculator())
        network.update_funds()

        self.assertTrue(f1.is_in_margin_call())
        self.assertFalse(f1.default())

        self.assertTrue(f2.is_in_margin_call())
        self.assertTrue(f2.default())

        self.assertFalse(f3.is_in_margin_call())
        self.assertFalse(f3.default())
        """a0 = Asset(price=1, daily_volume=40, volatility=1.5, symbol='a0')
Пример #3
0
 def test_update_state_margin_only(self):
     assets = {
         'XXX': Asset(1, 20, 1.5, 'XXX'),
         'YYY': Asset(1, 20, 1.5, 'yyy')
     }
     fund = Fund('F1', {'XXX': 10, 'YYY': 10}, 5, 2, 0.25)
     fund.update_state(assets)
     self.assertTrue(fund.is_in_margin_call())
     self.assertFalse(fund.default())