chore: prices 날짜 범위 자동화
This commit is contained in:
parent
26e77a23fb
commit
ac87063d24
@ -1,5 +1,5 @@
|
||||
import time
|
||||
from datetime import date
|
||||
from datetime import date, datetime, timedelta
|
||||
from io import BytesIO
|
||||
|
||||
import pandas as pd
|
||||
@ -36,11 +36,21 @@ def process_for_price():
|
||||
# 티커 선택
|
||||
ticker = ticker_list['종목코드'][i]
|
||||
|
||||
# todo: 날짜 범위 수정
|
||||
# 시작일과 종료일
|
||||
# fr = (date.today() + relativedelta(years=-5)).strftime("%Y%m%d")
|
||||
to = (date.today()).strftime("%Y%m%d")
|
||||
fr = '20250301'
|
||||
# 시작일(최근 저장 날짜 다음날)과 종료일(오늘)
|
||||
to = date.today().strftime("%Y%m%d")
|
||||
|
||||
# 최근 날짜 조회
|
||||
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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user