Pyalgotrade를 사용할 때 Python의 TypeError

치 펑우

Pyalgotrade 라이브러리의 목록 기능을 사용하여 Python에서 Stochcastic Oscillator를 작성하려고합니다.

내 코드는 다음과 같습니다.

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
import numpy
import talib

class MyStrategy(strategy.BacktestingStrategy):
    def __init__(self, feed, instrument):
        strategy.BacktestingStrategy.__init__(self, feed)  
        self.__instrument = instrument

    def onBars(self, bars):

        barDs = self.getFeed().getDataSeries("002389.SZ")

        self.__stoch = indicator.STOCH(barDs, 20, 3, 3)

        bar = bars[self.__instrument]
        self.info("%0.2f, %0.2f" % (bar.getClose(), self.__stoch[-1]))

# Downdload then Load the yahoo feed from the CSV file
yahoofinance.download_daily_bars('002389.SZ', 2013, '002389.csv')
feed = yahoofeed.Feed()
feed.addBarsFromCSV("002389.SZ", "002389.csv")

# Evaluate the strategy with the feed's bars.
myStrategy = MyStrategy(feed, "002389.SZ")
myStrategy.run()

그리고 다음과 같은 오류가 발생했습니다.

  File "/Users/johnhenry/Desktop/simple_strategy.py", line 46, in onBars
    self.info("%0.2f, %0.2f" % (bar.getClose(), self.__stoch[-1]))
TypeError: float argument required, not numpy.ndarray

확률 적 :

pyalgotrade.talibext.indicator.STOCH (barDs, count, fastk_period = -2147483648, slowk_period = -2147483648, slowk_matype = 0, slowd_period = -2147483648, slowd_matype = 0)

보니파시오 2

하나 bar.getClose()또는 self.__stoch[-1]을 반환 numpy.ndarray모두 반환해야한다 반면 float들.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

유사 쿼리를 사용할 때 TypeError

분류에서Dev

VueJS에서 Typescript를 사용할 때 TypeError

분류에서Dev

Python3 : TypeError : 해시 할 수없는 유형 : Counter를 사용할 때 'list'

분류에서Dev

TypeError : requireJ를 사용할 때 scrollto가 정의되지 않았습니다.

분류에서Dev

pdfMake pdf 엔진에서 사용자 정의 이미지를 사용할 때 "Uncaught TypeError : Cannot read property 'embed'of undefined"발생

분류에서Dev

'Uncaught TypeError : jQuery를 사용할 때 정의되지 않은'timestamp '속성을 설정할 수 없습니다.

분류에서Dev

NameError : Python에서 Pyalgotrade를 사용하여 전역 이름 'indicator'가 정의되지 않았습니다.

분류에서Dev

Tkinter를 사용하여 함수를 호출 할 때 TypeError

분류에서Dev

Stack Navigator를 사용할 때 "TypeError : (0, _reactNavigationStack.default) is not a function"

분류에서Dev

gulp를 사용할 때 'TypeError : args.cb is not a function'오류 발생

분류에서Dev

jQuery UI를 사용하려고 할 때 "TypeError : 'undefined'is not a function"발생

분류에서Dev

JS : putImageData를 사용하려고 할 때 "Uncaught TypeError : Type error"발생

분류에서Dev

numba를 사용하여 numpy 배열을 인덱싱 할 때 TypeError

분류에서Dev

플롯에 날짜 시간 객체를 사용할 때 TypeError

분류에서Dev

IIFE를 사용하려고 할 때 잡히지 않은 TypeError

분류에서Dev

Uncaught TypeError : React MuiAlert를 사용하려고 할 때 undefined의 'main'속성을 읽을 수 없습니다.

분류에서Dev

TypeError : EarlyStopping keras에서 restore_best_weights = True를 사용할 때 'NoneType'유형의 개체에 len ()이 없습니다.

분류에서Dev

TypeError : axios HTTP 드라이버를 사용할 때 this.Vue.axios가 정의되지 않았습니다.

분류에서Dev

