update polymarket trading: fix auth, add order monitoring, optimize status handling, remove unused scripts
This commit is contained in:
1 parent
7004b281a4
commit
f13b1c1afe
7 files changed
+378
-504
No files matched your search
+23
-2
@@ -91,6 +91,23 @@ def terminate_process(process, name):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def send_alert(content):
|
||||
"""发送告警消息 (使用 curl)"""
|
||||
try:
|
||||
url = "https://zhiyinzhe.xyz/sendMsg/api/send"
|
||||
cmd = [
|
||||
"curl", "-X", "POST", url,
|
||||
"-F", "bot_name=weibo",
|
||||
"-F", "receive_id=on_f972f5f8c4de6ac967574b97dc8c1d82",
|
||||
"-F", "receive_id_type=union_id",
|
||||
"-F", f"content={content}"
|
||||
]
|
||||
# 使用 run 等待请求完成,确保告警发出
|
||||
subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=10)
|
||||
log(f"已发送告警: {content}", GREEN)
|
||||
except Exception as e:
|
||||
log(f"发送告警失败: {e}", RED)
|
||||
|
||||
def main():
|
||||
# 激活 Conda 环境
|
||||
# 注意:在子进程中直接使用当前已激活的 python 解释器路径,避免 conda activate 问题
|
||||
@@ -117,10 +134,14 @@ def main():
|
||||
# 监控子进程状态
|
||||
while True:
|
||||
if api_process and api_process.poll() is not None:
|
||||
log("API 服务意外退出", RED)
|
||||
msg = "API 服务意外退出"
|
||||
log(msg, RED)
|
||||
send_alert(msg)
|
||||
break
|
||||
if trade_process and trade_process.poll() is not None:
|
||||
log("自动交易程序意外退出", RED)
|
||||
msg = "自动交易程序意外退出"
|
||||
log(msg, RED)
|
||||
send_alert(msg)
|
||||
break
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
Reference in new issue
Block a user