Tests the future_symbol API function.
(self)
| 708 | algo.symbol({'foo': 'bar'}) |
| 709 | |
| 710 | def test_future_symbol(self): |
| 711 | """ Tests the future_symbol API function. |
| 712 | """ |
| 713 | algo = self.make_algo() |
| 714 | algo.datetime = pd.Timestamp('2006-12-01', tz='UTC') |
| 715 | |
| 716 | # Check that we get the correct fields for the CLG06 symbol |
| 717 | cl = algo.future_symbol('CLG06') |
| 718 | self.assertEqual(cl.sid, 5) |
| 719 | self.assertEqual(cl.symbol, 'CLG06') |
| 720 | self.assertEqual(cl.root_symbol, 'CL') |
| 721 | self.assertEqual(cl.start_date, pd.Timestamp('2005-12-01', tz='UTC')) |
| 722 | self.assertEqual(cl.notice_date, pd.Timestamp('2005-12-20', tz='UTC')) |
| 723 | self.assertEqual(cl.expiration_date, |
| 724 | pd.Timestamp('2006-01-20', tz='UTC')) |
| 725 | |
| 726 | with self.assertRaises(SymbolNotFound): |
| 727 | algo.future_symbol('') |
| 728 | |
| 729 | with self.assertRaises(SymbolNotFound): |
| 730 | algo.future_symbol('PLAY') |
| 731 | |
| 732 | with self.assertRaises(SymbolNotFound): |
| 733 | algo.future_symbol('FOOBAR') |
| 734 | |
| 735 | # Supplying a non-string argument to future_symbol() |
| 736 | # should result in a TypeError. |
| 737 | with self.assertRaises(TypeError): |
| 738 | algo.future_symbol(1) |
| 739 | |
| 740 | with self.assertRaises(TypeError): |
| 741 | algo.future_symbol((1,)) |
| 742 | |
| 743 | with self.assertRaises(TypeError): |
| 744 | algo.future_symbol({1}) |
| 745 | |
| 746 | with self.assertRaises(TypeError): |
| 747 | algo.future_symbol([1]) |
| 748 | |
| 749 | with self.assertRaises(TypeError): |
| 750 | algo.future_symbol({'foo': 'bar'}) |
| 751 | |
| 752 | |
| 753 | class TestSetSymbolLookupDate(zf.WithMakeAlgo, zf.ZiplineTestCase): |
nothing calls this directly
no test coverage detected