python 股票量化盘后分析系统(Beta v0.2)

2023-10-23 06:59

本文主要是介绍python 股票量化盘后分析系统(Beta v0.2),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前言:
感觉有点越弄越上头了,连续写了好几天,中间虽然有点累,但是感觉到了自己在一点一点进步,虽然不清楚能坚持到什么时候,走一步算一步。
这几天重新理了下框架,用tk.PanedWindow()函数对建立的root窗口进行了左右划分,然后对右边的图形功能内容进行了函数自定义,这样左边窗口的按钮对应了相应的功能显示,目前当你点击全景图功能按钮时会有点慢,原因估计数据太多处理有点慢,不清楚有什么办法可以处理得快点,以后再留意下方法。
还有变量名称的问题,越写到后面,代码的变量名称感觉都不知道怎么取名了,这次比上次的代码改动了不少变量名称。
重新对自己写的软件进行了功能定位:只涉及盘后的复盘分析,就不对盘中走势各种行情进行分析了,目前的知识水平也搞不了,代码如下:

import pandas as pd
import tushare as ts
import mplfinance as mpf
import tkinter as tk
import tkinter.tix as tix
from tkinter import ttk
import tkinter.font as tf
from tkinter.constants import *
import matplotlib.pyplot as plt
import matplotlib.dates as mdates  # 处理日期
from matplotlib.backends.backend_tkagg import (FigureCanvasTkAgg, NavigationToolbar2Tk)pro = ts.pro_api('要到tushare官网注册个账户然后将token复制到这里,可以的话请帮个忙用文章末我分享的链接注册,谢谢')
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
# pd.set_option()就是pycharm输出控制显示的设置
pd.set_option('expand_frame_repr', False)  # True就是可以换行显示。设置成False的时候不允许换行
pd.set_option('display.max_columns', None)  # 显示所有列
# pd.set_option('display.max_rows', None)  # 显示所有行
pd.set_option('colheader_justify', 'centre')  # 显示居中root = tk.Tk()  # 创建主窗口
screenWidth = root.winfo_screenwidth()  # 获取屏幕宽的分辨率
screenHeight = root.winfo_screenheight()
x, y = int(screenWidth / 4), int(screenHeight / 4)  # 初始运行窗口屏幕坐标(x, y),设置成在左上角显示
width = int(screenWidth / 2)  # 初始化窗口是显示器分辨率的二分之一
height = int(screenHeight / 2)
root.geometry('{}x{}+{}+{}'.format(width, height, x, y))  # 窗口的大小跟初始运行位置
root.title('Wilbur量化复盘分析软件')
# root.resizable(0, 0)  # 固定窗口宽跟高,不能调整大小,无法最大窗口化
root.iconbitmap('ZHY.ico')  # 窗口左上角图标设置,需要自己放张图标为icon格式的图片文件在项目文件目录下,不想设置就注释掉这句代码main_window = tk.PanedWindow(root)  # 设置窗口管理,将主窗口分成左右两部分
main_window.pack(fill='both', expand=1)main_frame = tk.Frame(main_window, width=screenWidth, height=screenHeight, relief=tk.SUNKEN, bg='#353535', bd=5,borderwidth=4)
main_window.pack(fill=BOTH, expand=1)
main_window.add(main_frame)  # 将功能主框架添加到左边窗口# 创建图形显示主框架
graphic_main_frame = tk.Frame(main_window, width=screenWidth, height=screenHeight, relief=tk.SUNKEN, bg='#353535',bd=5, borderwidth=4)
main_window.pack(fill=BOTH, expand=0)
main_window.add(graphic_main_frame)  # 将查询主框架添加到右边窗口def stockindex_function():# 必须添加以下控件销毁代码,不然点击一次按钮框架长生一次,显示的画面会多一次,你可以将下面的代码删除测试看下for widget_graphic_main_frame in graphic_main_frame.winfo_children():widget_graphic_main_frame.destroy()stockindex_window = tk.PanedWindow(graphic_main_frame, orient='vertical', opaqueresize=False)stockindex_window.pack(fill=BOTH)stockindex_sh_frame = tk.Frame(graphic_main_frame, width=screenWidth, height=screenHeight, relief=tk.SUNKEN,bg='#353535', bd=5, borderwidth=4)stockindex_sh_frame.pack(fill=BOTH)stockindex_window.add(stockindex_sh_frame, height=screenHeight/2)stockindex_sz_frame = tk.Frame(graphic_main_frame, width=screenWidth, height=screenHeight, relief=tk.SUNKEN,bg='#353535', bd=5, borderwidth=4)stockindex_sz_frame.pack(fill=BOTH)stockindex_window.add(stockindex_sz_frame)for widget_stockindex_sh_frame in stockindex_sh_frame.winfo_children():widget_stockindex_sh_frame.destroy()for widget_stockindex_sz_frame in stockindex_sz_frame.winfo_children():widget_stockindex_sz_frame.destroy()# 上证指数index_data_sh = pro.index_daily(ts_code='000001.SH', start_date=20100101)# 日数据处理# :取所有行数据,后面取date列,open列等数据index_data_sh = index_data_sh.loc[:, ['trade_date', 'open', 'close', 'high', 'low', 'vol']]index_data_sh = index_data_sh.rename(columns={'trade_date': 'Date', 'open': 'Open', 'close': 'Close','high': 'High', 'low': 'Low', 'vol': 'Volume'})  # 更换列名,为后面函数变量做准备index_data_sh.set_index('Date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。index_data_sh.index = pd.DatetimeIndex(index_data_sh.index)index_data_sh = index_data_sh.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列print(index_data_sh)index_sh_fig, axlist = mpf.plot(index_data_sh, type='candle', mav=(5, 10, 20), volume=True,show_nontrading=False, returnfig=True)canvas_index_sh = FigureCanvasTkAgg(index_sh_fig, master=stockindex_sh_frame)  # 设置tkinter绘制区canvas_index_sh.draw()toolbar_index_sh = NavigationToolbar2Tk(canvas_index_sh, stockindex_sh_frame)toolbar_index_sh.update()  # 显示图形导航工具条canvas_index_sh._tkcanvas.pack(fill=BOTH, expand=1)# 深圳指数index_data_sz = pro.index_daily(ts_code='399001.SZ', start_date=20100101)# 日数据处理# :取所有行数据,后面取date列,open列等数据index_data_sz = index_data_sz.loc[:, ['trade_date', 'open', 'close', 'high', 'low', 'vol']]index_data_sz = index_data_sz.rename(columns={'trade_date': 'Date', 'open': 'Open', 'close': 'Close','high': 'High', 'low': 'Low', 'vol': 'Volume'})  # 更换列名,为后面函数变量做准备index_data_sz.set_index('Date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。index_data_sz.index = pd.DatetimeIndex(index_data_sh.index)index_data_sz = index_data_sz.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列print(index_data_sz)index_sz_fig, axlist = mpf.plot(index_data_sz, type='candle', mav=(5, 10, 20), volume=True,show_nontrading=False, returnfig=True)canvas_index_sz = FigureCanvasTkAgg(index_sz_fig, master=stockindex_sz_frame)  # 设置tkinter绘制区canvas_index_sz.draw()toolbar_index_sz = NavigationToolbar2Tk(canvas_index_sz, stockindex_sz_frame)toolbar_index_sz.update()  # 显示图形导航工具条canvas_index_sz._tkcanvas.pack(fill=BOTH, expand=1)def stock_query_function():# 必须添加以下控件销毁代码,不然点击一次按钮框架长生一次,显示的画面会多一次,你可以将下面的代码删除测试看下for widget_graphic_main_frame in graphic_main_frame.winfo_children():widget_graphic_main_frame.destroy()# 在主框架下创建股票代码输入子框架code_frame = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535')code_frame.pack()# 创建标签‘股票代码’stock_label = tk.Label(code_frame, text='股票代码', bd=1)stock_label.pack(side=LEFT)# 创建股票代码输入框input_code_var = tk.StringVar()code_widget = tk.Entry(code_frame, textvariable=input_code_var, borderwidth=1, justify=CENTER)# input_code_get = input_code_var.set(input_code_var.get())  # 获取输入的新值code_widget.pack(side=LEFT, padx=4)# 在主框架下创建股票日期输入框子框架input_date_frame = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535')input_date_frame.pack()# 创建标签‘开始日期’date_start_label = tk.Label(input_date_frame, text='开始日期', bd=1)date_start_label.pack(side=LEFT)# 创建开始日期代码输入框input_startdate_var = tk.StringVar()startdate_widget = tk.Entry(input_date_frame, textvariable=input_startdate_var, borderwidth=1, justify=CENTER)input_startdate_get = input_startdate_var.set(input_startdate_var.get())  # 获取输入的新值startdate_widget.pack(side=LEFT, padx=4)# 创建标签‘结束日期’date_end_label = tk.Label(input_date_frame, text='结束日期', bd=1)date_end_label.pack(side=LEFT)# 创建结束日期代码输入框input_enddate_var = tk.StringVar()enddate_widget = tk.Entry(input_date_frame, textvariable=input_enddate_var, borderwidth=1, justify=CENTER)input_enddate_get = input_enddate_var.set(input_enddate_var.get())  # 获取输入的新值enddate_widget.pack(side=LEFT, padx=4)# 创建Notebook标签选项卡tabControl = ttk.Notebook(graphic_main_frame)stock_graphics_daily = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tk.RAISED)  # 增加新选项卡日K线图# stock_graphics_daily.pack(expand=1, fill=tk.BOTH, anchor=tk.CENTER)stock_graphics_daily_basic = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tk.RAISED)  # 增加新选项卡基本面指标stock_graphics_week = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tk.RAISED)stock_graphics_month = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tk.RAISED)company_information = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tk.RAISED)tabControl.add(stock_graphics_daily, text='日K线图')  # 把新选项卡日K线框架增加到NotebooktabControl.add(stock_graphics_daily_basic, text='基本面指标')tabControl.add(stock_graphics_week, text='周K线图')tabControl.add(stock_graphics_month, text='月K线图')tabControl.add(company_information, text='公司信息')tabControl.pack(expand=1, fill="both")  # 设置选项卡布局tabControl.select(stock_graphics_daily)  # 默认选定日K线图开始def go():   # 图形输出渲染# 以下函数作用是省略输入代码后缀.sz .shdef code_name_transform(get_stockcode):  # 输入的数字股票代码转换成字符串股票代码str_stockcode = str(get_stockcode)str_stockcode = str_stockcode.strip()  # 删除前后空格字符if 6 > len(str_stockcode) > 0:str_stockcode = str_stockcode.zfill(6) + '.SZ'  # zfill()函数返回指定长度的字符串,原字符串右对齐,前面填充0if len(str_stockcode) == 6:if str_stockcode[0:1] == '0':str_stockcode = str_stockcode + '.SZ'if str_stockcode[0:1] == '3':str_stockcode = str_stockcode + '.SZ'if str_stockcode[0:1] == '6':str_stockcode = str_stockcode + '.SH'return str_stockcode# 清除stock_graphics_daily框架中的控件内容,winfo_children()返回的项是一个小部件列表,# 以下代码作用是为每次点击查询按钮时更新图表内容,如果没有以下代码句,则每次点击查询会再生成一个图表for widget_daily in stock_graphics_daily.winfo_children():widget_daily.destroy()for widget_daily_basic in stock_graphics_daily_basic.winfo_children():widget_daily_basic.destroy()for widget_week in stock_graphics_week.winfo_children():widget_week.destroy()for widget_month in stock_graphics_month.winfo_children():widget_month.destroy()for widget_company_information in company_information.winfo_children():widget_company_information.destroy()# 获取用户输入信息stock_name = input_code_var.get()code_name = code_name_transform(stock_name)start_date = input_startdate_var.get()end_date = input_enddate_var.get()# 获取股票数据stock_data = pro.daily(ts_code=code_name, start_date=start_date, end_date=end_date)stock_daily_basic = pro.daily_basic(ts_code=code_name, start_date=start_date, end_date=end_date,fields='close,trade_date,turnover_rate,volume_ratio,pe,pb')stock_week_data = pro.weekly(ts_code=code_name, start_date=start_date, end_date=end_date)stock_month_data = pro.monthly(ts_code=code_name, start_date=start_date, end_date=end_date)stock_name_change = pro.namechange(ts_code=code_name, fields='ts_code,name')stock_information = pro.stock_company(ts_code=code_name, fields='introduction,main_business,business_scope')# 日数据处理data = stock_data.loc[:, ['trade_date', 'open', 'close', 'high', 'low', 'vol']]  # :取所有行数据,后面取date列,open列等数据data = data.rename(columns={'trade_date': 'Date', 'open': 'Open', 'close': 'Close', 'high': 'High', 'low': 'Low','vol': 'Volume'})  # 更换列名,为后面函数变量做准备data.set_index('Date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。data.index = pd.DatetimeIndex(data.index)data = data.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列# 基本面指标数据处理stock_daily_basic.set_index('trade_date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。stock_daily_basic.index = pd.DatetimeIndex(stock_daily_basic.index)stock_daily_basic = stock_daily_basic.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列print(stock_daily_basic)# 周数据处理week_data = stock_week_data.loc[:, ['trade_date', 'open', 'close', 'high', 'low', 'vol']]week_data = week_data.rename(columns={'trade_date': 'Date', 'open': 'Open', 'close': 'Close', 'high': 'High','low': 'Low', 'vol': 'Volume'})  # 更换列名,为后面函数变量做准备week_data.set_index('Date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。week_data.index = pd.DatetimeIndex(week_data.index)week_data = week_data.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列# 月数据处理month_data = stock_month_data.loc[:, ['trade_date', 'open', 'close', 'high', 'low', 'vol']]month_data = month_data.rename(columns={'trade_date': 'Date', 'open': 'Open', 'close': 'Close', 'high': 'High','low': 'Low', 'vol': 'Volume'})  # 更换列名,为后面函数变量做准备month_data.set_index('Date', inplace=True)  # 设置date列为索引,覆盖原来索引,这个时候索引还是 object 类型,就是字符串类型。# 将object类型转化成 DateIndex 类型,pd.DatetimeIndex 是把某一列进行转换,同时把该列的数据设置为索引 index。month_data.index = pd.DatetimeIndex(month_data.index)month_data = month_data.sort_index(ascending=True)  # 将时间顺序升序,符合时间序列# 公司信息处理stock_company_code = stock_name_change.at[0, 'ts_code']stock_company_name = stock_name_change.at[0, 'name']stock_introduction = stock_information.at[0, 'introduction']stock_main_business = stock_information.at[0, 'main_business']stock_business_scope = stock_information.at[0, 'business_scope']# K线图图形输出daily_fig, axlist = mpf.plot(data, type='candle', mav=(5, 10, 20), volume=True,show_nontrading=False, returnfig=True)# 基本面指标图形输出# 注意必须按照选项卡的排列顺序渲染图形输出,假如你把matplotlib的图形放到最后,则会出现图像错位现象,不信你可以把以下的代码放到month_fig后试下plt_stock_daily_basic = plt.figure(facecolor='white')plt.suptitle('Daily Basic Indicator', size=10)fig_close = plt.subplot2grid((3, 2), (0, 0), colspan=2)  # 创建网格子绘图,按行切分成3份,列切分成2分,位置(0,0),横向占用2列fig_close.set_title('Close Price')plt.xticks(stock_daily_basic.index, rotation=45)  # 设置x轴时间显示方向,放在这跟放在最后显示效果不一样fig_close.plot(stock_daily_basic.index, stock_daily_basic['close'])plt.xlabel('Trade Day')plt.ylabel('Close')plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))  # 设置X轴主刻度显示的格式plt.gca().xaxis.set_major_locator(mdates.MonthLocator(interval=1))  # 设置X轴主刻度的间距fig_turnover_rate = plt.subplot2grid((3, 2), (1, 0))  # 创建网格子绘图,按行切分成3份,列切分成2分,位置(1,0)fig_turnover_rate.set_title('Turnover Rate')plt.xticks(stock_daily_basic.index, rotation=45)  # 设置x轴时间显示方向,放在这跟放在最后显示效果不一样fig_turnover_rate.bar(stock_daily_basic.index, stock_daily_basic['turnover_rate'], facecolor='red')plt.xlabel('Trade Day')plt.ylabel('Turnover Rate')plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m'))  # 设置X轴主刻度显示的格式plt.gca().xaxis.set_major_locator(mdates.MonthLocator(interval=2))  # 设置X轴主刻度的间距fig_volume_ratio = plt.subplot2grid((3, 2), (2, 0))  # 创建网格子绘图,按行切分成3份,列切分成2分,位置(1,2)fig_volume_ratio.set_title('Volume Ratio')plt.xticks(stock_daily_basic.index, rotation=45)  # 设置x轴时间显示方向,放在这跟放在最后显示效果不一样fig_volume_ratio.bar(stock_daily_basic.index, stock_daily_basic['volume_ratio'])plt.xlabel('Trade Day')plt.ylabel('Volume Ratio')plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m'))  # 设置X轴主刻度显示的格式plt.gca().xaxis.set_major_locator(mdates.MonthLocator(interval=2))  # 设置X轴主刻度的间距fig_pe = plt.subplot2grid((3, 2), (1, 1))  # 创建网格子绘图,按行切分成3份,列切分成2分,位置在第3行,第1列fig_pe.set_title('PE')plt.xticks(stock_daily_basic.index, rotation=45)  # 设置x轴时间显示方向,放在这跟放在最后显示效果不一样fig_pe.plot(stock_daily_basic.index, stock_daily_basic['pe'])plt.xlabel('Trade Day')plt.ylabel('PE')plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m'))  # 设置X轴主刻度显示的格式plt.gca().xaxis.set_major_locator(mdates.MonthLocator(interval=2))  # 设置X轴主刻度的间距fig_pb = plt.subplot2grid((3, 2), (2, 1))  # 创建网格子绘图,按行切分成3份,列切分成2分,位置在第3行,第2列fig_pb.set_title('PB')plt.xticks(stock_daily_basic.index, rotation=45)  # 设置x轴时间显示方向,放在这跟放在最后显示效果不一样fig_pb.plot(stock_daily_basic.index, stock_daily_basic['pb'])plt.xlabel('Trade Day')plt.ylabel('PB')plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m'))  # 设置X轴主刻度显示的格式plt.gca().xaxis.set_major_locator(mdates.MonthLocator(interval=2))  # 设置X轴主刻度的间距plt_stock_daily_basic.tight_layout(h_pad=-2, w_pad=0)  # 解决子图图形重叠问题# 周K线图形输出week_fig, axlist = mpf.plot(week_data, type='candle', mav=(5, 10, 20), volume=True,show_nontrading=False, returnfig=True)# 月k线图形输出month_fig, axlist = mpf.plot(month_data, type='candle', mav=(5, 10, 20), volume=True,show_nontrading=False, returnfig=True)# 将获得的图形渲染到画布上# 日K线图形渲染到tkinter画布上canvas_daily = FigureCanvasTkAgg(daily_fig, master=stock_graphics_daily)  # 设置tkinter绘制区canvas_daily.draw()toolbar_daily = NavigationToolbar2Tk(canvas_daily, stock_graphics_daily)toolbar_daily.update()  # 显示图形导航工具条canvas_daily._tkcanvas.pack(side=BOTTOM, fill=BOTH, expand=1)# 基本面指标图形渲染到tkinter画布上canvas_stock_daily_basic = FigureCanvasTkAgg(plt_stock_daily_basic, master=stock_graphics_daily_basic)canvas_stock_daily_basic.draw()toolbar_stock_daily_basic = NavigationToolbar2Tk(canvas_stock_daily_basic, stock_graphics_daily_basic)toolbar_stock_daily_basic.update()  # 显示图形导航工具条canvas_stock_daily_basic._tkcanvas.pack(side=BOTTOM, fill=BOTH, expand=1)plt.close()# 周K线图形渲染到tkinter画布上canvas_week = FigureCanvasTkAgg(week_fig, master=stock_graphics_week)  # 设置tkinter绘制区canvas_week.draw()toolbar_week = NavigationToolbar2Tk(canvas_week, stock_graphics_week)toolbar_week.update()  # 显示图形导航工具条canvas_week._tkcanvas.pack(side=BOTTOM, fill=BOTH, expand=1)# 月K线图形渲染到tkinter画布上canvas_month = FigureCanvasTkAgg(month_fig, master=stock_graphics_month)  # 设置tkinter绘制区canvas_month.draw()toolbar_month = NavigationToolbar2Tk(canvas_month, stock_graphics_month)toolbar_month.update()  # 显示图形导航工具条canvas_month._tkcanvas.pack(side=BOTTOM, fill=BOTH, expand=1)# 在company_information框架下设置文字选项卡功能内容company_text = tk.Text(company_information, bg='white', undo=True, wrap=tix.CHAR)# 在文本框第一行添加股票代码,文字红色,居中显示company_text.insert(tk.INSERT, stock_company_code)company_text.tag_add('tag1', '1.0', '1.9')  # 设置选定的内容,company_text.tag_config('tag1', foreground='red', justify=CENTER)company_text.insert(tk.INSERT, '\n')company_text.insert(tk.INSERT, stock_company_name)company_text.tag_add('tag2', '2.0', '2.9')company_text.tag_config('tag2', foreground='red', justify=CENTER)company_text.insert(tk.INSERT, '\n')company_text.insert(tk.INSERT, '    ')company_text.insert(tk.INSERT, '公司简介:')company_text.tag_add('tag3', '3.3', '3.9')company_text.tag_config('tag3', foreground='red', font=tf.Font(family='SimHei', size=12))company_text.insert(tk.INSERT, stock_introduction)company_text.tag_add('tag4', '3.9', 'end')company_text.tag_config('tag4', foreground='black', spacing1=20, spacing2=10,font=tf.Font(family='SimHei', size=12))company_text.insert(tk.INSERT, '\n')company_text.insert(tk.INSERT, '    ')company_text.insert(tk.INSERT, '主要业务及产品:')company_text.tag_add('tag5', '4.4', '4.12')company_text.tag_config('tag5', foreground='blue')company_text.insert(tk.INSERT, stock_main_business)company_text.tag_add('tag6', '4.12', 'end')company_text.tag_config('tag6', spacing1=20, spacing2=10,font=tf.Font(family='SimHei', size=12))company_text.insert(tk.INSERT, '\n')company_text.insert(tk.INSERT, '    ')company_text.insert(tk.INSERT, '经营范围:')company_text.tag_add('tag7', '5.4', '5.9')company_text.tag_config('tag7', foreground='#cc6600')company_text.insert(tk.INSERT, stock_business_scope)company_text.tag_add('tag8', '5.9', 'end')company_text.tag_config('tag8', spacing1=20, spacing2=10,font=tf.Font(family='SimHei', size=12))company_text.insert(tk.INSERT, '\n')company_text.pack(fill=BOTH, expand=1)# 在主框架下创建查询按钮子框架search_frame = tk.Frame(graphic_main_frame, borderwidth=1, bg='#353535', relief=tix.SUNKEN)search_frame.pack(before=tabControl)  # 必须加上before,否则控件则会出现在底部,除非tabControl设置了bottom布局属性# 创建查询按钮并设置功能stock_find = tk.Button(search_frame, text='查询', width=5, height=1, command=go)stock_find.pack()stockIndex_label_button = tk.Button(main_frame, text='全景指数', command=stockindex_function)
stockIndex_label_button.pack(fill=X)
query_label_button = tk.Button(main_frame, text='查询', command=stock_query_function)
query_label_button.pack(fill=X)root.mainloop()

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
tushare注册链接:LINK

