@run-out Got it,thank you, hey, I am looking for a detailed course on studying the backtrader, any help?
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Latest posts made by Madhoon
RE: Help With YahooFinance Data
from datetime import datetime import backtrader as bt from backtrader import plot import yfinance as yf # Create a subclass of Strategy to define the indicators and logic class SmaCross(bt.Strategy): # list of parameters which are configurable for the strategy params = dict( pfast=50, # period for the fast moving average pslow=200 # period for the slow moving average ) def __init__(self): sma1 = bt.ind.SMA(period=self.p.pfast) # fast moving average sma2 = bt.ind.SMA(period=self.p.pslow) # slow moving average self.crossover = bt.ind.CrossOver(sma1, sma2) # crossover signal def next(self): if not self.position: # not in the market if self.crossover > 0: # if fast crosses slow to the upside self.buy() # enter long elif self.crossover < 0: # in the market & cross to the downside self.close() # close long position cerebro = bt.Cerebro() # create a "Cerebro" engine instance cerebro.broker.setcash(100000) # Create a data feed data = bt.feeds.PandasData(dataname=yf.download('KPITTECH.NS', '2019-01-01', '2021-07-06')) cerebro.adddata(data) # Add the data feed cerebro.addstrategy(SmaCross) # Add the trading strategy cerebro.run() # run it all cerebro.plot() # and plot it with a single command this is my code⬆️ and this is the error⬇️ Traceback (most recent call last): File "/Users/madhurjodhwani/Desktop/python/hey.py", line 37, in <module> cerebro.plot() # and plot it with a single command File "/opt/homebrew/lib/python3.9/site-packages/backtrader/cerebro.py", line 974, in plot from . import plot File "/opt/homebrew/lib/python3.9/site-packages/backtrader/plot/__init__.py", line 42, in <module> from .plot import Plot, Plot_OldSync File "/opt/homebrew/lib/python3.9/site-packages/backtrader/plot/plot.py", line 44, in <module> from . import locator as loc File "/opt/homebrew/lib/python3.9/site-packages/backtrader/plot/locator.py", line 35, in <module> from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN, ImportError: cannot import name 'warnings' from 'matplotlib.dates' (/opt/homebrew/lib/python3.9/site-packages/matplotlib/dates.py)
I am trying to run cerebro.plot() and it is giving this error, also I am new to finance and wnant to learn this bactrader,is there any course or any videos to help me with this?