ENH: Add continuous future current contract.

Add the ability for an algorithm to request the current contract for a
future chain via `data.current`.

e.g.:
```
data.current(ContinuousFuture('CL', offset=0, roll='calendar'),
'contract')
```
This commit is contained in:
Eddie Hebert
2016-10-06 13:39:44 -04:00
parent 03d77b34b4
commit ec6f298972
9 changed files with 697 additions and 5 deletions
+27
View File
@@ -1185,6 +1185,33 @@ class TradingAlgorithm(object):
as_of_date=_lookup_date,
)
@api_method
@preprocess(root_symbol_str=ensure_upper_case)
def continuous_future(self, root_symbol_str, offset, roll):
"""Create a specifier for a continuous contract.
Parameters
----------
root_symbol_str : str
The root symbol for the future chain.
offset : int
The distance from the primary contract.
roll_style : str
How rolls are determined.
Returns
-------
continuous_future : ContinuousFuture
The continuous future specifier.
"""
return self.asset_finder.create_continuous_future(
root_symbol_str,
offset,
roll,
)
@api_method
def symbols(self, *args):
"""Lookup multuple Equities as a list.