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/

    Logout when plotting

    General Code/Help
    2
    2
    60
    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.
    • Pang Wai Yuen
      Pang Wai Yuen last edited by

      Hi,

      I am quite new to python an absolute new to Backtrader, so if I asked something stupid please forgive me.

      When I run this code from my terminal my user got logout, would someone please help? I am using Mac OS

      from future import (absolute_import, division, print_function,
      unicode_literals)

      import backtrader as bt
      from IPython import get_ipython
      class St(bt.Strategy):
      def init(self):
      self.sma = bt.indicators.SimpleMovingAverage(self.data)

      data = bt.feeds.BacktraderCSVData(dataname='/Users/py/Documents/python/testdata/forex.csv')

      cerebro = bt.Cerebro()
      cerebro.adddata(data)
      cerebro.addstrategy(St)
      cerebro.run()

      cerebro.plot(iplot=False)

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

        1. Top of the page
        For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
        
        1. The backtrader code itself does not run in the shell and has no contact with it. It seems awkward to import get_ipython and to run cerebro.plot(ipython=False), because those seems to be related to be running inside a Jupyter Notebook or Spyder environment.
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors