量化交易之vnpy篇 - 报表自动化 - outer api部分

class TQZAutoReport:

    __is_updating = False

    @classmethod
    def tqz_update(cls, settlement_jsonfile):
        """
        Create or Update today auto report.
        """

        if TQZAutoReport.__source_data_is_update(
                current_source_data_name=TQZAutoReportFilePath.current_source_data_excel_path()
        ) is False:
            print(f'auto-report today({TQZAutoReportFilePath.today_string()}) not update yet')
            cls.__tqz_update_today_auto_report(settlement_jsonfile=settlement_jsonfile)
        else:
            print(f'auto-report today({TQZAutoReportFilePath.today_string()}) is update all right')
            cls.__tqz_update_today_auto_report()


    # --- outer operation private part ---
    @classmethod
    def __current_source_data_dataframe(cls):
        """
        Get dataframe of current source data
        """

        data_frame = None
        if os.path.exists(TQZAutoReportFilePath.theory_source_data_excel_path()):
            data_frame = pandas.read_excel(TQZAutoReportFilePath.theory_source_data_excel_path(), sheet_name=TQZAutoReportSheetType.SOURCE_DATA.value)

        return data_frame

    @classmethod
    def __source_data_is_update(cls, current_source_data_name):
        """
        Judge source data of current day is update or not
        """

        target_string = TQZAutoReportFilePath.today_string()
        source_string = current_source_data_name

        ret = re.search(target_string, source_string)
        if ret:
            is_update = True
        else:
            is_update = False

        return is_update

    @classmethod
    def __tqz_update_today_auto_report(cls, settlement_jsonfile=None):
        """
        Update today auto report (Create today source data excel at first when settlement_jsonfile is not None)
        """

        if cls.__is_updating is True:
            return
        cls.__is_updating = True  # lock

        if settlement_jsonfile is not None:
            cls.__create_source_data_excel(settlement_jsonfile=settlement_jsonfile)

        cls.__update_per_account_data_excel()
        cls.__update_today_images()
        cls.__update_total_data_excel()
        if time.localtime().tm_wday is TQZWeekDayType.FRIDAY.value:
            cls.__update_weekly_pdfs(begin_weekday=TQZWeekDayType.FRIDAY.value)

        cls.__is_updating = False  # unlock

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值