Traceback (most recent call last):
File "C:/Users/14753/OneDrive/Desktop/stock.py", line 17, in
data = pd.read_csv("SBUX.csv", date_parser=['date'])
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 702, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 429, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 895, in init
self._make_engine(self.engine)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 1122, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\parsers.py", line 1853, in init
self._reader = parsers.TextReader(src, **kwds)
File "pandas_libs\parsers.pyx", line 387, in pandas._libs.parsers.TextReader.cinit
File "pandas_libs\parsers.pyx", line 705, in pandas._libs.parsers.TextReader._setup_parser_source
FileNotFoundError: [Errno 2] File b'SBUX.csv' does not exist: b'SBUX.csv'
Having this error, whats the problem
That file isn't available, try data.csv from the examples folder.
Traceback (most recent call last):
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexes\base.py", line 4381, in get_value
return libindex.get_value_box(s, key)
File "pandas_libs\index.pyx", line 52, in pandas._libs.index.get_value_box
File "pandas_libs\index.pyx", line 48, in pandas._libs.index.get_value_at
File "pandas_libs\util.pxd", line 113, in pandas._libs.util.get_value_at
File "pandas_libs\util.pxd", line 98, in pandas._libs.util.validate_indexer
TypeError: 'str' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\14753\OneDrive\Desktop\Clairvoyant-master\Clairvoyant-master\examples\stock.py", line 22, in
backtest.start(data, kernel='rbf', C=1, gamma=10)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\clairvoyant\engine.py", line 197, in start
Engine.start(self, data, **kwargs)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\clairvoyant\engine.py", line 52, in start
Xs = [data.iloc[i][var] for var in self.features]
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\clairvoyant\engine.py", line 52, in
Xs = [data.iloc[i][var] for var in self.features]
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\series.py", line 868, in getitem
result = self.index.get_value(self, key)
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexes\base.py", line 4389, in get_value
raise e1
File "C:\Users\14753\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\indexes\base.py", line 4375, in get_value
tz=getattr(series.dtype, 'tz', None))
File "pandas_libs\index.pyx", line 81, in pandas._libs.index.IndexEngine.get_value
File "pandas_libs\index.pyx", line 89, in pandas._libs.index.IndexEngine.get_value
File "pandas_libs\index.pyx", line 132, in pandas._libs.index.IndexEngine.get_loc
File "pandas_libs\hashtable_class_helper.pxi", line 1601, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas_libs\hashtable_class_helper.pxi", line 1608, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'EMA'
Now i'm getting a different error. I have seen your past resolved code, but I don't quite understand.
You need to calculate the EMA yourself, something like this would do
from talib.abstract import *
data['EMA'] = EMA(data, field="close")
data['RSI'] = RSI(data, field="close")
filtered_df = data[data['RSI'].notnull()]
filtered_df = data[data['EMA'].notnull()]
And then use filtered_df as the data input
You need to change in features , Try using X1,X2 instead of EMA,SSO i.e features=["X1", "X2"]