sirnfs / OptionSuite

Option and stock backtester / live trader
MIT License
241 stars 58 forks source link

KeyError: 'symbol' #9

Closed artofax closed 2 years ago

artofax commented 2 years ago

Hi Thanks for this software, I am excited to get it to work. Currently having this issue. Not sure why. Can anyone help? I used the sample iVolatility data and just trying to get the default backTester.py to work.


Empty Traceback (most recent call last)

in run(session) 3 try: ----> 4 event = session.eventQueue.get(False) 5 except queue.Empty: /opt/anaconda3/lib/python3.8/queue.py in get(self, block, timeout) 166 if not self._qsize(): --> 167 raise Empty 168 elif timeout is None: Empty: During handling of the above exception, another exception occurred: KeyError Traceback (most recent call last) /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 3079 try: -> 3080 return self._engine.get_loc(casted_key) 3081 except KeyError as err: pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/index.pyx in pandas._libs.index.IndexEngine.get_loc() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() pandas/_libs/hashtable_class_helper.pxi in pandas._libs.hashtable.PyObjectHashTable.get_item() KeyError: 'symbol' The above exception was the direct cause of the following exception: KeyError Traceback (most recent call last) in 33 34 # Run the session. ---> 35 run(session) 36 37 # Write position monitoring to CSV file. in run(session) 5 except queue.Empty: 6 #Get data for tick event. ----> 7 if not session.dataHandler.getNextTick(): 8 # Get out of infinite while loop; no more data available. 9 break ~/OptionSuite-master 2/dataHandler/csvData.py in getNextTick(self) 229 return False 230 # Convert optionChain from a dataframe to Option class objects. --> 231 optionChainObjs = self.__createBaseType(optionChain) 232 # Create tick event with option chain objects. 233 event = tickEvent.TickEvent() ~/OptionSuite-master 2/dataHandler/csvData.py in __createBaseType(self, optionChain) 175 raise ValueError('Symbol for put / call in dataProviders.json not found in optionType dataframe column.') 176 else: --> 177 optionFieldDict[option_column_name] = row[dataframe_column_name] 178 179 if optionFieldDict['bidPrice'] is not None and optionFieldDict['askPrice'] is not None: /opt/anaconda3/lib/python3.8/site-packages/pandas/core/series.py in __getitem__(self, key) 851 852 elif key_is_scalar: --> 853 return self._get_value(key) 854 855 if is_hashable(key): /opt/anaconda3/lib/python3.8/site-packages/pandas/core/series.py in _get_value(self, label, takeable) 959 960 # Similar to Index.get_value, but we do not fall back to positional --> 961 loc = self.index.get_loc(label) 962 return self.index._get_values_for_loc(self, loc, label) 963 /opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 3080 return self._engine.get_loc(casted_key) 3081 except KeyError as err: -> 3082 raise KeyError(key) from err 3083 3084 if tolerance is not None: KeyError: 'symbol'
sirnfs commented 2 years ago

Thanks for sending the issue. Can you please tell me which sample data file you are using? You can use the sample file in this directory: OptionSuite/marketData/iVolatility/SPX/SPX_2011_2017/ , but you cannot use the aapl_sample_ivolatility.csv file.

artofax commented 2 years ago

That was the sample file I used. marketData/iVolatility/SPX/SPX_2011_2017/RawIV_5day_sample.csv Thank you for responding so quickly

sirnfs commented 2 years ago

The issue is that the 'symbol' header column is corrupt. The column currently appears as "_1" instead of "symbol". I will upload a new file this evening. Thanks for catching this.

sirnfs commented 2 years ago

I have updated the file with a file named RawIV_5day_sample_updated.csv. Please take a look.