python-dotenv 없을 때 env_loader가 .env를 직접 파싱하도록 해 LIVE_TRADING_ENABLED=1이 dry-run으로 보이던 문제를 해결한다. 06 기동 시 로더·LIVE 상태를 출력하고, B-1 한도 검증·잔고 점검 스크립트를 추가한다. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""3단계: 실거래 (monitor_rules + 빗썸 주문). LIVE_TRADING_ENABLED=1 필수."""
|
|
import argparse
|
|
import runpy
|
|
from pathlib import Path
|
|
|
|
runpy.run_path(str(Path(__file__).resolve().parent / "_bootstrap.py"))
|
|
|
|
from deepcoin.env_loader import ENV_FILE, env_status # noqa: E402
|
|
|
|
from config import (
|
|
GT_INITIAL_CASH_KRW,
|
|
LIVE_DAILY_KRW_MAX,
|
|
LIVE_DAILY_LOSS_LIMIT_KRW,
|
|
LIVE_MAX_TRADES_PER_DAY,
|
|
LIVE_TRADING_ENABLED,
|
|
MONITOR_LOOP_SLEEP_SEC,
|
|
)
|
|
from deepcoin.ops.live_trader import LiveTrader
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="WLD 실거래 (06)")
|
|
parser.add_argument("--once", action="store_true", help="1회만 실행")
|
|
args = parser.parse_args()
|
|
st = env_status()
|
|
mode = "LIVE=ON (실주문)" if LIVE_TRADING_ENABLED else "LIVE=OFF (dry-run)"
|
|
print(
|
|
f"[06] 운영 설정 · {mode} · "
|
|
f"초기₩{GT_INITIAL_CASH_KRW:,} · 일한도₩{LIVE_DAILY_KRW_MAX:,} · "
|
|
f"일손실₩{LIVE_DAILY_LOSS_LIMIT_KRW:,} · max_trades={LIVE_MAX_TRADES_PER_DAY}"
|
|
)
|
|
print(
|
|
f"[06] .env 로더={st.get('loader')} · 파일={ENV_FILE.name} · "
|
|
f"LIVE_TRADING_ENABLED(raw)={st.get('live_trading_enabled')!r}"
|
|
)
|
|
if st.get("loader") == "fallback":
|
|
print(
|
|
"주의: python-dotenv 미설치 — fallback 파서 사용. "
|
|
"권장: pip install python-dotenv (requirements.txt)"
|
|
)
|
|
if not LIVE_TRADING_ENABLED:
|
|
print(
|
|
"주의: LIVE_TRADING_ENABLED=0 — .env에 1인지 확인 후 재기동. "
|
|
"(ncue 등 dotenv 없는 환경이면 pip install python-dotenv)"
|
|
)
|
|
trader = LiveTrader()
|
|
if args.once:
|
|
trader.run_once()
|
|
else:
|
|
trader.run_loop(MONITOR_LOOP_SLEEP_SEC)
|