B
@tmi said in Error: When strings show up where they aren't wanted...:
It's a relatively straightforward project (it's a riff on the Quickstart guide model)
Sorry, it is not.
@tmi said in Error: When strings show up where they aren't wanted...:
My CSV has 6 columns of data: one datetime time series, and 5 custom indicators (no OHLC data)
Running with no ohlc is a very advanced use case and you have to really know what you are doing.
@tmi said in Error: When strings show up where they aren't wanted...:
self.order = self.buy()
With no ohlc, what are you expecting from (for example) this statement? Which of the AbraX fields from your data has to choose the broker to execute an order?
You should consider configuring the PandasData subclass to assign open, high, low and close to correspond to the different AbraX in your data, using the column indices or the field names in the params declaration.
If those AbraX fields have nothing to do with regular ohlc fields, well you said it was a simple variation of the quickstart example ... but it really isn't.
@tmi said in Error: When strings show up where they aren't wanted...:
('Date', 0),
('time', -1),
Please see the docs for PandasData. Those parameters/lines don't exist. There is a single field called datetime (and if Date existed, it would be a lowercase date)
Docs - Pandas DataFeed Example
Docs - Data Feeds Reference
Which means that the data feed is trying to find the datetime field in the index of the dataframe, which is made of ints and not timestamps. If you see the docs (and this is standard practice when loading a datetime series), the index should be made of datetime timestamps. You probably want to check the pd.read_csv documentation to automatically set the index to the column containing the dates.
Note: Seeing how the dates are displayed when you print the dataframe, it is likely they haven't been parsed and they are still strings, hence your error.
Some personal advice
@tmi said in Error: When strings show up where they aren't wanted...:
PandasDataAbra = type('PandasDataAbra', (btfeeds.PandasData,), mydict)
Unless you have good reasons for using type, the only thing you are achieving is the pollution of the global namespace with unneeded lines, params, mydict declarations.
Keep things simple, using type isn't going to get you to magical places. Regular subclassing is already very powerful tool.
@tmi said in Error: When strings show up where they aren't wanted...:
datafields = btfeeds.PandasData.datafields + (['Date', 'Abra1', 'Abra2', 'Abra3', "Abra4", "Abra5"])
datafields hasn't been needed for a long time.