mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-20 12:20:29 +08:00
BUG: asserting for correct index type.
This commit is contained in:
@@ -105,7 +105,7 @@ class TradingAlgorithm(object):
|
||||
"""
|
||||
Create trading environment, transforms and SimulatedTrading object.
|
||||
|
||||
Gets called by self.run(data).
|
||||
Gets called by self.run().
|
||||
"""
|
||||
environment = create_trading_environment(start=source.data.index[0], end=source.data.index[-1])
|
||||
|
||||
@@ -147,7 +147,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
"""
|
||||
assert isinstance(data, pd.DataFrame)
|
||||
assert isinstance(data.index, pd.Timeseries)
|
||||
assert isinstance(data.index, pd.tseries.index.DatetimeIndex)
|
||||
|
||||
source = DataFrameSource(data, sids=self.sids)
|
||||
|
||||
@@ -156,12 +156,7 @@ class TradingAlgorithm(object):
|
||||
|
||||
# loop through simulated_trading, each iteration returns a
|
||||
# perf ndict
|
||||
perfs = []
|
||||
for perf in simulated_trading:
|
||||
#from nose.tools import set_trace; set_trace()
|
||||
perfs.append(perf)
|
||||
|
||||
#perfs = list(self.simulated_trading)
|
||||
perfs = list(self.simulated_trading)
|
||||
|
||||
# convert perf ndict to pandas dataframe
|
||||
daily_stats = self._create_daily_stats(perfs)
|
||||
|
||||
@@ -88,7 +88,8 @@ def load_close_px(indexes=None, stocks=None):
|
||||
|
||||
def run((short_window, long_window)):
|
||||
#data = pd.DataFrame.from_csv('SP500.csv')
|
||||
data = pd.DataFrame.from_csv('aapl.csv') #load_close_px()
|
||||
#data = pd.DataFrame.from_csv('aapl.csv') #load_close_px()
|
||||
data = load_close_px()
|
||||
myalgo = DMA([0, 1], amount=100, short_window=short_window, long_window=long_window)
|
||||
stats = myalgo.run(data)
|
||||
stats['sw'] = short_window
|
||||
|
||||
Reference in New Issue
Block a user