This repository has been archived on 2025-06-07. You can view files and clone it, but cannot push or open issues or pull requests.
2025-05-06 21:23:04 +09:00

53 lines
2.0 KiB
Python

import os
import argparse
import pandas as pd
from risk_manage_engine.risk_calculator import calculate_all_risks
from risk_manage_engine.risk_scorer import compute_risk_score
from risk_manage_engine.filter import filter_by_risk
def evaluate_predictions(prediction_file, cds_dir, output_path="risk_filtered_result.csv"):
df = pd.read_csv(prediction_file)
results = []
for _, row in df.iterrows():
symbol = row["symbol"]
score = row["predicted_score"]
cds_path = os.path.join(cds_dir, f"{symbol}_ohlcv.csv")
if not os.path.exists(cds_path):
continue
try:
df_cds = pd.read_csv(cds_path)
risk_factors = calculate_all_risks(df_cds)
risk_score = compute_risk_score(risk_factors)
results.append({
"symbol": symbol,
"predicted_score": score,
"risk_score": risk_score,
"tradable": risk_score >= 60 # 기준점은 조정 가능
})
except Exception as e:
print(f"{symbol} 리스크 평가 중 오류 발생: {e}")
continue
result_df = pd.DataFrame(results)
print("\n[리스크 평가 요약]")
print(result_df)
result_df.to_csv(output_path, index=False)
print(f"\n결과가 다음 위치에 저장되었습니다: {output_path}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="SightRay 리스크 평가 실행")
parser.add_argument('--cds_dir', type=str, required=True, help='CDS 디렉토리 경로')
parser.add_argument('--prediction_file', type=str, required=True, help='예측 결과 CSV 파일 경로')
parser.add_argument('--output_file', type=str, default='risk_filtered_result.csv', help='리스크 평가 결과 저장 경로')
args = parser.parse_args()
evaluate_predictions(
prediction_file=args.prediction_file,
cds_dir=args.cds_dir,
output_path=args.output_file
)