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?



  • 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"