daily_crawler.py
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import math
import pymysql
import datetime
from sqlalchemy import create_engine
import pandas as pd
from PyQt5.QtCore import *
import library.cf
pymysql.install_as_MySQLdb()
# -* daily_crawler *-
# 종목별 일자별 데이터를 저장하는 데이터베이스
class daily_crawler():
def __init__(self, db_name, daily_craw_db_name, daily_buy_list_db_name):
self.cf=library.cf
# db_name==0인 경우는 simulator
if db_name != 0:
self.db_name = db_name
self.daily_craw_db_name = daily_craw_db_name
self.daily_buy_list_db_name = daily_buy_list_db_name
self.engine = create_engine(
"mysql+pymysql://" + self.cf.db_id + ":" + self.cf.db_pw + "@" + self.cf.db_ip + ":" + self.cf.db_port + "/daily_craw",
encoding='utf-8')
self.daily_craw_db_con = self.engine.connect()
self.variable_setting()
else:
pass
# 업데이트가 금일 제대로 끝났는지 확인하는 함수
def variable_setting(self):
self.market_start_time = QTime(9, 0, 0) # 장 시작시간
self.market_end_time = QTime(15, 31, 0) # 장 마감시간
self.today = datetime.datetime.today().strftime("%Y%m%d")
self.today_detail = datetime.datetime.today().strftime("%Y%m%d%H%M")
# 현재 시간에 장이 열려있는지 확인하는 함수
def market_time_check(self):
self.current_time = QTime.currentTime()
if self.current_time > self.market_start_time and self.current_time < self.market_end_time:
return True
else:
return False