def gen_pdf(stk_list_): for stk_ in stk_list_: # 将选定的股票的走势图打印到本地 gen_stk_sea_select_pic(stk_) print('开始生成pdf...') # 生成pdf c_ = canvas.Canvas(U"魔灯海选" + get_current_date_str() + ".pdf", pagesize=letter) c_ = add_front(c_, '魔灯每日股票海选结果' + get_current_date_str(), '本文档由免费开源的量化投资软件“魔灯”自动生成 末尾公众号内有软件介绍', pagesize=letter) for stk_ in stk_list_: c_ = print_k_to_pdf(c_, stk_, get_current_date_str()) c_ = add_tail_page(c_) c_.save()
# c = add_front(c, '魔灯每日股票海选结果' + get_current_date_str(), '本文档由免费开源的量化投资软件“魔灯”自动生成 末尾公众号内有软件介绍', pagesize=letter) # for stk in stk_list: # c = print_k_to_pdf(c, stk, get_current_date_str()) # c = add_tail_page(c) # c.save() if __name__ == '__main__': stk_list = ['300495', '000504', '002016', '000503', '603012', '300143'] for stk in stk_list: # 将选定的股票的走势图打印到本地 gen_stk_sea_select_pic(stk) print('开始生成pdf...') # 生成pdf c = canvas.Canvas(U"魔灯海选" + get_current_date_str() + ".pdf", pagesize=letter) c = add_front(c, '魔灯每日股票海选结果' + get_current_date_str(), '本文档由免费开源的量化投资软件“魔灯”自动生成 末尾公众号内有软件介绍', pagesize=letter) for stk in stk_list: c = print_k_to_pdf(c, stk, get_current_date_str()) c = add_tail_page(c) c.save() df = ts.get_stock_basics() end = 0
# encoding = utf-8 import PIL from reportlab.lib.pagesizes import letter from reportlab.lib.utils import ImageReader from reportlab.pdfgen import canvas from DataSource.Code2Name import code2name from Function.SeaSelect.Sub.reportlab_sub import print_k_to_pdf, add_front, add_tail_page from Function.SeaSelect.gen_pic import stk_code from Global_Value.file_dir import sea_select_pic_dir from SDK.MyTimeOPT import get_current_date_str from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics pdfmetrics.registerFont(TTFont('song', 'SURSONG.TTF')) pdfmetrics.registerFont(TTFont('hei', 'SIMHEI.TTF')) from reportlab.lib import fonts fonts.addMapping('song', 0, 0, 'song') fonts.addMapping('song', 0, 1, 'song') fonts.addMapping('song', 1, 0, 'hei') fonts.addMapping('song', 1, 1, 'hei') date = '2019-12-28' if __name__ == '__main__': c = canvas.Canvas(U"魔灯海选" + get_current_date_str() + ".pdf", pagesize=letter) c = add_front(c, '魔灯每日股票海选结果' + get_current_date_str(), '本文档由免费开源的量化投资软件“魔灯”自动生成 末尾公众号内有软件介绍', pagesize=letter) c = print_k_to_pdf(c, stk_code, date) c = add_tail_page(c) c.save()