Esempio n. 1
0
    def test_linearity_mul(self, a):
        universe = make_randomwalk()
        strategy = RandomStrategy().run(universe)

        result = a * ts.wealth(strategy.trades, universe)
        expected = ts.wealth([a * t for t in strategy.trades], universe)

        assert_allclose(result, expected)
Esempio n. 2
0
    def test_linearity_add(self):
        universe = make_randomwalk()
        s0 = RandomStrategy().run(universe)
        s1 = RandomStrategy().run(universe)

        result = ts.wealth(s0.trades, universe) + ts.wealth(s1.trades, universe)
        expected = ts.wealth(s0.trades + s1.trades, universe)

        assert_allclose(result, expected)
Esempio n. 3
0
    def test_ts(self):
        universe = make_randomwalk()
        strategy = RandomStrategy().run(universe)
        trades = strategy.trades

        assert_equal(strategy.wealth().values, ts.wealth(trades, universe))
        assert_equal(strategy.drawdown().values, ts.drawdown(trades, universe))
Esempio n. 4
0
    def test_zero(self):
        """
        result = 0 if trade is zero
        """
        universe = make_randomwalk()
        strategy = RandomStrategy(min_lot=0, max_lot=0).run(universe)

        result = ts.wealth(strategy.trades, universe)
        expected = np.zeros_like(result)

        assert_equal(result, expected)