Navigation

    Backtrader Community

    • Register
    • 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/

    Excuse me please help me to see why an error is reported when running the drawing code

    General Discussion
    4
    5
    89
    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.
    • T yellow
      T yellow last edited by

      Traceback (most recent call last):
      File "C:/Users/阿斯顿/PycharmProjects/Career/pythonProject3/main.py", line 148, in <module>
      cerebro.plot()
      File "D:\python\lib\site-packages\backtrader\cerebro.py", line 974, in plot
      from.import plot
      File "D:\python\lib\site-packages\backtrader\plot_init_.py", line 13
      def notify_trade(self, trade):
      ^
      IndentationError: expected an indented block

      R run-out 2 Replies Last reply Reply Quote 0
      • R
        rajanprabu @T yellow last edited by

        @T-yellow its a python error not from BT. make sure you code has correct indentation (spaces).

        1 Reply Last reply Reply Quote 0
        • T yellow
          T yellow last edited by

          still the same
          File "D:\python\lib\site-packages\backtrader\cerebro.py", line 974, in plot
          from.import plot

          O 1 Reply Last reply Reply Quote 0
          • O
            ODD @T yellow last edited by

            @T-yellow Where is your code? It's difficult to identify the problem in the first place without being able to see the code.

            1 Reply Last reply Reply Quote 0
            • run-out
              run-out @T yellow last edited by

              @T-yellow said in Excuse me please help me to see why an error is reported when running the drawing code:

              def notify_trade(self, trade):
              Python error. If you have no function lines in the def notify_trade() function, you'll get an error. Either comment out that line, or put in pass after it.

              def notify_trade(self, trade):
                  pass
              

              RunBacktest.com

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