a7c28f240d
### 데이터 로드 (100% 커버리지) - GatherTradingData.xlsx에서 20개 시트 추출 (7,495 rows) - kis_data_collection.db: data_feed 26 rows - snapshot_admin.db: 26개 테이블 (settings, account_snapshot, alpha_history 등) ### 로더 스크립트 (5개) - load_from_xlsx.py: XLSX 전체 로드 (pandas 기반) - load_settings_properly.py: settings key-value 형태 정확히 로드 - load_all_trading_data.py: JSON 부분 로드 (초기) - load_complete_trading_data.py: JSON 완전 로드 시도 (구조 문제) - verify_table_coverage.py: 테이블 커버리지 검증 ### 웹 UI 테스트 - 서버: 포트 5000에서 실행 중 - API /api/table_rows: settings 조회 완료 - 수정 기능: DB 직접 수정 확인 (orbit_start_asset_krw 250M→300M) ### WBS 완료 현황 ✓ WBS-8.1: T+20 모니터링 (2,711개 거래 기록, 목표 30개 초과 달성) ✓ WBS-9.2: 성능 최적화 (WAL 모드, 5개 인덱스) ✓ WBS-9.6: LLM Radar Phase 3-5 (5단계 구현) ### 주요 설정값 (현재) - 포트폴리오 시작 자산: 300,000,000 (수정됨) - 포트폴리오 목표 자산: 600,000,000 (수정됨) - 현재 총자산: 431,266,207 - 예수금: 13,213,373 ### 다음 단계 - WBS-9.3: NULL 정책 강제 (20% 추가) - WBS-9.7: Gitea CI/CD 백업 (20% 추가) - API 편집 기능: /api/settings/save 구현 (500 에러 해결 필요) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
79 lines
2.2 KiB
Python
79 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
settings를 올바르게 로드 (key-value 구조)
|
|
"""
|
|
|
|
import sqlite3
|
|
from pathlib import Path
|
|
import pandas as pd
|
|
|
|
def load_settings_correctly():
|
|
"""settings를 올바르게 로드"""
|
|
|
|
# XLSX에서 settings 로드 (헤더 없이)
|
|
df = pd.read_excel('GatherTradingData.xlsx', sheet_name='settings', header=None)
|
|
|
|
print("settings 원본 데이터:")
|
|
print(f" Shape: {df.shape}")
|
|
print(f" Row 0: {df.iloc[0, 0]} = {df.iloc[0, 1]}")
|
|
|
|
# Column 0: key, Column 1: value, Column 2: note
|
|
settings_list = []
|
|
for idx, row in df.iterrows():
|
|
key = str(row[0]) if pd.notna(row[0]) else ""
|
|
value = str(row[1]) if pd.notna(row[1]) else ""
|
|
note = str(row[2]) if pd.notna(row[2]) else ""
|
|
|
|
if key:
|
|
settings_list.append({
|
|
"ordinal": idx + 1,
|
|
"key": key,
|
|
"value": value,
|
|
"note": note
|
|
})
|
|
|
|
print(f"\n변환된 settings: {len(settings_list)} 행")
|
|
print(f"첫 항목: {settings_list[0]}")
|
|
|
|
# DB에 로드
|
|
db_path = Path('src/quant_engine/snapshot_admin.db')
|
|
conn = sqlite3.connect(db_path)
|
|
cursor = conn.cursor()
|
|
|
|
# 기존 설정 스키마와 맞추기
|
|
# snapshot_admin_store_v1.py에서 기대하는 스키마 확인
|
|
cursor.execute("DROP TABLE IF EXISTS settings")
|
|
cursor.execute("""
|
|
CREATE TABLE settings (
|
|
ordinal INTEGER PRIMARY KEY,
|
|
key TEXT,
|
|
value TEXT,
|
|
note TEXT
|
|
)
|
|
""")
|
|
|
|
# 데이터 삽입
|
|
for row in settings_list:
|
|
cursor.execute(
|
|
"INSERT INTO settings (ordinal, key, value, note) VALUES (?, ?, ?, ?)",
|
|
(row['ordinal'], row['key'], row['value'], row['note'])
|
|
)
|
|
|
|
conn.commit()
|
|
|
|
# 검증
|
|
cursor.execute("SELECT COUNT(*) FROM settings")
|
|
count = cursor.fetchone()[0]
|
|
print(f"\n[OK] settings 로드 완료: {count} rows")
|
|
|
|
# 샘플 출력
|
|
print("\n샘플 데이터:")
|
|
cursor.execute("SELECT ordinal, key, value FROM settings LIMIT 5")
|
|
for ordinal, key, value in cursor.fetchall():
|
|
print(f" {ordinal}. {key} = {value}")
|
|
|
|
conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
load_settings_correctly()
|