Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    problem newly happened

    General Code/Help
    3
    8
    131
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guslijif
      guslijif last edited by

      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'

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        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

        guslijif 1 Reply Last reply Reply Quote 0
        • guslijif
          guslijif @backtrader last edited by

          @backtrader 08c530e3-4a58-46b3-90d9-deb23563242b-image.png

          this is the data and data types that I feed in

          B 1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators @guslijif last edited by

            @guslijif

            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.

            Олег Шпагин guslijif 2 Replies Last reply Reply Quote 0
            • Олег Шпагин
              Олег Шпагин @backtrader last edited by

              @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!

              1 Reply Last reply Reply Quote 1
              • guslijif
                guslijif @backtrader last edited by

                @backtrader Here I use getETFdata method which will return a dataframe that I provide picture above.
                this pic show how I feed the data:
                8af3942c-37c6-452e-8299-a9813a9bccb7-image.png

                1 Reply Last reply Reply Quote 0
                • B
                  backtrader administrators last edited by

                  See, I do understand that you have a problem but,

                  1. Pictures cannot be used to reproduce problems
                  2. 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 to cerebro

                  See the documentation for PandasData: https://www.backtrader.com/docu/pandas-datafeed/pandas-datafeed/

                  guslijif 1 Reply Last reply Reply Quote 0
                  • guslijif
                    guslijif @backtrader last edited by

                    @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:
                    17965b0e-9e0f-452d-afc6-19679633a587-image.png
                    This is the dataframe that I feed in:
                    c5528f5e-8582-468d-970d-b3dc2d56abee-image.png
                    This is the output:
                    fb996702-54aa-4516-99dd-19ffc1418470-image.png

                    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.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors