back-testing

bt.plot() from the backtesting python library doesn't work

bt.plot() from the backtesting python library doesn't work Question: I’m trying to create a trading strategy, I used the backtesting library to do so. I used data from refinitiv using my app key, the eikon library and extracting the open, high, low, close, volume data of apple from the last two years with the ek.get_timeseries …

Total answers: 2

Pyinstaller comes with errors when importing backtesting.py module

Pyinstaller comes with errors when importing backtesting.py module Question: I am using Windows 11 for Python code development. I have a large Python program that uses the backteting.py module. The program works fine when running it using Visual Studio Code or executing it in the console. However, when I create an EXE file using the …

Total answers: 1

`pd.DateTimeIndex` is advised in backtesting.py library

`pd.DateTimeIndex` is advised in backtesting.py library Question: I am using the backtesting.py library https://kernc.github.io/backtesting.py/doc/backtesting/index.html What is this error? UserWarning: Data index is not datetime. Assuming simple periods, but ‘pd.DateTimeIndex’ is advised. bt = Backtest(data, test2, cash=100000, commission=.002) import pandas as pd from backtesting import Strategy from backtesting import Backtest data = pd.read_csv(‘I:/algotrading/BTCUSDT.csv’) data.columns = [‘Time’,’Open’,’High’,’Low’,’Close’]; …

Total answers: 2

How to vectorize an operation that uses previous values?

How to vectorize an operation that uses previous values? Question: I want to do something like this: df[‘indicator’] = df.at[x-1] + df.at[x-2] or df[‘indicator’] = df.at[x-1] > df.at[x-2] I guess edge cases would be taken care of automatically, e.g. skip the first few rows. Asked By: paperduck || Source Answers: This line should give you …

Total answers: 1