mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-05 14:02:11 +08:00
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user