first vibe coding
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
FROM python:3.11-slim
|
||||
WORKDIR /app
|
||||
RUN pip install --no-cache-dir aiohttp python-dotenv
|
||||
COPY kill.py .
|
||||
CMD ["python", "kill.py"]
|
||||
@@ -0,0 +1,51 @@
|
||||
"""
|
||||
kill_switch/kill.py
|
||||
긴급 전량 청산 스크립트
|
||||
단독 실행: python kill_switch/kill.py
|
||||
"""
|
||||
import os, sys, asyncio
|
||||
from pathlib import Path
|
||||
|
||||
def load_env():
|
||||
for p in [Path(".env"), Path("../.env")]:
|
||||
if p.exists():
|
||||
with open(p) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
k, _, v = line.partition("=")
|
||||
k = k.strip(); v = v.strip().strip('"').strip("'")
|
||||
if k and v and k not in os.environ:
|
||||
os.environ[k] = v
|
||||
break
|
||||
|
||||
load_env()
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from app.execution.kis_client import KISClient
|
||||
|
||||
async def kill_all():
|
||||
print("=" * 40)
|
||||
print(" 긴급 전량 청산 실행")
|
||||
print("=" * 40)
|
||||
|
||||
kis = KISClient()
|
||||
balance = await kis.get_balance()
|
||||
holdings = balance.get("holdings", [])
|
||||
|
||||
if not holdings:
|
||||
print(" 보유 종목 없음")
|
||||
return
|
||||
|
||||
print(f" 보유 종목: {len(holdings)}개")
|
||||
for h in holdings:
|
||||
print(f" 청산 중: {h['name']}({h['ticker']}) {h['qty']}주")
|
||||
await kis.order_sell(h["ticker"], h["qty"])
|
||||
print(f" ✅ 완료")
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
print(" 전량 청산 완료")
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(kill_all())
|
||||
Reference in New Issue
Block a user