def test_last_index(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) last = vf.last_index() self.assertIsInstance(last, str) self.assertEqual('2019-03-01', last) last = vf.last_index(as_string=False) self.assertIsInstance(last, pd.Timestamp)
def test_abs_daily_change(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) df = vf.abs_daily_change() self.assertIsInstance(df, pd.DataFrame) self.assertEqual(0, df.DOW['2019-01-21']) # print(df) df = vf.abs_daily_change(start='2019-02-28', end='2020-01-31')
def test_first_index(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) first = vf.first_index() self.assertIsInstance(first, str) self.assertEqual('2019-01-02', first) first = vf.first_index(as_string=False) self.assertIsInstance(first, pd.Timestamp)
def test_rel_change(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) df = vf.rel_change() self.assertIsInstance(df, pd.DataFrame) self.assertEqual(df.DOW['2019-01-18'], df.DOW['2019-01-21'])
def test_last(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) self.assertIsInstance(vf.last(), pd.DataFrame)
def test_construction_with_multiple(self): vf = ft.ValueFrame([ft.df_indices(ft.Idx.DOW), ft.df_indices(ft.Idx.AEX)]) self.assertListEqual(list(vf.df.columns), ['DOW', 'AEX'])
def test_construction_with_one(self): vf = ft.ValueFrame(ft.df_index(ft.Idx.DOW)) self.assertListEqual(list(vf.df.columns), ['close', 'open', 'high', 'low', 'volume', 'change'])
def test_display_rel_change(self): vf = ft.ValueFrame(ft.df_indices([ft.Idx.AEX, ft.Idx.DOW])) vf.display_rel_change()