Ejemplo n.º 1
0
 def test_linearity_mul(self, a, seed):
     universe = make_randomwalk(seed=seed)
     trade0 = RandomTrader(n_trades=1, seed=seed).run(universe).trades[0]
     tradeA = a * trade0
     result0 = trade0.final_pnl(universe)
     resultA = tradeA.final_pnl(universe)
     assert np.allclose(a * result0, resultA)
Ejemplo n.º 2
0
    def test_random(self, seed):
        universe = make_randomwalk(n_bars=100, n_assets=10, seed=seed)
        trade = RandomTrader(n_trades=1, seed=seed).run(universe).trades[0]
        result = trade.final_pnl(universe)
        expected = trade.array_pnl(universe)[-1]

        assert np.allclose(result, expected)