Ejemplo n.º 1
0
 def test_compute_compute_curr_leverage(self):
     assets = {
         'XXX': Asset(1, 20, 1.5, 'XXX'),
         'YYY': Asset(4, 20, 1.5, 'yyy')
     }
     fund = Fund('F1', {'XXX': 10, 'YYY': 10}, 5, 2, 3)
     self.assertEqual(0.25, fund.compute_curr_leverage(assets))
 def test_run_intraday_simulation_goal_leverage_reached(self):
     a0 = Asset(price=1, daily_volume=40, volatility=1.5, symbol='a0')
     a1 = Asset(price=2, daily_volume=40, volatility=1.5, symbol='a1')
     f0 = Fund('f0', {'a0': 10},
               initial_capital=2,
               initial_leverage=8,
               tolerance=2)
     f1 = Fund('f1', {
         'a0': 10,
         'a1': 1
     },
               initial_capital=1,
               initial_leverage=1,
               tolerance=3)
     assets = {'a0': a0, 'a1': a1}
     network = AssetFundsNetwork({
         'f0': f0,
         'f1': f1
     }, assets, MockMarketImpactTestCalculator())
     network.run_intraday_simulation(2, 0.8)
     self.assertTrue(f0.compute_curr_leverage(assets) <= 0.8)
     self.assertTrue(f1.compute_curr_leverage(assets) <= 0.8)