def check_table(base_time, instrument, con, table_type): if table_type == "1m": base_time = base_time - timedelta(minutes=1) elif table_type == "5m": base_time = base_time - timedelta(minutes=5) elif table_type == "1h": base_time = base_time - timedelta(hours=1) elif table_type == "3h": base_time = base_time - timedelta(hours=3) elif table_type == "8h": base_time = base_time - timedelta(hours=8) elif table_type == "day": base_time = base_time - timedelta(days=1) season = decideSeason(base_time) if season == "winter": base_time = base_time.strftime("%Y-%m-%d 07:00:00") base_time = datetime.strptime(base_time, "%Y-%m-%d %H:%M:%S") else: base_time = base_time.strftime("%Y-%m-%d 06:00:00") base_time = datetime.strptime(base_time, "%Y-%m-%d %H:%M:%S") if decideMarket(base_time): sql = "select insert_time from %s_%s_TABLE where insert_time = \'%s\'" % (instrument, table_type, base_time) #print(sql) response = con.select_sql(sql) if len(response) == 0: print("below is *** ng *** %s" % sql) insert_table(base_time, instrument, con, table_type, count=1)
if table_mode == "8h": table_type = "8h" target_time = start_time - timedelta(hours=8) bulk_insert(target_time, end_time, instrument, con, table_type) if table_mode == "day": table_type = "day" target_time = start_time - timedelta(days=1) bulk_insert(target_time, end_time, instrument, con, table_type) elif mode == "production": count = 100 while True: try: term = decideSeason(base_time) now = datetime.now() weekday = base_time.weekday() hour = base_time.hour minutes = base_time.minute seconds = base_time.second return_time = None if base_time > now: time.sleep(1) else: if seconds % 5 == 0: if table_mode == "5s": table_type = "5s" target_time = base_time - timedelta(minutes=1) target_time = target_time.strftime( "%Y-%m-%d %H:%M:00")
property_path = current_path + "/property" from mysql_connector import MysqlConnector from price_obj import PriceObj from datetime import datetime, timedelta from common import decideMarket, account_init, iso_jp, jp_utc, decideSeason from get_indicator import getBollingerWrapper from send_mail import SendMail import time con = MysqlConnector() instrument = sys.argv[1] target_date = sys.argv[2] target_date = datetime.strptime("%s 06:00:00" % target_date, "%Y-%m-%d %H:%M:%S") season = decideSeason(target_date) if season == "summer": pass else: target_date = target_date + timedelta(hours=1) start_time = target_date - timedelta(days=5) end_time = target_date - timedelta(minutes=1) print("start_time = %s" % start_time) print("end_time = %s" % end_time) table_list = ["1m", "5m", "1h", "3h", "8h", "day"] master_count = [7200, 1440, 120, 40, 15, 5] message = ""