这篇关于python 股票量化盘后分析系统(Beta v0.2)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:https://blog.csdn.net/Wilburzzz/article/details/109210908
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/266317

相关文章

Python通用唯一标识符模块uuid使用案例详解

《Python通用唯一标识符模块uuid使用案例详解》Pythonuuid模块用于生成128位全局唯一标识符,支持UUID1-5版本,适用于分布式系统、数据库主键等场景,需注意隐私、碰撞概率及存储优... 目录简介核心功能1. UUID版本2. UUID属性3. 命名空间使用场景1. 生成唯一标识符2. 数

Linux系统性能检测命令详解

《Linux系统性能检测命令详解》本文介绍了Linux系统常用的监控命令(如top、vmstat、iostat、htop等)及其参数功能,涵盖进程状态、内存使用、磁盘I/O、系统负载等多维度资源监控,... 目录toppsuptimevmstatIOStatiotopslabtophtopdstatnmon

Python办公自动化实战之打造智能邮件发送工具

《Python办公自动化实战之打造智能邮件发送工具》在数字化办公场景中,邮件自动化是提升工作效率的关键技能,本文将演示如何使用Python的smtplib和email库构建一个支持图文混排,多附件,多... 目录前言一、基础配置:搭建邮件发送框架1.1 邮箱服务准备1.2 核心库导入1.3 基础发送函数二、

