Пример #1
0
 def test_hcost_pos(self):
     """Test hcost function, positive positions."""
     self.hcost_term.borrow_costs += 0
     t = self.returns.index[1]
     h = copy.copy(self.portfolio)
     results = SimulationResult(initial_portfolio=h, policy=None,
                                cash_key='cash', simulator=self.Simulator)
     u = pd.Series(index=self.portfolio.index, data=1E4)
     h_next, u = self.Simulator.propagate(h, u, t=t)
     results.log_simulation(t=t, u=u, h_next=h_next,
                            risk_free_return=0., exec_time=0)
     self.assertAlmostEquals(results.simulator_HcostModel.sum().sum(), 0.)
Пример #2
0
 def test_propag_neg(self):
     """Test propagation of portfolio, negative trades."""
     t = self.returns.index[1]
     h = copy.copy(self.portfolio)
     results = SimulationResult(initial_portfolio=h, policy=None,
                                cash_key='cash', simulator=self.Simulator)
     u = pd.Series(index=self.portfolio.index, data=[-1E4] * 29)
     h_next, u = self.Simulator.propagate(h, u, t=t)
     results.log_simulation(t=t, u=u, h_next=h_next,
                            risk_free_return=0., exec_time=0)
     self.assertAlmostEquals(
         results.simulator_TcostModel.sum().sum(), 157.604, 3)
     self.assertAlmostEquals(
         results.simulator_HcostModel.sum().sum(), 0., 3)
     self.assertAlmostEqual(sum(h_next), 28908611.931, 3)