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/

    how to import modul DJANGO in strategie?

    General Code/Help
    1
    1
    426
    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.
    • mamos
      mamos last edited by mamos

      hello all,
      first I'm newbies and sorry for my English...
      I have a big problem. It is impossible to import module from Django like models...
      I don't understand why I can't do it.
      please help me I will be crazy :'(

      EXAMPLE:
      from datetime import datetime
      import backtrader as bt

      FROM FOOAPP.MODELS IMPORT barstrategie

      class SmaCross(bt.SignalStrategy):
      def init(self):
      sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
      crossover = bt.ind.CrossOver(sma1, sma2)
      self.signal_add(bt.SIGNAL_LONG, crossover)

      cerebro = bt.Cerebro()
      cerebro.addstrategy(SmaCross)

      data0 = bt.feeds.YahooFinanceData(dataname='YHOO', fromdate=datetime(2011, 1, 1),
      todate=datetime(2012, 12, 31))
      cerebro.adddata(data0)

      cerebro.run()
      cerebro.plot()

      DJANGO RETURN No module named ''FOOAPP"

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