The following code works fine in a python shell, displaying the content of the feed object:
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
class MyStrategy(strategy.BacktestingStrategy):
def __init__(self, feed, instrument):
strategy.BacktestingStrategy.__init__(self, feed)
self.__instrument = instrument
def onBars(self, bars):
bar = bars[self.__instrument]
self.info(bar.getClose())
feed = yahoofeed.Feed()
feed.addBarsFromCSV("orcl","data/bistampTicker.csv")
myStrategy = MyStrategy(feed, "orcl")
myStrategy.run()
However, its execution in a Django views leads to the following error:
'function' object has no attribute 'BacktestingStrategy'
Where the BacktestingStrategy is a class defined in the __ init__.py file inside the strategy folder of the python module, inside the python path.
My understanding of the problem is that django doesn't read the __ init__.py file, thus not importing the module correctly (a pyalgotrade module).
Is there a way to tell Django to do so?
Thanks in advance and sorry for the noobish question.
Cheers