Skip to content

Commit f4daf10

Browse files
author
Eddie Hebert
committed
MAINT: Remove future_chain API method.
`future_chain` will be replaced by the as yet to be implemented method, `data.current_chain` Also removing `FutureChain` which will be replaced by another version which only supports indexing and iteration.
1 parent 86c7635 commit f4daf10

File tree

6 files changed

+0
-650
lines changed

6 files changed

+0
-650
lines changed

docs/source/appendix.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ Assets
8787

8888
.. autofunction:: zipline.api.future_symbol
8989

90-
.. autofunction:: zipline.api.future_chain
91-
9290
.. autofunction:: zipline.api.set_symbol_lookup_date
9391

9492
.. autofunction:: zipline.api.sid

tests/test_algorithm.py

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
TradingControlViolation,
5959
AccountControlViolation,
6060
SymbolNotFound,
61-
RootSymbolNotFound,
6261
UnsupportedDatetimeFormat,
6362
CannotOrderDelistedAsset,
6463
SetCancelPolicyPostInit,
@@ -726,108 +725,6 @@ def test_future_symbol(self):
726725
with self.assertRaises(TypeError):
727726
algo.future_symbol({'foo': 'bar'})
728727

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-
831728
def test_set_symbol_lookup_date(self):
832729
"""
833730
Test the set_symbol_lookup_date API method.

0 commit comments

Comments
 (0)