메뉴 여닫기
개인 메뉴 토글
로그인하지 않음
만약 지금 편집한다면 당신의 IP 주소가 공개될 수 있습니다.

주식 rsi

DB CAFE
Dbcafe (토론 | 기여)님의 2024년 10월 2일 (수) 00:36 판 (새 문서: <source lang=python> import dbcon import pymysql import datetime import UTIL_SLACK_CALL db = dbcon.conn() cursor = db.cursor(pymysql.cursors.DictCursor) def selectStockList(cursor): selectSql = "select ifnull(date_format(date_add(max(sr.date),interval +1 day),'%Y%m%d') "\ " , date_format(date_add(curdate( ),interval -850 day),'%Y%m%d'))as start_date "\ " ,date_format((SELECT MAX(DATE) FROM tb_stock_daily_i...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
import dbcon
import pymysql
import datetime
import UTIL_SLACK_CALL

db = dbcon.conn()
cursor = db.cursor(pymysql.cursors.DictCursor)


def selectStockList(cursor):
    selectSql = "select ifnull(date_format(date_add(max(sr.date),interval +1 day),'%Y%m%d')                  "\
                "               , date_format(date_add(curdate( ),interval -850 day),'%Y%m%d'))as start_date "\
                "    	,date_format((SELECT MAX(DATE) FROM tb_stock_daily_info), '%Y%m%d') as end_date    "\
                "  from tb_stock_daily_result sr                                                             "

    cursor.execute(selectSql)
    result = cursor.fetchall()
    return result

#time.sleep(3600)
if __name__ == "__main__":

    for vStockList in selectStockList(cursor):
        now = datetime.datetime.now()
        if vStockList['start_date'] <= vStockList['end_date']:

            #입력파라미터 : 시작일자, 종료일자, 엔벨로퍼%(0.2 => 20%)
            cursor.callproc("sp_stock_daily_result", (vStockList['start_date'], vStockList['end_date'], 0.2));
            print(vStockList['start_date'], vStockList['end_date'])

    dbcon.close(db)


UTIL_SLACK_CALL.send_slack("STEP_03 - Finish .. Stock_Daily_Result");