mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-30 23:09:41 +08:00
refining the batch transform interface:
- removed use_panel - default for refresh_period is now 0 - refresh_period will only affect the recreation of the datapanel - user's transform method is invoked on every call to batch transform
This commit is contained in:
@@ -342,12 +342,6 @@ class BatchTransformAlgorithm(TradingAlgorithm):
|
||||
clean_nans=True
|
||||
)
|
||||
|
||||
self.return_ticks = return_data(
|
||||
refresh_period=self.refresh_period,
|
||||
window_length=self.window_length,
|
||||
create_panel=False
|
||||
)
|
||||
|
||||
self.return_not_full = return_data(
|
||||
refresh_period=0,
|
||||
window_length=self.window_length,
|
||||
@@ -372,8 +366,6 @@ class BatchTransformAlgorithm(TradingAlgorithm):
|
||||
self.history_return_args.append(
|
||||
self.return_args_batch.handle_data(
|
||||
data, *self.args, **self.kwargs))
|
||||
self.history_return_ticks.append(
|
||||
self.return_ticks.handle_data(data))
|
||||
self.history_return_not_full.append(
|
||||
self.return_not_full.handle_data(data))
|
||||
self.uses_ufunc.handle_data(data)
|
||||
|
||||
@@ -313,7 +313,7 @@ class BatchTransform(EventWindow):
|
||||
|
||||
def __init__(self,
|
||||
func=None,
|
||||
refresh_period=None,
|
||||
refresh_period=0,
|
||||
window_length=None,
|
||||
clean_nans=True,
|
||||
sids=None,
|
||||
@@ -368,6 +368,7 @@ class BatchTransform(EventWindow):
|
||||
self.window_length = window_length
|
||||
self.trading_days_since_update = 0
|
||||
self.trading_days_total = 0
|
||||
self.window = None
|
||||
|
||||
self.full = False
|
||||
self.last_dt = None
|
||||
@@ -512,8 +513,14 @@ class BatchTransform(EventWindow):
|
||||
|
||||
if self.updated:
|
||||
# Create new pandas panel
|
||||
data = self.get_data()
|
||||
self.cached = self.compute_transform_value(data, *args, **kwargs)
|
||||
self.window = self.get_data()
|
||||
|
||||
if self.window:
|
||||
self.cached = self.compute_transform_value(
|
||||
self.window,
|
||||
*args,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
return self.cached
|
||||
|
||||
|
||||
Reference in New Issue
Block a user