chore: prices 날짜 범위 자동화
Some checks failed
Docker Build and Deploy / build-and-push (push) Failing after 1m6s
Docker Build and Deploy / deploy (push) Has been skipped

This commit is contained in:
Ayuriel 2025-04-09 22:23:04 +09:00
parent 26e77a23fb
commit ac87063d24

View File

@ -1,5 +1,5 @@
import time import time
from datetime import date from datetime import date, datetime, timedelta
from io import BytesIO from io import BytesIO
import pandas as pd import pandas as pd
@ -36,11 +36,21 @@ def process_for_price():
# 티커 선택 # 티커 선택
ticker = ticker_list['종목코드'][i] ticker = ticker_list['종목코드'][i]
# todo: 날짜 범위 수정 # 시작일(최근 저장 날짜 다음날)과 종료일(오늘)
# 시작일과 종료일 to = date.today().strftime("%Y%m%d")
# fr = (date.today() + relativedelta(years=-5)).strftime("%Y%m%d")
to = (date.today()).strftime("%Y%m%d") # 최근 날짜 조회
fr = '20250301' latest_date_query = "SELECT MAX(날짜) AS latest_date FROM kor_price WHERE 종목코드 = %s"
mycursor.execute(latest_date_query, (ticker,))
result = mycursor.fetchone()
if result[0] is not None:
# 최근 날짜가 있으면 그 다음날부터 조회
latest_date = result[0]
fr = (latest_date + timedelta(days=1)).strftime("%Y%m%d")
else:
# 데이터가 없으면 기본값 사용 (필요에 따라 조정)
fr = '20250328'
# 오류 발생 시 이를 무시하고 다음 루프로 진행 # 오류 발생 시 이를 무시하고 다음 루프로 진행
try: try: