diff --git a/.cursorrules b/.cursorrules new file mode 100644 index 0000000..bfd675c --- /dev/null +++ b/.cursorrules @@ -0,0 +1,20 @@ +# 1. 역할 (Role & Persona) +- 당신은 '세계 최고의 퀀트 개발자'이자 '헤지펀드 매니저'입니다. 동시에 초보자를 위한 최고의 코딩 멘토입니다. +- 금융 공학적 관점에서 수익을 극대화하고 리스크를 최소화하는 논리를 제시하되, 설명은 아주 쉽고 친절하게 하세요. + +# 2. 코드 작성 및 제공 원칙 (Strict Rules) +- [전체 코드 제공]: 코드는 반드시 '전체 소스(Full Source)'를 제공하세요. `// ... 생략`은 절대 금지합니다. 함수가 3줄 이하라면 3줄 전체를 제공하고, 수정할 때도 생략 없이 온전한 코드를 줍니다. +- [기존 구조 존중]: 잘 작동하는 코드를 '더 나은 구조'라며 임의로 클래스화하거나 복잡하게 바꾸지 마세요. 기존의 주석과 로거(Logger)는 절대 지우지 말고 유지하세요. +- [설명 후 수정]: 핵심 로직을 변경해야 할 때는 코드를 짜기 전에 반드시 이유를 먼저 설명하고 승인을 받으세요. +- [교육적 주석]: 주식 투자 용어(RSI, 변동성, 꼬리잡기 등)나 새로운 개념이 나올 때는 코딩에 추가할 때 이해하기 쉽게 주석을 달아주세요. +- 빼먹거나 놓치는 부분 없이 꼼꼼하게 검증한 후 코드를 출력하세요. + +# 3. 투자 철학 및 매매 로직 (Trading Philosophy) +- 모든 매매 로직은 '안정성(Safety)'을 최우선으로 하며, 손절(Stop-loss) 로직은 필수입니다. +- 백테스트(Backtest)가 불가능한 '뇌동매매' 기반의 코드는 작성하지 않습니다. +- 수수료(Fees)와 슬리피지(Slippage), API 호출 효율성을 철저히 고려하여 코드를 작성하세요. + +# 4. 시스템 아키텍처 및 통신 (System Architecture) +- [즉시 저장 (Atomic Save)]: 데이터 파일(json 등)은 프로그램 종료 시점이 아니라, 이벤트(알림 발송 등)가 발생할 때마다 즉시 저장하세요. 재시작 시 기존 데이터를 삭제하지 않고 수정 데이터만 끼워 넣는 방식으로 안정적으로 운영하세요. +- [API 요청 규칙]: 모든 API 요청은 `utils/request_handler.py`의 `SafeRequest` 클래스를 상속받아 구현하세요. HTTP 429(Too Many Requests) 에러 발생 시 재시도(Retry) 로직을 반드시 포함하세요. +- [알림 시스템]: 알림 기능은 텔레그램과 매터모스트용(msg_tg, msg_mm)으로 분리하여 구현하고, 서버 부하 방지를 위해 일반 루프에는 `random.sleep(1~3)`을 기본 적용하세요. (실시간 매매 로직 제외) \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0c53104 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info + +# Virtual environments +.venv +.env +# Environment variables +.env +*.log +*.json +*.db \ No newline at end of file diff --git a/__pycache__/database.cpython-312.pyc b/__pycache__/database.cpython-312.pyc index 2bd5861..2a6eb76 100644 Binary files a/__pycache__/database.cpython-312.pyc and b/__pycache__/database.cpython-312.pyc differ diff --git a/__pycache__/ml_predictor.cpython-312.pyc b/__pycache__/ml_predictor.cpython-312.pyc index bd19741..4d87d7f 100644 Binary files a/__pycache__/ml_predictor.cpython-312.pyc and b/__pycache__/ml_predictor.cpython-312.pyc differ diff --git a/__pycache__/risk_manager.cpython-312.pyc b/__pycache__/risk_manager.cpython-312.pyc index 1ef8794..4f1530b 100644 Binary files a/__pycache__/risk_manager.cpython-312.pyc and b/__pycache__/risk_manager.cpython-312.pyc differ diff --git a/quant_bot.db b/quant_bot.db index a7d8ab6..8da240b 100644 Binary files a/quant_bot.db and b/quant_bot.db differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4752418 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,118 @@ +aiofiles==25.1.0 +annotated-types==0.7.0 +anthropic==0.79.0 +anyio==4.12.1 +asgi-csrf==0.11 +asgiref==3.11.1 +async-generator==1.10 +attrs==25.4.0 +beautifulsoup4==4.14.3 +certifi==2026.1.4 +cffi==2.0.0 +charset-normalizer==3.4.4 +click==8.1.8 +click-default-group==1.2.4 +cryptography==46.0.5 +curl_cffi==0.13.0 +datasette==0.65.2 +datasette-cluster-map==0.18.2 +datasette-export-notebook==1.0.1 +datasette-leaflet==0.2.2 +datasette-vega==0.6.2 +distro==1.9.0 +docstring_parser==0.17.0 +dotenv==0.9.9 +flexcache==0.3 +flexparser==0.4 +frozendict==2.4.7 +google-ai-generativelanguage==0.6.15 +google-api-core==2.29.0 +google-api-python-client==2.189.0 +google-auth==2.49.0.dev0 +google-auth-httplib2==0.3.0 +google-genai==1.63.0 +google-generativeai==0.8.6 +googleapis-common-protos==1.72.0 +grpcio==1.78.0 +grpcio-status==1.71.2 +h11==0.16.0 +html5lib==1.1 +httpcore==1.0.9 +httplib2==0.31.2 +httpx==0.28.1 +hupper==1.12.1 +idna==3.11 +importlib_metadata==8.7.1 +iniconfig==2.1.0 +itsdangerous==2.2.0 +janus==2.0.0 +Jinja2==3.1.6 +jiter==0.13.0 +joblib==1.5.3 +-e git+http://192.168.0.141:30008/kiwoom_bot/kiwoom_bot.git@09e3a15c1238582d4622d230f6217db4a7edd662#egg=kiwoom_rest_api +lxml==6.0.2 +markdown-it-py==3.0.0 +MarkupSafe==3.0.3 +mattermostdriver==7.3.2 +mdurl==0.1.2 +mergedeep==1.3.4 +multitasking==0.0.12 +mypy_extensions==1.1.0 +numpy==2.4.1 +outcome==1.3.0.post0 +packaging==26.0 +pandas==3.0.0 +peewee==3.19.0 +platformdirs==4.5.1 +pluggy==1.6.0 +proto-plus==1.27.1 +protobuf==5.29.6 +pyasn1==0.6.2 +pyasn1_modules==0.4.2 +pycparser==3.0 +pydantic==2.12.5 +pydantic_core==2.41.5 +Pygments==2.19.2 +pyparsing==3.3.2 +PySocks==1.7.1 +pytest==8.4.2 +pytest-httpx==0.35.0 +python-dateutil==2.9.0.post0 +python-dotenv==1.2.1 +python-multipart==0.0.22 +pytrends==4.9.2 +pytz==2025.2 +PyYAML==6.0.3 +requests==2.32.5 +rich==13.9.4 +scikit-learn==1.8.0 +scipy==1.17.0 +selenium==4.40.0 +setuptools==80.10.2 +shellingham==1.5.4 +six==1.17.0 +sniffio==1.3.1 +sortedcontainers==2.4.0 +soupsieve==2.8.3 +tenacity==9.1.4 +threadpoolctl==3.6.0 +tqdm==4.67.3 +trio==0.33.0 +trio-typing==0.10.0 +trio-websocket==0.12.2 +typer==0.9.4 +types-certifi==2021.10.8.3 +types-urllib3==1.26.25.14 +typing-inspection==0.4.2 +typing_extensions==4.15.0 +uritemplate==4.2.0 +urllib3==2.6.3 +uvicorn==0.40.0 +webdriver-manager==4.0.2 +webencodings==0.5.1 +websocket-client==1.9.0 +websockets==15.0.1 +wheel==0.46.3 +wsproto==1.3.2 +yfinance==0.2.39 +zipp==3.23.0 diff --git a/update_env_simple.py b/update_env_simple.py index 86ae4ce..0e8b69d 100644 --- a/update_env_simple.py +++ b/update_env_simple.py @@ -54,9 +54,9 @@ if __name__ == "__main__": # 여기에 업데이트할 값들을 딕셔너리로 넣으세요 my_updates = { # 한투 API 설정 - - # "KIS_APP_KEY_REAL": "PSUbfJUp3eiA0rthF1GSK8yWI7dD7GvXMPQL", # 여기에 앱키 입력 - # "KIS_APP_SECRET_REAL": "DzG04RbksnUMROslum/2DliJiVZAdeSgwUNHKSbFehMmD2WKGVUeSd0N1B8LY947W/aNtEmU8pdkvKTFnVX1u68DvCj7cvEtlJc++wCUeaRD3z1Ov48b5PLsPiWvwE+pMd0pEl6jmFg0J6td1TidugAsZtEQ3GUBimyQyDSgw3jkdbnM390=", + "KIS_MOCK": "true", + "KIS_APP_KEY_REAL": "PSUT2l4CO94DjrwDa2EAnEl639YXnWHdbbkN", # 여기에 앱키 입력 + "KIS_APP_SECRET_REAL": "2SkPBKrztpBomcR+pYNEBuVa5/iSqYLQxsDn/YqJuQ0dULp/GqTAePhe4czJHuf/1XBUd18KDV6ZTrmxfI8eTiCfIEaO6jMKSq0u+CoUkHTrO9TfliYtxsNbl43jL+rokLB54V2VmHrlqM4WCF+54bMWhzzSE7z3OOl67V9yWKCWIoTrcYg=", # "KIS_APP_KEY_MOCK": "PSdfKtsMihgC9tLiUr2XISscuR3fHxl6kvmV", # 여기에 앱키 입력` # "KIS_APP_SECRET_MOCK": "Ip+XZrZcoz11thgDD40XS8i6R1AalYkKFZwg2w8+ZMulVKN8rJVXiqGONxc4EYxw1S3TgOcx7fSldDc6EGq63bprfbgHwKWxstu29ZmLAtRNU0oFqV7e9vCOfgiWxrfnCqwcihoS7ovmza9+Ylqd8/EtjFGNmhQHWocyTAm8kdp5IG6tFtc=", # 여기에 앱시크릿 입력