diff --git a/backend/backtest.py b/backend/backtest.py index 37b4578..6de44b3 100644 --- a/backend/backtest.py +++ b/backend/backtest.py @@ -35,7 +35,7 @@ logging.basicConfig( ) logger = logging.getLogger("backtest") -PG_HOST = os.getenv("PG_HOST", "10.106.0.3") +PG_HOST = os.getenv("PG_HOST", "127.0.0.1") PG_PORT = int(os.getenv("PG_PORT", "5432")) PG_DB = os.getenv("PG_DB", "arb_engine") PG_USER = os.getenv("PG_USER", "arb") diff --git a/backend/db.py b/backend/db.py index fc845dd..dd46397 100644 --- a/backend/db.py +++ b/backend/db.py @@ -1,6 +1,6 @@ """ db.py — PostgreSQL 数据库连接层 -统一连接到 Cloud SQL(PG_HOST 默认 10.106.0.3) +统一连接到 Cloud SQL(PG_HOST 默认 127.0.0.1) 同步连接池(psycopg2)供脚本类使用 异步连接池(asyncpg)供FastAPI使用 """ @@ -13,7 +13,7 @@ import psycopg2.pool from contextlib import contextmanager # PG连接参数(统一连接 Cloud SQL) -PG_HOST = os.getenv("PG_HOST", "10.106.0.3") +PG_HOST = os.getenv("PG_HOST", "127.0.0.1") PG_PORT = int(os.getenv("PG_PORT", 5432)) PG_DB = os.getenv("PG_DB", "arb_engine") PG_USER = os.getenv("PG_USER", "arb") diff --git a/backend/ecosystem.dev.config.js b/backend/ecosystem.dev.config.js index 26a0623..e3e7703 100644 --- a/backend/ecosystem.dev.config.js +++ b/backend/ecosystem.dev.config.js @@ -5,8 +5,8 @@ module.exports = { interpreter: "python3", cwd: "/root/Projects/arbitrage-engine/backend", env: { - PG_HOST: "34.85.117.248", - CLOUD_PG_HOST: "34.85.117.248", + PG_HOST: "127.0.0.1", + CLOUD_PG_HOST: "127.0.0.1", CLOUD_PG_ENABLED: "true" } }] diff --git a/backend/live_executor.py b/backend/live_executor.py index 795a281..fb7b29d 100644 --- a/backend/live_executor.py +++ b/backend/live_executor.py @@ -49,7 +49,7 @@ if not _DB_PASSWORD: sys.exit(1) DB_CONFIG = { - "host": os.getenv("DB_HOST", "10.106.0.3"), + "host": os.getenv("DB_HOST", "127.0.0.1"), "port": int(os.getenv("DB_PORT", "5432")), "dbname": os.getenv("DB_NAME", "arb_engine"), "user": os.getenv("DB_USER", "arb"), diff --git a/backend/market_data_collector.py b/backend/market_data_collector.py index ccd5940..e0cc3b5 100644 --- a/backend/market_data_collector.py +++ b/backend/market_data_collector.py @@ -12,7 +12,7 @@ from psycopg2.extras import Json SYMBOLS = ["BTCUSDT", "ETHUSDT", "XRPUSDT", "SOLUSDT"] INTERVAL_SECONDS = 300 -PG_HOST = os.getenv("PG_HOST", "10.106.0.3") +PG_HOST = os.getenv("PG_HOST", "127.0.0.1") PG_PORT = int(os.getenv("PG_PORT", "5432")) PG_DB = os.getenv("PG_DB", "arb_engine") PG_USER = os.getenv("PG_USER", "arb") diff --git a/backend/migrate_v54.py b/backend/migrate_v54.py index 8e8abac..64ed46c 100644 --- a/backend/migrate_v54.py +++ b/backend/migrate_v54.py @@ -12,7 +12,7 @@ import sys import psycopg2 from psycopg2.extras import execute_values -PG_HOST = os.environ.get("PG_HOST", "10.106.0.3") +PG_HOST = os.environ.get("PG_HOST", "127.0.0.1") PG_PASS = os.environ.get("PG_PASS", "arb_engine_2026") PG_USER = "arb" PG_DB = "arb_engine" diff --git a/backend/migrate_v54b_gates.py b/backend/migrate_v54b_gates.py index b7a4ea1..d44dd4b 100644 --- a/backend/migrate_v54b_gates.py +++ b/backend/migrate_v54b_gates.py @@ -22,7 +22,7 @@ import os, sys import psycopg2 from psycopg2.extras import RealDictCursor -PG_HOST = os.getenv("PG_HOST", "10.106.0.3") +PG_HOST = os.getenv("PG_HOST", "127.0.0.1") PG_USER = os.getenv("PG_USER", "arb") PG_PASS = os.getenv("PG_PASS", "arb_engine_2026") PG_DB = os.getenv("PG_DB", "arb_engine") diff --git a/backend/position_sync.py b/backend/position_sync.py index 340c705..5a06845 100644 --- a/backend/position_sync.py +++ b/backend/position_sync.py @@ -40,7 +40,7 @@ if not _DB_PASSWORD: sys.exit(1) DB_CONFIG = { - "host": os.getenv("DB_HOST", "10.106.0.3"), + "host": os.getenv("DB_HOST", "127.0.0.1"), "port": int(os.getenv("DB_PORT", "5432")), "dbname": os.getenv("DB_NAME", "arb_engine"), "user": os.getenv("DB_USER", "arb"), diff --git a/backend/risk_guard.py b/backend/risk_guard.py index 62c40d7..6f41d1f 100644 --- a/backend/risk_guard.py +++ b/backend/risk_guard.py @@ -47,7 +47,7 @@ if not _DB_PASSWORD: sys.exit(1) DB_CONFIG = { - "host": os.getenv("DB_HOST", "10.106.0.3"), + "host": os.getenv("DB_HOST", "127.0.0.1"), "port": int(os.getenv("DB_PORT", "5432")), "dbname": os.getenv("DB_NAME", "arb_engine"), "user": os.getenv("DB_USER", "arb"), diff --git a/scripts/replay_paper_trades.py b/scripts/replay_paper_trades.py index 410d177..a815c7c 100644 --- a/scripts/replay_paper_trades.py +++ b/scripts/replay_paper_trades.py @@ -239,7 +239,7 @@ def replay_trade(cur, tid, symbol, direction, strategy, entry_ts, atr): def main(dry_run=False): - conn = psycopg2.connect(host='10.106.0.3', dbname='arb_engine', user='arb', password='arb_engine_2026') + conn = psycopg2.connect(host='127.0.0.1', dbname='arb_engine', user='arb', password='arb_engine_2026') cur = conn.cursor() cur.execute("""