Vanilla Tilt를 React와 함께 사용하려고 할 때 "TypeError : Object (...) is not a function"의 원인은 무엇입니까?

분류에서Dev

TypeError : 상태를 사용할 때 정의되지 않은 '0'속성을 읽을 수 없습니다.

분류에서Dev

TypeError : Google Map API를 사용할 때지도가 정의되지 않았습니다.

분류에서Dev

cloneNode를 사용할 때 음의 rowIndex

분류에서Dev

NumPy를 사용할 때의 긴 정수

분류에서Dev

Python에서 except를 사용할 때 SyntaxError

분류에서Dev

pytesseract를 사용할 때 python FileNotFoundError

분류에서Dev

[groupby]를 사용할 때 중간 열의 Python Pandas 정렬

분류에서Dev

Python에서 argparse를 사용할 때의 혼란

분류에서Dev

신경망에 Python의 Keras를 사용할 때 유형 오류

분류에서Dev

for 루프를 사용할 때 Python의 변수 범위

Related 관련 기사

  1. 1

    유사 쿼리를 사용할 때 TypeError

  2. 2

    VueJS에서 Typescript를 사용할 때 TypeError

  3. 3

    Python3 : TypeError : 해시 할 수없는 유형 : Counter를 사용할 때 'list'

  4. 4

    TypeError : requireJ를 사용할 때 scrollto가 정의되지 않았습니다.

  5. 5

    pdfMake pdf 엔진에서 사용자 정의 이미지를 사용할 때 "Uncaught TypeError : Cannot read property 'embed'of undefined"발생

  6. 6

    'Uncaught TypeError : jQuery를 사용할 때 정의되지 않은'timestamp '속성을 설정할 수 없습니다.

  7. 7

    NameError : Python에서 Pyalgotrade를 사용하여 전역 이름 'indicator'가 정의되지 않았습니다.

  8. 8

    Tkinter를 사용하여 함수를 호출 할 때 TypeError

  9. 9

    Stack Navigator를 사용할 때 "TypeError : (0, _reactNavigationStack.default) is not a function"

  10. 10

    gulp를 사용할 때 'TypeError : args.cb is not a function'오류 발생

  11. 11

    jQuery UI를 사용하려고 할 때 "TypeError : 'undefined'is not a function"발생

  12. 12

    JS : putImageData를 사용하려고 할 때 "Uncaught TypeError : Type error"발생

  13. 13

    numba를 사용하여 numpy 배열을 인덱싱 할 때 TypeError

  14. 14

    플롯에 날짜 시간 객체를 사용할 때 TypeError

  15. 15

    IIFE를 사용하려고 할 때 잡히지 않은 TypeError

  16. 16

    Uncaught TypeError : React MuiAlert를 사용하려고 할 때 undefined의 'main'속성을 읽을 수 없습니다.

  17. 17

    TypeError : EarlyStopping keras에서 restore_best_weights = True를 사용할 때 'NoneType'유형의 개체에 len ()이 없습니다.

  18. 18

    TypeError : axios HTTP 드라이버를 사용할 때 this.Vue.axios가 정의되지 않았습니다.

  19. 19

    Vanilla Tilt를 React와 함께 사용하려고 할 때 "TypeError : Object (...) is not a function"의 원인은 무엇입니까?

  20. 20

    TypeError : 상태를 사용할 때 정의되지 않은 '0'속성을 읽을 수 없습니다.

  21. 21

    TypeError : Google Map API를 사용할 때지도가 정의되지 않았습니다.

  22. 22

    cloneNode를 사용할 때 음의 rowIndex

  23. 23

    NumPy를 사용할 때의 긴 정수

  24. 24

    Python에서 except를 사용할 때 SyntaxError

  25. 25

    pytesseract를 사용할 때 python FileNotFoundError

  26. 26

    [groupby]를 사용할 때 중간 열의 Python Pandas 정렬

  27. 27

    Python에서 argparse를 사용할 때의 혼란

  28. 28

    신경망에 Python의 Keras를 사용할 때 유형 오류

  29. 29

    for 루프를 사용할 때 Python의 변수 범위

뜨겁다태그

보관