1

私はpyalgotradeを使ってトレーディングアルゴを書いています。上記のエラーが発生しましたが、修正できないようです。「SLOW STOCHASTIC」を使用しようとしています。このエラーを解決し、遅い確率を機能させるための助けをいただければ幸いです。

エラー:

C:\Users\...\Desktop>python bobo.py
Traceback (most recent call last):
  File "bobo.py", line 114, in <module>
    main()
  File "bobo.py", line 110, in main
    run_strategy(10,inst,2,14,5,2,3)
  File "bobo.py", line 102, in run_strategy
    myStrategy = MyStrategy(feed, inst, smaPeriod,emaPeriod,rsiPeriod,fastk_period,slowk_period,slowd_period)
  File "bobo.py", line 26, in __init__
    self.__stoch = indicator.STOCH(self.__prices,fastk_period,slowk_period,slowd_period)
  File "C:\Users\...\Anaconda2\lib\site-packages\pyalgotrade\talibext\indicator.py", line 803, in STOCH
    ret = call_talib_with_hlc(barDs, count, talib.STOCH, fastk_period, slowk_period, slowk_matype, slowd_period, slowd_matype)
  File "C:\Users\...\Anaconda2\lib\site-packages\pyalgotrade\talibext\indicator.py", line 93, in call_talib_with_hlc
    high = bar_ds_high_to_numpy(barDs, count)
  File "C:\Users\...\Anaconda2\lib\site-packages\pyalgotrade\talibext\indicator.py", line 45, in bar_ds_high_to_numpy
    return value_ds_to_numpy(barDs.getHighDataSeries(), count)
AttributeError: 'SequenceDataSeries' object has no attribute 'getHighDataSeries'

コード:

from pyalgotrade.tools import yahoofinance
from pyalgotrade import strategy
from pyalgotrade.barfeed import yahoofeed
from pyalgotrade.technical import stoch
from pyalgotrade import dataseries
from pyalgotrade.technical import ma
from pyalgotrade import technical
from pyalgotrade.technical import highlow
from pyalgotrade import bar
from pyalgotrade.talibext import indicator
from pyalgotrade.technical import rsi
import numpy
import talib


class MyStrategy(strategy.BacktestingStrategy):
    def __init__(self, feed,instrument,smaPeriod,emaPeriod,rsiPeriod,fastk_period,slowk_period,slowd_period):
        strategy.BacktestingStrategy.__init__(self, feed, 1000)      #change portfolio amount
        self.__position = None
        self.__instrument = instrument
        self.setUseAdjustedValues(True)
        self.__prices = feed[instrument].getPriceDataSeries()
        self.__sma = ma.SMA(self.__prices, smaPeriod)
        self.__ema = ma.EMA(self.__prices, emaPeriod)
        self.__rsi = rsi.RSI(self.__prices, rsiPeriod)
        self.__stoch = indicator.STOCH(self.__prices,fastk_period,slowk_period,slowd_period)

今、私はエラーが発生しています:

Traceback (most recent call last):
  File "bobo.py", line 103, in <module>
    main()
  File "bobo.py", line 99, in main
    run_strategy(inst,10,250,14,5,5,5)
  File "bobo.py", line 90, in run_strategy
    myStrategy = MyStrategy(feed, inst, smaPeriod,emaPeriod,rsiPeriod,fastk_period,slowk_period,slowd_period)
  File "bobo.py", line 28, in __init__
    self.__stoch = indicator.STOCH(feed[instrument],fastk_period,slowk_period,slowd_period)
  File "C:\Users\JDOG\Anaconda2\lib\site-packages\pyalgotrade\talibext\indicator.py", line 803, in STOCH
    ret = call_talib_with_hlc(barDs, count, talib.STOCH, fastk_period, slowk_period, slowk_matype, slowd_period, slowd_matype)
  File "C:\Users\JDOG\Anaconda2\lib\site-packages\pyalgotrade\talibext\indicator.py", line 105, in call_talib_with_hlc
    return talibFunc(high, low, close, *args, **kwargs)
  File "talib/func.pyx", line 9388, in talib.func.STOCH (talib\func.c:87125)
Exception: inputs are all NaN
4

1 に答える 1