Spaces:
Running
Running
Commit ·
046fcfe
1
Parent(s): 69caad1
변경 사항을 요약할 수 있도록 `app.py` 파일의 변경 내용(diff)을 제공해 주세요.
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import yfinance as yf
|
|
| 9 |
import pandas as pd
|
| 10 |
import numpy as np
|
| 11 |
from datetime import datetime, timedelta
|
|
|
|
| 12 |
from datasets import Dataset
|
| 13 |
from huggingface_hub import HfApi
|
| 14 |
import os
|
|
@@ -93,6 +94,26 @@ def fetch_ticker_data(ticker, max_retries=3):
|
|
| 93 |
if col in hist.columns:
|
| 94 |
hist[col] = hist[col].round(4)
|
| 95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
return hist
|
| 97 |
|
| 98 |
except Exception as e:
|
|
|
|
| 9 |
import pandas as pd
|
| 10 |
import numpy as np
|
| 11 |
from datetime import datetime, timedelta
|
| 12 |
+
from zoneinfo import ZoneInfo
|
| 13 |
from datasets import Dataset
|
| 14 |
from huggingface_hub import HfApi
|
| 15 |
import os
|
|
|
|
| 94 |
if col in hist.columns:
|
| 95 |
hist[col] = hist[col].round(4)
|
| 96 |
|
| 97 |
+
# --- 장중 데이터(미확정 종가) 제외 로직 ---
|
| 98 |
+
# zoneinfo는 Python 내장이라 별도 설치 불필요, 썸머타임(EDT/EST) 자동 처리
|
| 99 |
+
ny_tz = ZoneInfo("America/New_York")
|
| 100 |
+
now_ny = datetime.now(ny_tz)
|
| 101 |
+
today_ny = now_ny.strftime("%Y-%m-%d")
|
| 102 |
+
|
| 103 |
+
# 정규장 마감: 뉴욕 현지 시간 16:00 (썸머타임이든 아니든 동일)
|
| 104 |
+
# 여유를 두고 16:30 이후면 종가 확정으로 판단
|
| 105 |
+
market_closed = now_ny.hour >= 17 or (now_ny.hour == 16 and now_ny.minute >= 30)
|
| 106 |
+
|
| 107 |
+
if not hist.empty and hist.iloc[-1]["Date"] == today_ny:
|
| 108 |
+
if not market_closed:
|
| 109 |
+
# 아직 장중이거나 마감 직후 → 오늘 데이터 제외 (종가 미확정)
|
| 110 |
+
logger.info(f"[{ticker}] 장중 데이터({today_ny}) 제외 (현재 뉴욕시간: {now_ny.strftime('%H:%M')})")
|
| 111 |
+
hist = hist.iloc[:-1]
|
| 112 |
+
else:
|
| 113 |
+
# 장 마감 후 → 오늘 종가 확정, 포함
|
| 114 |
+
logger.info(f"[{ticker}] 장 마감 후 데이터({today_ny}) 포함")
|
| 115 |
+
# -----------------------------------------------
|
| 116 |
+
|
| 117 |
return hist
|
| 118 |
|
| 119 |
except Exception as e:
|