refactor: reorganize project structure into tests/, data/, logs/
- Move all backtest/simulation scripts to tests/ - Add sys.path.insert to each script for correct import resolution - Move pkl cache files to data/ (git-ignored) - Move log files to logs/ (git-ignored) - Update main.py: trading.log path → logs/trading.log - Add ecosystem.config.js: pm2 log paths → logs/pm2*.log - Update .gitignore: ignore data/ and logs/ instead of *.pkl/*.log - core/fng.py: increase cache TTL 3600→86400s (API updates daily at KST 09:00) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
45
tests/trend_check.py
Normal file
45
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