Using backtrader data to make a Pandas dataframe from
behdadahmadi last edited by
I want to make a Pandas dataframe from each 40 data and applying exponential smoothing to them, and then after that I want to feed the classifier to predict. How can I do it with Backtrader?
@behdadahmadi, I'm not quite sure if I'm understanding your question correctly, it sounds like you want to take 40 bars of data from the output of a program and then refeed that into an EMA. I had read this article about backtrader when I was getting started, and it talks a little about logging to pandas df: https://ntguardian.wordpress.com/2017/06/12/getting-started-with-backtrader/
The specific paragraph I'm referring to is:
"The only feature that, to me, appears to be a glaring omission, is the ability to log results to a pandas DataFrame. pandas was designed to handle time series, and is in general an essential package to Python data analysis, in my opinion. backtrader‘s closest Python “competitor”, zipline, advertises its strong pandas support (though Mr. Kipnis believes it is inferior to quantstrat and looking though the documentation it has not bedazzled me to the extent backtrader has). There is a likely work-around, though; backtrader‘s logging functionality allows logging to files, including CSV files, so a user can perform a backtest, define what metrics she wants captured in a CSV file, then read that file into a pandas DataFrame. It would be nice to cut out the middle-man, though."
Now this was published a little over a year ago so things could be changed, however, it seems from this as though you would need to log your results to a CSV file, and then write a python script to transfer that data into a pandas df, or otherwise just refeed the data from the CSV file.
Hope this helps, good luck.
behdadahmadi last edited by
How can I take each 40 bars (this is the lookback I use in my trained machine learning classifier) and input them to the machine learning classifier?
My strategy is so simple : Feed the look back of 40 data to a ML classifier ( I load it with joblib) and then it predicts the data. If the result is 1,its a buy signal,otherwise is a sell signal.
Thank you so much
I don't know anything about machine learning so I can't help much. Perhaps somebody else can chime in on that one
I want to make a Pandas dataframe from each 40 data and applying exponential smoothing to them,
Do you make the Pandas dataframe before or after loading the data into
backtrader? Which type of exponential smoothing (there are many)?
My strategy is so simple : Feed the look back of 40 data to a ML classifier
Your strategy may sound simple to you. The explanation is fully unclear.
Is the data or the exponential smoothing what you want to feed?
Have you read this: