Beispiel #1
0
 def test_linearity_add(self, 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_pnl(self.universe_hand)
     result1 = trade1.series_pnl(self.universe_hand)
     resultA = tradeA.series_pnl(self.universe_hand)
     assert np.allclose(result0 + result1, resultA)
Beispiel #2
0
 def test_value_zero(self):
     trade = Trade(asset=["A0", "A1"], lot=[0, 0], open_bar=1, shut_bar=3)
     result = trade.series_pnl(self.universe_hand)
     expected = np.zeros((self.universe_hand.n_bars))
     assert np.allclose(result, expected)