backtrader is a python backtesting library for trading strategies
Questions tagged [backtrader]
107 questions
0
votes
0 answers
backtrader shows same time for all candles
This is my code:
data15 = bt.feeds.GenericCSVData(dataname='BTCUSDT-15m-2022-01-01.csv',
dtformat=lambda x: datetime.utcfromtimestamp(int(x)/1000))
from csvgeneric.py:
dt = datetime.strptime(dtfield, dtformat)
else:
dt =…

Rony Tesler
- 1,207
- 15
- 25
0
votes
1 answer
Problem with creating a ZeroLagLSMA indicator
can someone look on my implementation of bellow pinescript indicator:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © veryfid
//@version=4
study(title = "ZLSMA - Zero Lag LSMA",…

Papay
- 1
0
votes
1 answer
backtrader #IndexError: list index out of range problem
The data is coming in as unix timestamp in milliseconds.
So i am using #dtformat=lambda x: datetime.datetime.utcfromtimestamp(int(x) / 1000).
import backtrader as bt
import datetime
cerebro = bt.Cerebro()
data =…
0
votes
1 answer
In backtrader I am unable to add 1 minute candle data using GenericCSVData
My CSV looks like the…
0
votes
1 answer
Why Backtrader doesn't show xticks when plotting graph?
it's weird my backtrader doesn't show xticks on most of my testing cases when i use cerebro.plot(style='candlestick'), I check it out on internet and find out it's not just me. Can anybody help us out there? Thanks!

Jeff Kwok
- 1
- 2
0
votes
1 answer
What is the right way to import IbPy2 and backtrader?
Hi i am having trouble importing backtrader and IbPy2. When i pip install both and when i run import backtrader in my python shell i get the following error:
i pip installed these:
pip install https://github.com/blampe/IbPy/archive/master.zip
pip…

James
- 15
- 5
0
votes
0 answers
Why my backtesting program didn't enter any position?
I am new to the field of programming, and recently I am trying to write a backtesting program by using backtrader.
But it didn't enter into any position, can anyone tell me why?
CSV doc to run this program
The csv doc is attached for your reference.…

IU iuuu
- 1
0
votes
1 answer
'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'self'
everyone!
I´m trying to replicate one of the strategies with backtrader for practice purposes, but I get this message when I try to run it: 'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'self'.
I want to buy when RSI…
0
votes
0 answers
Backtrder animated plotting
Im looking for a way to animate backtest plotting of the Backtrder. I searched for appropriate tools and I found FuncAnimation:
FuncAnimation(figure, animation_function, frames=None, init_func=None, fargs=None, save_count=None, *,…

teralee
- 11
- 1
0
votes
1 answer
I want to customize some indicators in backtrader
When I am using my own method, I met some problems, my program responds: Invalid parameter value for nbdev (expected float, got int)
I am really confused
after several tries, I suppose that the problem is caused because of my indicators.
I hope to…

SeatheStars
- 1
- 1
0
votes
1 answer
Problem with backtrader live Gold (XAUUSD) data from IB (Interactive Brokers)
Backtrader works fine with live data of IB (Interactive Brokers) through TWS, but when I want to trade on gold commodity (XAUUSD), it cannot receive the data.
the python code is:
data = store.getdata(dataname='XAUUSD', sectype='CMDTY',…

Amir Alikhani
- 41
- 5
0
votes
2 answers
Problem with Backtrader after installing ibpy2
Backtrader worked fine for backtesting, but after installing:
pip install ibpy2
there would be an error:
This problem really annoy since it just appeared in one of my systems.
I've uninstalled python and used anaconda, but the problem does not…

Amir Alikhani
- 41
- 5
0
votes
1 answer
'numpy.int64' object has no attribute 'to_pydatetime' in backtrader feed
I am unable to fix the error - 'numpy.int64' object has no attribute 'to_pydatetime', I will be really grateful, if anyone could please help me out in this? I have already tried uninstalling pyfolio and itstalling it from git. Please see the…

Arun Kumar Panda
- 13
- 4
0
votes
1 answer
Backtrader issue - optstrategy AttributeError: module 'collections' has no attribute 'Iterable'
I'm trying to optimize my strategy on Backtrader with python but keeps getting this error and i can't find anything on the web showing why I'm getting it.
My code is simple and loosely based on the quick start examples:
from alpaca_trade_api.rest…

mr_statler
- 1,913
- 2
- 3
- 14
0
votes
1 answer
Can't convert from timestamp to date
I am developing a backtesting strategy along with backtrader. I am feeding cerebro with generic csv data that goes like…

Apollo
- 164
- 8