仮想通貨自動売買bot エラー解決のアドバイスお願いします
Q&A
解決したいこと
pythonで仮想通貨の自動売買運用を目指しておりますが、
売買の実行まではできるのですが、その後、エラーが発生。
エラー解決すべく格闘しておりますが、なかなか解決の糸口が見出せず
行き詰っております。
何卒、解決のアドバイスを宜しくお願い致します。
(使用python) ver3.10.5
(使用エディタ) vscode
発生している問題・エラー
(エラー)TypeError: unsupported operand type(s) for +: 'int' and 'str'
過去10足の最安値3203223円を、直近の価格が3201409円でブレイクしました
現在のアカウント残高は179217.0円です
新規注文に利用可能な証拠金の額は179217.0円です
現在の5期間の平均ボラティリティは13947円です
現在のアカウント残高は179217.0円です
許容リスクから購入できる枚数は最大0.03BTCまでです
2回に分けて0.01BTCずつ注文します
証拠金から購入できる枚数は最大0.16BTCまでです
3201409円あたりに0.01BTCの売りの成行注文を出します
--------------------
{'info': {'child_order_acceptance_id': 'JRF20220815-200251-015824'}, 'id': 'JRF20220815-200251-015824'}
--------------------
Traceback (most recent call last):
File "C:\Users\beerm\AppData\Local\Programs\Python\Python310\main1-3.py", line 785, in <module>
flag = entry_signal( data,last_data,flag )
File "C:\Users\beerm\AppData\Local\Programs\Python\Python310\main1-3.py", line 141, in entry_signal
price = bitflyer_market( "SELL", lot )
File "C:\Users\beerm\AppData\Local\Programs\Python\Python310\main1-3.py", line 670, in bitflyer_market
average_price = bitflyer_check_market_order( order_id, lot )
File "C:\Users\beerm\AppData\Local\Programs\Python\Python310\main1-3.py", line 693, in bitflyer_check_market_order
if round(sum(size),2) != lot:
TypeError: unsupported operand type(s) for +: 'int' and 'str'
発生している問題・エラー
# 成行注文の執行状況を確認する関数
def bitflyer_check_market_order(id,lot):
while True:
try:
size = []
price = []
executions = bitflyer.private_get_getexecutions( params = { "product_code" : "FX_BTC_JPY" })
for exec in executions:
if exec["child_order_acceptance_id"] == id:
size.append( exec["size"] )
price.append( exec["price"] )
# 全部約定するまで待つ
if round(sum(size) ,2) != lot:
time.sleep(20)
print_log("注文がすべて約定するのを待っています")
else:
# 平均価格を計算する
average_price = round(sum(( price[i]) * (size[i]) for i in (range(len(price)) )) / sum(size))
print_log("すべての成行注文が執行されました")
print_log("執行価格は平均 {}円です".format(average_price))
return average_price
except ccxt.BaseError as e:
print_log("BitflyerのAPIで問題発生 : " + str(e))
print_log("20秒待機してやり直します"){\rtf1}
###確認したこと
(エラー693行目)if round(sum(size) ,2) != lot:
size → list 、 lot → Any