コード例 #1
0
def start():
    start_date = datetime.datetime(2015, 1, 1)
    end_date = datetime.datetime(2021, 12, 31)

    date_range = get_date_range(start_date, end_date)

    delete_old_data()

    for date in date_range:
        is_workday_flag = True if datetime.datetime.isoweekday(date) <= 5 and date not in holiday_manual else False
        insert_new_data(date, is_workday_flag)
コード例 #2
0
    delete from future_holding_data where trade_date=:data_date
    """
    args = {"data_date": data_date}
    update_data(sql, args)


def start(date_now=None):
    date_now = datetime.datetime.now() if date_now is None else date_now
    date_now = datetime.datetime(date_now.year, date_now.month, date_now.day)

    if Date().is_workday(date_now):
        delete_future_holding_data(date_now)
        for exchange in FUTURE_EXCHANGE_CODE_LIST:
            try:
                future_holding_data = get_future_holding_data(
                    convert_datetime_to_str(date_now), exchange)
                store_future_holding_data(future_holding_data)
            except Exception as e:
                store_failed_message("", "future_main_holding_data", str(e),
                                     date_now)


if __name__ == "__main__":
    for date_now in get_date_range(datetime.datetime(2015, 1, 1),
                                   datetime.datetime(2021, 6, 18)):
        print(date_now)
        start(date_now)
    # start(datetime.datetime(2020, 5, 19))
    # all_future_daily_point_data = pro.daily(trade_date="20181008")
    pass
コード例 #3
0

def store_security_daily_basic(security_daily_basic_data):
    security_daily_basic_data["update_date"] = datetime.datetime.now()
    security_daily_basic_data["trade_date"] = security_daily_basic_data["trade_date"].apply(convert_str_to_datetime)
    security_daily_basic_data["turnover_rate"] = security_daily_basic_data["turnover_rate"].apply(lambda x: x / 100)
    security_daily_basic_data["turnover_rate_f"] = security_daily_basic_data["turnover_rate_f"].apply(lambda x: x / 100 if x else x)

    security_daily_basic_data.to_sql("security_daily_basic", engine, index=False, if_exists="append")


def start(date_now=None):
    date_now = datetime.datetime.now() if date_now is None else date_now
    date_now = datetime.datetime(date_now.year, date_now.month, date_now.day)

    if Date().is_workday(date_now):
        try:
            all_security_daily_basic = get_all_security_daily_basic(convert_datetime_to_str(date_now))
            store_security_daily_basic(all_security_daily_basic)
        except Exception as e:
            store_failed_message("", "security_daily_basic_data", str(e), date_now)


if __name__ == "__main__":
    for date_now in get_date_range(datetime.datetime(2018, 12, 14), datetime.datetime(2021, 6, 18)):
        print(date_now)
        start(date_now)
    # start(datetime.datetime(2020, 5, 19))
    # all_future_daily_point_data = pro.daily(trade_date="20181008")
    pass
コード例 #4
0
        lambda x: x / 100)

    security_point_data.to_sql("security_point_data",
                               engine,
                               index=False,
                               if_exists="append")


def start(date_now=None):
    date_now = datetime.datetime.now() if date_now is None else date_now
    date_now = datetime.datetime(date_now.year, date_now.month, date_now.day)

    if Date().is_workday(date_now):
        try:
            all_security_point_data = get_all_security_point_data(
                convert_datetime_to_str(date_now))
            store_security_point_data(all_security_point_data)
        except Exception as e:
            store_failed_message("", "security_point_data", str(e), date_now)


if __name__ == "__main__":
    for date_now in get_date_range(datetime.datetime(2021, 5, 19),
                                   datetime.datetime(2021, 6, 18)):
        print(date_now)
        start(date_now)

    # start(datetime.datetime(2020, 5, 19))
    # all_future_daily_point_data = pro.daily(trade_date="20181008")
    pass