Python初心者です。
先物の自動売買ツールの作成に挑戦しております。
以下のエラーが解消できません。大変初歩的なエラーかと思うのですが、
何卒、ご教示ください。
よろしくお願いいたします。
エラー内容
Traceback (most recent call last):
File "gajumaru2.py", line 99, in <module>
main()
File "gajumaru2.py", line 90, in main
startflg, curprice = get_price(lastprice, curprice);
File "gajumaru2.py", line 6, in get_price
if curprice > (lastprice + 50):
TypeError: '>' not supported between instances of 'str' and 'int'
対象ソース
Python
1#価格情報を取得 2#前回取得した価格との差が50円以上の場合のみ、後続の処理を行う。 3def get_price(lastprice, curprice): 4 if curprice > (lastprice + 50): 5 startflg = True 6 return startflg, curprice 7 elif curprice < (lastprice - 50): 8 startflg = True 9 return startflg, curprice 10 else: 11 startflg = False 12 return startflg, curprice;
Python
1#主処理 2def main(): 3 4#変数の初期化 5#現在の価格 6 curprice = 0 7#前回の価格 8 lastprice = 0 9#現在のポジション 10 positionflg = False 11#掛け枚数 12 curcoin = 1 13 pricetrend = 1 14 15 for i in range(5): 16 lastprice = curprice 17 print('-' * 20) 18 curprice = input('Current Price : >') 19 print('-' * 20) 20 startflg, curprice = get_price(lastprice, curprice); 21 if startflg == False: 22 continue 23 else: 24 #現在価格が前回価格より、50円以上上回っている場合、価格分析を行う。 25 pricetrend, mountain, vally = ana_price(pricetrend, curprice, lastprice) 26 i += 1 27 28if __name__ == '__main__': 29 main()

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/04/21 12:20
2018/04/21 16:05