backtrader is a python backtesting library for trading strategies
Questions tagged [backtrader]
107 questions
0
votes
1 answer
After running Cerebro nothing is happening to my portfolio value in backtrader, how do i check if it is working or not
import backtrader as bt
import backtrader.feeds as btfeed
import backtrader.analyzers as btanalyzers
import talib as ta
import numpy as np
import pandas as pd
from datetime import datetime
class MACross(bt.Strategy):
def __init__(self):
ma_fast…
0
votes
1 answer
Can't remove the error with the datetime format in backtrader
class dataFeed(btfeed.GenericCSVData):
params = (
('dtformat', '%m%d%Y %H:%M:%S'),
('datetime', 0),
('open', 1),
('high', 2),
('low', 3),
('close', 4),
('volume', 5),
…
0
votes
1 answer
sh: Script.py: command not found
I wrote a Script.py script. In this script I start to initialize some variables, than there are 7 classes and in the end I run a cerebro to backtest stocks:
> if __name__ == '__main__':
> cerebro = bt.Cerebro()
> ...
> ...
If I run the…

chrissi2909
- 51
- 2
- 6
0
votes
1 answer
Visual Studio Code on mac using python Error "syntax error: invalid syntax" at the line 'cerebro = bt.Cerebro()'
I'm using VSCode with python to do some backtesting using backtrader. I just starting following a tutorial and the first test code seems to comeup with a syntax error when instantiating cerebro. Here is the code:
import backtrader as bt
from…

tew
- 261
- 4
- 13
0
votes
2 answers
Backtrader issue
I have this error when I run my code using Backtrader library:
**File "/Users/giovannicaridi/opt/anaconda3/lib/python3.7/site-packages/backtrader/feeds/yahoo.py", line 94, in start
super(YahooFinanceCSVData, self).start()
TypeError: super(type,…

elfunambolo
- 1
- 1
0
votes
1 answer
Ist there Something as a vectorized Backtesting Platform?
I got a pandas series of timevalues and 1s for a Trade and 0s for Not to Trade (plus different Takeprofit and stoploss values)
and i am Planing to Backtest it.
However the Last Time I used backtrader I manually had to search the current…

Benoid
- 209
- 1
- 4
- 11
0
votes
0 answers
Converting ThinkScripts CompoundValue Function to python
declare lower;
def x = CompoundValue(2, x[1] + x[2], 1);
plot FibonacciNumbers = x;
This is in thinkscript i want to convert this in python actually i am converting one of Thinkorswim strategy in python backtrader

mudassar031
- 83
- 7
0
votes
1 answer
Backtrader - order.executed.value on sell order erroneous?
Using a boiler plate strategy assuming 1 share being bought and sold (long only/ every buy order is coupled with a sell order).
For some reason when I sell a stock, it logs the value of the trade (shares * price) at the same amount that was…

RageAgainstheMachine
- 901
- 2
- 11
- 28
0
votes
1 answer
Strategy Buy and Hold Monthly Backtrader
When I run my backtrader code with the strategy below it doesn't work. Anybody would know why? The notify_timer function is not even called!
Thanks!
import math
import backtrader as bt
class BuyEveryMonth(bt.Strategy):
params =…

Charles Wagner
- 103
- 1
- 2
- 10
-1
votes
0 answers
Letters and figures in a Pyfolio library window are too close together and overlap
I am using python's Pyfolio library (which uses matplotlib) to plot analysis charts for a trading strategy developed with Backtrader.
I attach an image of one of the windows.
I can't make out anything, the window is full screen, the writing is…

Bio
- 11
- 3
-1
votes
1 answer
How to get 1-minute data of just 1 day in Yahoo Finance
yf.download("TSLA", start='2022-08-29', end='2022-08-30', interval="1m")
Above is the code that I normally use to get 1 minute stock prices of a period, but I want to get the prices for just 1 day. I cannot do it like the below.
yf.download("TSLA",…

snowball
- 1
- 1
-1
votes
1 answer
Can you selectively inherit methods in Python?
I have a parent class with a lot of methods. I want some of them inherited in all of the child classes. Some of the methods I only want in certain classes. Can I somehow select which methods to inherit. I know I could override them in the child…

Borut Flis
- 15,715
- 30
- 92
- 119
-1
votes
1 answer
How to change date and time(CSV file) in standard format(yyyy-mm-ddthh:mm:ss+00:00)?
I had a data in which it has only Date(yyyy-mm-dd) and time(hh.mm). I am getting an error for datetime format does not match.
I want to convert my existing data into standard format using python(Pandas) library.Please give a proper solution for…

meet4288
- 1
- 1
-1
votes
1 answer
Open multiple positions in Backtrader
Does someone know if it's possible to open multiple positions with only a single data feed? I am trying to do a second buy whilst in a position, which doesn't seem to be possible.
Nobody seems to adress this issue. Does anyone have any experience…

yebowo
- 3
- 1
-1
votes
1 answer
How to select id's from one table and insert/update to another table
I am working on an automated trading system in python, I have set up a database which inserts a row every time a new order is generated.
What I am having trouble with is if the order is successful I would like to add the OrderID to my Position…

JGProgrammer
- 13
- 4