fix: .env 미로드(ncue) fallback 및 B-1 운영 설정 정합
python-dotenv 없을 때 env_loader가 .env를 직접 파싱하도록 해 LIVE_TRADING_ENABLED=1이 dry-run으로 보이던 문제를 해결한다. 06 기동 시 로더·LIVE 상태를 출력하고, B-1 한도 검증·잔고 점검 스크립트를 추가한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
48
scripts/check_balance.py
Normal file
48
scripts/check_balance.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
"""빗썸 실계좌 잔고 조회 (운영 점검용)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import runpy
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
runpy.run_path(str(Path(__file__).resolve().parent / "_bootstrap.py"))
|
||||
|
||||
from config import GT_INITIAL_CASH_KRW, LIVE_TRADING_ENABLED, SYMBOL # noqa: E402
|
||||
from deepcoin.ops.monitor import Monitor # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""
|
||||
KRW·거래 심볼 잔고를 출력합니다.
|
||||
|
||||
Returns:
|
||||
0 성공, 1 API 오류.
|
||||
"""
|
||||
print(f"LIVE_TRADING_ENABLED={int(LIVE_TRADING_ENABLED)}")
|
||||
print(f"GT_INITIAL_CASH_KRW=₩{GT_INITIAL_CASH_KRW:,}")
|
||||
m = Monitor(cooldown_file=None)
|
||||
raw = m.getBalances()
|
||||
if isinstance(raw, dict) and raw.get("error"):
|
||||
print("API_ERROR", raw.get("error"))
|
||||
return 1
|
||||
if not isinstance(raw, list):
|
||||
print("UNEXPECTED_RESPONSE", type(raw))
|
||||
return 1
|
||||
krw = next((x for x in raw if x.get("currency") == "KRW"), None)
|
||||
coin = next((x for x in raw if x.get("currency") == SYMBOL), None)
|
||||
if krw:
|
||||
bal = float(krw["balance"])
|
||||
print(f"KRW available=₩{bal:,.0f}")
|
||||
if bal < float(GT_INITIAL_CASH_KRW):
|
||||
print(f" [WARN] 가용 KRW < 초기자금 ₩{GT_INITIAL_CASH_KRW:,}")
|
||||
if coin:
|
||||
print(f"{SYMBOL} qty={float(coin['balance']):.6f}")
|
||||
else:
|
||||
print(f"{SYMBOL} qty=0")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user