problem newly happened
-
This problem never happened before:
not sure where goes wrong or maybe something wrong with the data feed?Traceback (most recent call last):
File "/newVolume/DataAnalysis/backEnd/backTest.PY", line 85, in <module>
cerebro.run()
File "/home/li/.local/lib/python3.8/site-packages/backtrader/cerebro.py", line 1132, in run
runstrat = self.runstrategies(iterstrat)
File "/home/li/.local/lib/python3.8/site-packages/backtrader/cerebro.py", line 1298, in runstrategies
self._runonce(runstrats)
File "/home/li/.local/lib/python3.8/site-packages/backtrader/cerebro.py", line 1693, in _runonce
self._brokernotify()
File "/home/li/.local/lib/python3.8/site-packages/backtrader/cerebro.py", line 1365, in _brokernotify
self._broker.next()
File "/home/li/.local/lib/python3.8/site-packages/backtrader/brokers/bbroker.py", line 1233, in next
self._get_value() # update value
File "/home/li/.local/lib/python3.8/site-packages/backtrader/brokers/bbroker.py", line 433, in _get_value
comminfo = self.getcommissioninfo(data)
File "/home/li/.local/lib/python3.8/site-packages/backtrader/broker.py", line 80, in getcommissioninfo
if data._name in self.comminfo:
AttributeError: 'int' object has no attribute '_name' -
It will be difficult for anyone to provide an answer without a minimum reproducible sample.
But a long shot would indicate that the data feed has not been properly initialized, hence the lack of
_name
-
this is the data and data types that I feed in
-
Quite difficult to reproduce anything from a picture. We don't even know how that's loaded, hence the comment before about a minimum reproducible sample.
-
@backtrader Hello! Can you please approve these changes https://github.com/mementum/backtrader/pull/472 ?
1st commit: Option to change background for plotted value tags for dark theme - to get dark theme)))
When you use dark theme you need to change background for plotted value tags.2nd commit: Fix: In last Python versions collections.Iterable -> collections.abcIterable - to work with Python 3.11+
**3rd commit: Fix: The set_view_interval, set_data_interval ... are removed. Now you can work with matplotlib > 3.6.x
Please review and approve it if you have time. Thanks!
-
@backtrader Here I use getETFdata method which will return a dataframe that I provide picture above.
this pic show how I feed the data:
-
See, I do understand that you have a problem but,
- Pictures cannot be used to reproduce problems
- Even if one typed in the entire text of your picture:
- It is not a complete script
- It contains no sample data
To start with so that you may grasp the difficulties of attempting something:
- What is
res
?
In any case I do stand by my early diagnostic. The data feed has not been started, because assuming I believe the return of
res
is a dataframe, that's not how to add it tocerebro
See the documentation for
PandasData
: https://www.backtrader.com/docu/pandas-datafeed/pandas-datafeed/ -
@backtrader res is a lib that I used to get the stock data frame by entering the stock code,I followed the documentation but still got the same error :
This is the code I have changed:
This is the dataframe that I feed in:
This is the output:
This problem is actually very weird because the strategy works properly before 2022-11-01. but after that day, it suddenly crashed. and this problem happens in some code stocks(actually happens in ETF 510760), for others, it works fine.