• I am totally new to backtrader and created this very simple code based on the code on the homepage.

    import numpy as np
    import pandas as pd
    import matplotlib.pyplot as plt
    import pandas_datareader
    import datetime
    import as web
    start = datetime.datetime(2012, 1, 1)
    end = datetime.datetime(2017, 1, 1)
    data = web.DataReader("MSFT",'google',start,end)
    from datetime import datetime
    import backtrader as bt
    class SmaCross(bt.SignalStrategy):
    params = (('pfast', 10), ('pslow', 30),)
    def init(self):
    sma2 = bt.ind.SMA(period=self.p.pfast),
    self.signal_add(bt.SIGNAL_LONG, bt.ind.CrossOver(sma1, sma2))
    cerebro = bt.Cerebro()

    I get this error:

    /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6-32 /Users/Admin/IdeaProjects/HellowWorld/
    Traceback (most recent call last):
    File "/Users/Admin/IdeaProjects/HellowWorld/", line 21, in <module>
    File "/Users/Admin/Downloads/backtrader-master/backtrader/", line 758, in adddata
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pandas/core/", line 3081, in getattr
    return object.getattribute(self, name)
    AttributeError: 'DataFrame' object has no attribute 'setenvironment'
    Process finished with exit code 1

    At this point I'm not sure if it has to do with my version of Python 3 or not.. Has anyone else had this issue?

  • administrators

    As posted it is unreadable. Can you repost following the instructions at the top of the forum? (On every page)

    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Log in to reply

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.