A little patch:
if self.p.apikey is not None:
urlargs.append('api_key=%s' % self.p.apikey)
There was a typo previously.
A little patch:
if self.p.apikey is not None:
urlargs.append('api_key=%s' % self.p.apikey)
There was a typo previously.
What about implementing Quandl
data source internally.
One cons is that API
key is mandatory.
Possible due to this :)
https://ichart.yahoo.com/table.csv?s=NFLX&a=0&b=1&c=2016&d=4&e=16&f=2017&g=h&ignore=.csv
Vote to add indicator into main package! It's great for Forex
market.
What's reason that f
is None
?
"version": "1.9.47.116"
backtrader\feed.py
...
def preload(self):
while self.load():
pass
self._last()
self.home()
# preloaded - no need to keep the object around - breaks multip in 3.x
self.f.close()
self.f = None
...
Traceback (most recent call last):
File "D:/Projects/trading-bot/main/lab/backtrader/playground.py", line 277, in <module>
run()
File "D:/Projects/trading-bot/main/lab/backtrader/playground.py", line 119, in run
strategies = run_strategy(back_trader, run_mode == RunMode.DevelopIdea, from_date, to_date)
File "D:/Projects/trading-bot/main/lab/backtrader/playground.py", line 218, in run_strategy
strategies = back_trader.run()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 1070, in run
runstrat = self.runstrategies(iterstrat)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 1146, in runstrategies
data.preload()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\feed.py", line 689, in preload
self.f.close()
AttributeError: 'NoneType' object has no attribute 'close'
Thanks for suggestion, I replace it with:
back_trader.addanalyzer(TimeReturn, timeframe=bt.TimeFrame.Years, _name='annualreturn')
Looks loke pretty the same for SharpeRatio:
Traceback (most recent call last):
File "D:/Projects/trading-bot/main/lab/backtrader/morning_buy.py", line 87, in <module>
strategies = back_trader.run(timeframe=bt.TimeFrame.Minutes)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 794, in run
runstrat = self.runstrategies(iterstrat)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 927, in runstrategies
strat._stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\strategy.py", line 421, in _stop
analyzer._stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\analyzer.py", line 194, in _stop
self.stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\analyzers\sharpe.py", line 173, in stop
ret_free_avg = average(ret_free)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\mathsupport.py", line 38, in average
return math.fsum(x) / (len(x) - bessel)
ZeroDivisionError: float division by zero
I'm optimizing parameters for strategy.
Sometimes when strategy is full of fear, so perform no action. In suck situations ZeroDivisionError: float division by zero
occur.
Traceback (most recent call last):
File "D:/Projects/trading-bot/main/lab/backtrader/morning_buy.py", line 86, in <module>
strategies = back_trader.run(timeframe=bt.TimeFrame.Minutes)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 794, in run
runstrat = self.runstrategies(iterstrat)
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\cerebro.py", line 927, in runstrategies
strat._stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\strategy.py", line 421, in _stop
analyzer._stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\analyzer.py", line 194, in _stop
self.stop()
File "C:\Users\Home\Anaconda3\lib\site-packages\backtrader\analyzers\annualreturn.py", line 84, in stop
annualret = (value_end / value_start) - 1.0
ZeroDivisionError: float division by zero
I checked that
b_trader.broker.setcash(1000.0)
was called earlier.
Schedule main loop! I prefer APScheduler as it's flexibily for reports running based on schedule.
In my particular case
line._plotvalue = False
helps.
Thanks for flexible solution!
Am I missing something or there is not option to reach (cancel) this code in Plot_OldSync.plotind()
?
if not math.isnan(lplot[-1]):
label += ' %.2f' % lplot[-1]