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)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/266317

相关文章

一文详解如何在Python中从字符串中提取部分内容

《一文详解如何在Python中从字符串中提取部分内容》:本文主要介绍如何在Python中从字符串中提取部分内容的相关资料,包括使用正则表达式、Pyparsing库、AST(抽象语法树)、字符串操作... 目录前言解决方案方法一:使用正则表达式方法二:使用 Pyparsing方法三:使用 AST方法四:使用字

Python列表去重的4种核心方法与实战指南详解

《Python列表去重的4种核心方法与实战指南详解》在Python开发中,处理列表数据时经常需要去除重复元素,本文将详细介绍4种最实用的列表去重方法,有需要的小伙伴可以根据自己的需要进行选择... 目录方法1:集合(set)去重法(最快速)方法2:顺序遍历法(保持顺序)方法3:副本删除法(原地修改)方法4:

Python运行中频繁出现Restart提示的解决办法

《Python运行中频繁出现Restart提示的解决办法》在编程的世界里,遇到各种奇怪的问题是家常便饭,但是,当你的Python程序在运行过程中频繁出现“Restart”提示时,这可能不仅仅是令人头疼... 目录问题描述代码示例无限循环递归调用内存泄漏解决方案1. 检查代码逻辑无限循环递归调用内存泄漏2.

Python中判断对象是否为空的方法

《Python中判断对象是否为空的方法》在Python开发中,判断对象是否为“空”是高频操作,但看似简单的需求却暗藏玄机,从None到空容器,从零值到自定义对象的“假值”状态,不同场景下的“空”需要精... 目录一、python中的“空”值体系二、精准判定方法对比三、常见误区解析四、进阶处理技巧五、性能优化

使用Python构建一个Hexo博客发布工具

《使用Python构建一个Hexo博客发布工具》虽然Hexo的命令行工具非常强大,但对于日常的博客撰写和发布过程,我总觉得缺少一个直观的图形界面来简化操作,下面我们就来看看如何使用Python构建一个... 目录引言Hexo博客系统简介设计需求技术选择代码实现主框架界面设计核心功能实现1. 发布文章2. 加

python logging模块详解及其日志定时清理方式

《pythonlogging模块详解及其日志定时清理方式》:本文主要介绍pythonlogging模块详解及其日志定时清理方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录python logging模块及日志定时清理1.创建logger对象2.logging.basicCo

Python如何自动生成环境依赖包requirements

《Python如何自动生成环境依赖包requirements》:本文主要介绍Python如何自动生成环境依赖包requirements问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录生成当前 python 环境 安装的所有依赖包1、命令2、常见问题只生成当前 项目 的所有依赖包1、

如何将Python彻底卸载的三种方法

《如何将Python彻底卸载的三种方法》通常我们在一些软件的使用上有碰壁,第一反应就是卸载重装,所以有小伙伴就问我Python怎么卸载才能彻底卸载干净,今天这篇文章,小编就来教大家如何彻底卸载Pyth... 目录软件卸载①方法:②方法:③方法:清理相关文件夹软件卸载①方法:首先,在安装python时,下

python uv包管理小结

《pythonuv包管理小结》uv是一个高性能的Python包管理工具,它不仅能够高效地处理包管理和依赖解析,还提供了对Python版本管理的支持,本文主要介绍了pythonuv包管理小结,具有一... 目录安装 uv使用 uv 管理 python 版本安装指定版本的 Python查看已安装的 Python

使用Python开发一个带EPUB转换功能的Markdown编辑器

《使用Python开发一个带EPUB转换功能的Markdown编辑器》Markdown因其简单易用和强大的格式支持,成为了写作者、开发者及内容创作者的首选格式,本文将通过Python开发一个Markd... 目录应用概览代码结构与核心组件1. 初始化与布局 (__init__)2. 工具栏 (setup_t