Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Examples - backtest.py is not working #102

Open
itpmngt opened this issue Nov 17, 2020 · 5 comments
Open

Examples - backtest.py is not working #102

itpmngt opened this issue Nov 17, 2020 · 5 comments

Comments

@itpmngt
Copy link

itpmngt commented Nov 17, 2020

After a fresh install attempted to run examples/backtest.py - but:

The data file name has changed:

  • from data_file = os.path.join("tests/data/bittrex:btc-usdt.csv")
  • to data_file = os.path.join("tests/data/bittrex_btc-usdt.csv")
    (semi-colon into underscore)

After fixing that attempted to run but it stumbles with an error from backtesting

RuntimeError: Indicator "DEMA(df,10)" errored with exception: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

The closest SO reference I found is: https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o

Seems there is some incompatibility for using with backtesting

@peerchemist
Copy link
Owner

I'll take a look. Thanks for reporting.

@itpmngt
Copy link
Author

itpmngt commented Nov 18, 2020

I wonder if returning the name is what is breaking it - just a guess...

@peerchemist
Copy link
Owner

It seems upstream library (backtesting) had some breaking changes, that is what happened here. I'll try to study what was changed in upstream and adopt the example. If not, I'll find a new backtesting library.

@scfox
Copy link

scfox commented May 19, 2021

Also interested in using finta with backtest. Any update / workaround?

@cmann50
Copy link

cmann50 commented Jun 5, 2021

I was able to get around the error and make the backtesting.py indicators work by passing in the exact columns finta expects and no other columns.

from backtesting import Backtest, Strategy
from finta import TA as TAF

def convert_finta(df: pd.DataFrame) -> pd.DataFrame:
    df_finta = pd.DataFrame()
    df_finta["open"] = df["open"]
    df_finta["high"] = df["high"]
    df_finta["low"] = df["low"]
    df_finta["close"] = df["close"]
    df_finta["volume"] = df["volume"] 
    return df_finta

self.fish = self.I(TAF.FISH, tools.convert_finta(ohlc),overlay=False, name="Fish" )

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants