23423423
This commit is contained in:
@@ -66,8 +66,14 @@ class BitmartFuturesTransaction:
|
||||
formatted.sort(key=lambda x: x['id'])
|
||||
return formatted # 最近3根: kline_1 (最老), kline_2, kline_3 (最新)
|
||||
except Exception as e:
|
||||
logger.error(f"获取K线异常: {e}")
|
||||
self.ding(msg="获取K线异常", error=True)
|
||||
error_msg = str(e)
|
||||
# 检查是否是429限流错误
|
||||
if "429" in error_msg or "too many requests" in error_msg.lower():
|
||||
logger.warning(f"API限流,等待60秒后重试: {e}")
|
||||
time.sleep(60) # 等待60秒后重试
|
||||
else:
|
||||
logger.error(f"获取K线异常: {e}")
|
||||
self.ding(msg="获取K线异常", error=True)
|
||||
return None
|
||||
|
||||
def get_current_price(self):
|
||||
@@ -346,6 +352,8 @@ class BitmartFuturesTransaction:
|
||||
new_price_datas = self.get_klines()
|
||||
if not new_price_datas:
|
||||
logger.info("获取最新价格有问题!!!")
|
||||
time.sleep(5) # 等待一段时间后重试
|
||||
continue # 跳过本次循环,避免对None进行排序操作
|
||||
|
||||
new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"])
|
||||
self.kline_1, self.kline_2, self.kline_3 = new_price_datas1[-3:]
|
||||
|
||||
Reference in New Issue
Block a user