Exemple #1
0
 def test_reindex_different_fills(self):
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3], method=None)
     print(ds.data)
     assert pd.isnull(
         ds.data.set_index(['symbol', 'timestamp']).at[('C', 3), 'high'])
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3, 4], method='bfill')
     assert ds.data.set_index(['symbol', 'timestamp']).at[('B', 2),
                                                          'close'] == 19
Exemple #2
0
 def test_reindex_different_fills(self):
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3], method=None)
     print(ds.data)
     assert pd.isnull(
         ds.data.set_index(["symbol", "timestamp"]).at[("C", 3), "high"]
     )
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3, 4], method="bfill")
     assert ds.data.set_index(["symbol", "timestamp"]).at[("B", 2), "close"] == 19
Exemple #3
0
 def test_reindex(self):
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3])
     assert len(ds.data) == 9
     # Check values
     assert ds.data.set_index(["symbol", "timestamp"]).at[("A", 1), "open"] == 0
     assert ds.data.set_index(["symbol", "timestamp"]).at[("B", 2), "close"] == 7
     assert ds.data.set_index(["symbol", "timestamp"]).at[("C", 3), "high"] == 9
     ds.reindex([1, 2, 3, 4])
     assert len(ds.data) == 12
Exemple #4
0
 def test_reindex(self):
     ds = DataSource(self.df)
     ds.reindex([1, 2, 3])
     assert len(ds.data) == 9
     # Check values
     assert ds.data.set_index(['symbol', 'timestamp']).at[('A', 1),
                                                          'open'] == 0
     assert ds.data.set_index(['symbol', 'timestamp']).at[('B', 2),
                                                          'close'] == 7
     assert ds.data.set_index(['symbol', 'timestamp']).at[('C', 3),
                                                          'high'] == 9
     ds.reindex([1, 2, 3, 4])
     assert len(ds.data) == 12