예제 #1
0
 def test_linearity_add(self, net, seed):
     np.random.seed(seed)
     lot0, lot1 = np.random.random(2)
     trade0 = Trade(asset="A0", lot=lot0, open_bar=1, shut_bar=3)
     trade1 = Trade(asset="A0", lot=lot1, open_bar=1, shut_bar=3)
     tradeA = Trade(asset="A0", lot=lot0 + lot1, open_bar=1, shut_bar=3)
     result0 = trade0.series_exposure(self.universe_hand, net=net)
     result1 = trade1.series_exposure(self.universe_hand, net=net)
     resultA = tradeA.series_exposure(self.universe_hand, net=net)
     assert np.allclose(result0 + result1, resultA)
예제 #2
0
    def test_hand(self, net):
        trade = Trade(asset=["A0", "A1"], lot=[2, -3], open_bar=1, shut_bar=3)
        result = trade.series_exposure(net=net, universe=self.universe_hand)
        if net:
            expected = [0, -19, 5, -22, 0, 0, 0]
        else:
            expected = [0, 23, 11, 26, 0, 0, 0]

        assert np.allclose(result, expected)
예제 #3
0
 def test_value_zero(self):
     trade = Trade(asset=["A0", "A1"], lot=[0, 0], open_bar=1, shut_bar=3)
     result = trade.series_exposure(self.universe_hand)
     expected = np.zeros((self.universe_hand.n_bars))
     assert np.allclose(result, expected)