refactor: MVC 구조 분리 + 미사용 파일 archive 정리
- tick_trader.py를 Controller로 축소, 로직을 3개 모듈로 분리: - core/signal.py: 시그널 감지, 지표 계산 (calc_vr, calc_atr, detect_signal) - core/order.py: Upbit 주문 실행 (매수/매도/취소/조회) - core/position_manager.py: 포지션 관리, DB sync, 복구, 청산 조건 - type hints, Google docstring, 구체적 예외 타입 적용 - 50줄 초과 함수 분리 (process_signal, restore_positions) - 미사용 파일 58개 archive/ 폴더로 이동 - README.md 추가 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
45
archive/tests/trend_check.py
Normal file
45
archive/tests/trend_check.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import os as _os, sys as _sys
|
||||
_sys.path.insert(0, _os.path.dirname(_os.path.dirname(_os.path.abspath(__file__))))
|
||||
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
import oracledb
|
||||
|
||||
conn = oracledb.connect(user=os.getenv('ORACLE_USER'), password=os.getenv('ORACLE_PASSWORD'),
|
||||
dsn=os.getenv('ORACLE_DSN'), config_dir=os.getenv('ORACLE_WALLET'))
|
||||
cur = conn.cursor()
|
||||
|
||||
for ticker in ['KRW-DKA', 'KRW-LAYER', 'KRW-SIGN']:
|
||||
cur.execute("""
|
||||
SELECT price, recorded_at FROM price_history
|
||||
WHERE ticker = :t AND recorded_at >= TIMESTAMP '2026-02-28 20:00:00'
|
||||
ORDER BY recorded_at
|
||||
""", t=ticker)
|
||||
rows = cur.fetchall()
|
||||
|
||||
lookback = 12 # 10분봉 * 12 = 2h
|
||||
gains = []
|
||||
for i in range(lookback, len(rows)):
|
||||
curr = rows[i][0]
|
||||
past = rows[i - lookback][0]
|
||||
if past > 0:
|
||||
gains.append((curr - past) / past * 100)
|
||||
|
||||
if not gains:
|
||||
continue
|
||||
|
||||
above_5 = sum(1 for g in gains if g >= 5.0)
|
||||
above_3 = sum(1 for g in gains if g >= 3.0)
|
||||
above_0 = sum(1 for g in gains if g >= 0.0)
|
||||
negative = sum(1 for g in gains if g < 0.0)
|
||||
|
||||
print(f"[{ticker}] 2h 등락률 분포 ({len(gains)}개 틱)")
|
||||
print(f" 평균={sum(gains)/len(gains):+.2f}% 최고={max(gains):+.2f}% 최저={min(gains):+.2f}%")
|
||||
print(f" +5% 이상(신호): {above_5}건 ({above_5/len(gains)*100:.0f}%)")
|
||||
print(f" +3%~+5%: {above_3-above_5}건 ({(above_3-above_5)/len(gains)*100:.0f}%)")
|
||||
print(f" 0%~+3%: {above_0-above_3}건 ({(above_0-above_3)/len(gains)*100:.0f}%)")
|
||||
print(f" 음전(하락): {negative}건 ({negative/len(gains)*100:.0f}%)")
|
||||
print()
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user