Android kotlin中 Channel 和 Flow 的区别和选择使用场景分析

《Androidkotlin中Channel和Flow的区别和选择使用场景分析》Kotlin协程中,Flow是冷数据流,按需触发,适合响应式数据处理;Channel是热数据流,持续发送,支持... 目录一、基本概念界定FlowChannel二、核心特性对比数据生产触发条件生产与消费的关系背压处理机制生命周期

Python包管理工具pip的升级指南

《Python包管理工具pip的升级指南》本文全面探讨Python包管理工具pip的升级策略,从基础升级方法到高级技巧,涵盖不同操作系统环境下的最佳实践,我们将深入分析pip的工作原理,介绍多种升级方... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核

基于Python实现一个图片拆分工具

《基于Python实现一个图片拆分工具》这篇文章主要为大家详细介绍了如何基于Python实现一个图片拆分工具,可以根据需要的行数和列数进行拆分,感兴趣的小伙伴可以跟随小编一起学习一下... 简单介绍先自己选择输入的图片,默认是输出到项目文件夹中,可以自己选择其他的文件夹,选择需要拆分的行数和列数,可以通过

Python中反转字符串的常见方法小结

《Python中反转字符串的常见方法小结》在Python中,字符串对象没有内置的反转方法,然而,在实际开发中,我们经常会遇到需要反转字符串的场景,比如处理回文字符串、文本加密等,因此,掌握如何在Pyt... 目录python中反转字符串的方法技术背景实现步骤1. 使用切片2. 使用 reversed() 函

Python中将嵌套列表扁平化的多种实现方法

《Python中将嵌套列表扁平化的多种实现方法》在Python编程中,我们常常会遇到需要将嵌套列表(即列表中包含列表)转换为一个一维的扁平列表的需求,本文将给大家介绍了多种实现这一目标的方法,需要的朋... 目录python中将嵌套列表扁平化的方法技术背景实现步骤1. 使用嵌套列表推导式2. 使用itert

使用Docker构建Python Flask程序的详细教程

《使用Docker构建PythonFlask程序的详细教程》在当今的软件开发领域,容器化技术正变得越来越流行,而Docker无疑是其中的佼佼者,本文我们就来聊聊如何使用Docker构建一个简单的Py... 目录引言一、准备工作二、创建 Flask 应用程序三、创建 dockerfile四、构建 Docker

Python使用vllm处理多模态数据的预处理技巧

《Python使用vllm处理多模态数据的预处理技巧》本文深入探讨了在Python环境下使用vLLM处理多模态数据的预处理技巧,我们将从基础概念出发,详细讲解文本、图像、音频等多模态数据的预处理方法,... 目录1. 背景介绍1.1 目的和范围1.2 预期读者1.3 文档结构概述1.4 术语表1.4.1 核