-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Is there a tutorial showing how I can use my own pandas dataframe? #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
What do you mean? Backtesting.py only works with your data frames! The dataframe needs the OHLC(V) columns as prescribed, and any additional columns are optional. See: #64. If you need back the def next(self):
df = self.data.df
... |
I tried doing it. Here's what I got with the result
The colums for dataframe are as follows: |
Take note: the indicators are pre-added from outside the SMACross class |
Sorry, but without code/data, that's really not enough to go on. 👉 Zero trades were made. |
ok, I'll try to post the code here after work. |
I think I finally got it working (results, no charts yet) def next(self):
# If sma1 crosses above sma2, close any existing
# short trades, and buy the asset
if crossover(self.data.df.sma_20, self.data.df.sma_50):
self.position.close()
self.buy()
# Else, if sma1 crosses below sma2, close any existing
# long trades, and sell the asset
elif crossover(self.data.df.sma_50, self.data.df.sma_20):
self.position.close()
self.sell()` |
Note, you should find it far more performant not to convert to df: if crossover(self.data.sma_20, self.data.sma_50):
... So is there an issue here? |
I'll test it out. |
Tested this out, it worked. But somehow the first time I used it, it didn't behaved properly. |
I've checked the docs and there seems to be no way to implement or add my own pandas dataframe.
I needs to do this because I will be using that df in the next()
The text was updated successfully, but these errors were encountered: