From 1bf880cebb697f1c199945d19227f3c28d43dec2 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Mar 2026 10:28:39 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=B8=89=E4=B8=AA=E5=AE=9E=E7=9B=98?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=8A=A0dotenv=E5=8A=A0=E8=BD=BD.env?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit live_executor/position_sync/risk_guard启动时自动加载backend/.env 确保TRADE_ENV/BINANCE_API_KEY/SECRET_KEY/PG_HOST等环境变量生效 --- backend/live_executor.py | 5 +++++ backend/position_sync.py | 5 +++++ backend/risk_guard.py | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/backend/live_executor.py b/backend/live_executor.py index 42db7f1..f57c5d0 100644 --- a/backend/live_executor.py +++ b/backend/live_executor.py @@ -11,6 +11,11 @@ Live Executor - 实盘交易执行模块 import os import sys +from pathlib import Path +try: + from dotenv import load_dotenv; load_dotenv(Path(__file__).parent / ".env") +except ImportError: + pass import json import time import logging diff --git a/backend/position_sync.py b/backend/position_sync.py index 675a942..aa68dc3 100644 --- a/backend/position_sync.py +++ b/backend/position_sync.py @@ -10,6 +10,11 @@ Position Sync - 仓位同步与对账模块 import os import sys import json +from pathlib import Path +try: + from dotenv import load_dotenv; load_dotenv(Path(__file__).parent / ".env") +except ImportError: + pass import time import logging import asyncio diff --git a/backend/risk_guard.py b/backend/risk_guard.py index 8263f2b..9d21a79 100644 --- a/backend/risk_guard.py +++ b/backend/risk_guard.py @@ -15,6 +15,11 @@ import os import sys import json import time +from pathlib import Path +try: + from dotenv import load_dotenv; load_dotenv(Path(__file__).parent / ".env") +except ImportError: + pass import logging import asyncio import hashlib