|
58 | 58 | TradingControlViolation,
|
59 | 59 | AccountControlViolation,
|
60 | 60 | SymbolNotFound,
|
61 |
| - RootSymbolNotFound, |
62 | 61 | UnsupportedDatetimeFormat,
|
63 | 62 | CannotOrderDelistedAsset,
|
64 | 63 | SetCancelPolicyPostInit,
|
@@ -726,108 +725,6 @@ def test_future_symbol(self):
|
726 | 725 | with self.assertRaises(TypeError):
|
727 | 726 | algo.future_symbol({'foo': 'bar'})
|
728 | 727 |
|
729 |
| - def test_future_chain_offset(self): |
730 |
| - # November 2006 December 2006 |
731 |
| - # Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa |
732 |
| - # 1 2 3 4 1 2 |
733 |
| - # 5 6 7 8 9 10 11 3 4 5 6 7 8 9 |
734 |
| - # 12 13 14 15 16 17 18 10 11 12 13 14 15 16 |
735 |
| - # 19 20 21 22 23 24 25 17 18 19 20 21 22 23 |
736 |
| - # 26 27 28 29 30 24 25 26 27 28 29 30 |
737 |
| - # 31 |
738 |
| - |
739 |
| - algo = TradingAlgorithm(env=self.env) |
740 |
| - algo.datetime = pd.Timestamp('2006-12-01', tz='UTC') |
741 |
| - |
742 |
| - self.assertEqual( |
743 |
| - algo.future_chain('CL', offset=1).as_of_date, |
744 |
| - pd.Timestamp("2006-12-04", tz='UTC') |
745 |
| - ) |
746 |
| - |
747 |
| - self.assertEqual( |
748 |
| - algo.future_chain("CL", offset=5).as_of_date, |
749 |
| - pd.Timestamp("2006-12-08", tz='UTC') |
750 |
| - ) |
751 |
| - |
752 |
| - self.assertEqual( |
753 |
| - algo.future_chain("CL", offset=-10).as_of_date, |
754 |
| - pd.Timestamp("2006-11-16", tz='UTC') |
755 |
| - ) |
756 |
| - |
757 |
| - # September 2016 |
758 |
| - # Su Mo Tu We Th Fr Sa |
759 |
| - # 1 2 3 |
760 |
| - # 4 5 6 7 8 9 10 |
761 |
| - # 11 12 13 14 15 16 17 |
762 |
| - # 18 19 20 21 22 23 24 |
763 |
| - # 25 26 27 28 29 30 |
764 |
| - self.assertEqual( |
765 |
| - algo.future_chain( |
766 |
| - "CL", |
767 |
| - as_of_date=pd.Timestamp("2016-08-31", tz='UTC'), |
768 |
| - offset=10 |
769 |
| - ).as_of_date, |
770 |
| - pd.Timestamp("2016-09-15", tz='UTC') |
771 |
| - ) |
772 |
| - |
773 |
| - def test_future_chain(self): |
774 |
| - algo = TradingAlgorithm(env=self.env) |
775 |
| - algo.datetime = pd.Timestamp('2006-12-01', tz='UTC') |
776 |
| - |
777 |
| - # Check that the fields of the FutureChain object are set correctly |
778 |
| - cl = algo.future_chain('CL') |
779 |
| - self.assertEqual(cl.root_symbol, 'CL') |
780 |
| - self.assertEqual(cl.as_of_date, algo.datetime) |
781 |
| - |
782 |
| - # Check the fields are set correctly if an as_of_date is supplied |
783 |
| - as_of_date = pd.Timestamp('1952-08-11', tz='UTC') |
784 |
| - |
785 |
| - cl = algo.future_chain('CL', as_of_date=as_of_date) |
786 |
| - self.assertEqual(cl.root_symbol, 'CL') |
787 |
| - self.assertEqual(cl.as_of_date, as_of_date) |
788 |
| - |
789 |
| - cl = algo.future_chain('CL', as_of_date='1952-08-11') |
790 |
| - self.assertEqual(cl.root_symbol, 'CL') |
791 |
| - self.assertEqual(cl.as_of_date, as_of_date) |
792 |
| - |
793 |
| - # Check that weird capitalization is corrected |
794 |
| - cl = algo.future_chain('cL') |
795 |
| - self.assertEqual(cl.root_symbol, 'CL') |
796 |
| - |
797 |
| - cl = algo.future_chain('cl') |
798 |
| - self.assertEqual(cl.root_symbol, 'CL') |
799 |
| - |
800 |
| - # Check that invalid root symbols raise RootSymbolNotFound |
801 |
| - with self.assertRaises(RootSymbolNotFound): |
802 |
| - algo.future_chain('CLZ') |
803 |
| - |
804 |
| - with self.assertRaises(RootSymbolNotFound): |
805 |
| - algo.future_chain('') |
806 |
| - |
807 |
| - # Check that invalid dates raise UnsupportedDatetimeFormat |
808 |
| - with self.assertRaises(UnsupportedDatetimeFormat): |
809 |
| - algo.future_chain('CL', 'my_finger_slipped') |
810 |
| - |
811 |
| - with self.assertRaises(UnsupportedDatetimeFormat): |
812 |
| - algo.future_chain('CL', '2015-09-') |
813 |
| - |
814 |
| - # Supplying a non-string argument to future_chain() |
815 |
| - # should result in a TypeError. |
816 |
| - with self.assertRaises(TypeError): |
817 |
| - algo.future_chain(1) |
818 |
| - |
819 |
| - with self.assertRaises(TypeError): |
820 |
| - algo.future_chain((1,)) |
821 |
| - |
822 |
| - with self.assertRaises(TypeError): |
823 |
| - algo.future_chain({1}) |
824 |
| - |
825 |
| - with self.assertRaises(TypeError): |
826 |
| - algo.future_chain([1]) |
827 |
| - |
828 |
| - with self.assertRaises(TypeError): |
829 |
| - algo.future_chain({'foo': 'bar'}) |
830 |
| - |
831 | 728 | def test_set_symbol_lookup_date(self):
|
832 | 729 | """
|
833 | 730 | Test the set_symbol_lookup_date API method.
|
|
0 commit comments