File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -127,11 +127,15 @@ def init():
127
127
value = func (* args , ** kwargs )
128
128
129
129
try :
130
+ if isinstance (value , pd .DataFrame ):
131
+ value = value .values .T
130
132
value = np .asarray (value )
131
133
except Exception :
132
134
raise ValueError ('Indicators must return array-like sequences of values' )
133
135
if value .shape [- 1 ] != len (self ._data .Close ):
134
- raise ValueError ('Indicators must be arrays of same length as `data`' )
136
+ raise ValueError ('Indicators must be (a tuple of) arrays of same length as `data`'
137
+ '(data: {}, indicator "{}": {})' .format (len (self ._data .Close ),
138
+ name , value .shape ))
135
139
136
140
if plot and overlay is None :
137
141
x = value / self ._data .Close
@@ -682,7 +686,7 @@ def run(self, **kwargs) -> pd.Series:
682
686
683
687
# Skip first few candles where indicators are still "warming up"
684
688
# +1 to have at least two entries available
685
- start = 1 + max ((np .isnan (indicator ).argmin ()
689
+ start = 1 + max ((np .isnan (indicator . astype ( float ) ).argmin ()
686
690
for _ , indicator in indicator_attrs ), default = 0 )
687
691
688
692
# Disable "invalid value encountered in ..." warnings. Comparison
Original file line number Diff line number Diff line change @@ -197,9 +197,10 @@ def SMA(series, n):
197
197
self.sma = self.I(SMA, daily, 10, plot=False)
198
198
199
199
"""
200
- if not isinstance (series , pd .Series ):
200
+ if not isinstance (series , ( pd .Series , pd . DataFrame ) ):
201
201
assert isinstance (series , _Array ), \
202
- 'resample_apply() takes either a `pd.Series` or a `Strategy.data.*` array'
202
+ 'resample_apply() takes either a `pd.Series`, `pd.DataFrame`, ' \
203
+ 'or a `Strategy.data.*` array'
203
204
series = series .to_series ()
204
205
205
206
resampled = series .resample (rule , label = 'right' ).agg ('last' ).dropna ()
You can’t perform that action at this time.
0 commit comments