您好,登錄后才能下訂單哦!
這篇文章主要介紹python如何實現股票歷史數據可視化示例,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
投資有風險,選擇需謹慎。 股票交易數據分析可直觀股市走向,對于如何把握股票行情,快速解讀股票交易數據有不可替代的作用!
import pandas as pd import csv
df = pd.read_csv("/home/kesci/input/maotai4154/maotai.csv")
df_high_low = df[['date','high','low']]
df_high_low_array = np.array(df_high_low) df_high_low_list =df_high_low_array.tolist()
price_dates, heigh_prices, low_prices = [], [], [] for content in zip(df_high_low_list): price_date = content[0][0] heigh_price = content[0][1] low_price = content[0][2] price_dates.append(price_date) heigh_prices.append(heigh_price) low_prices.append(low_price)
import pyecharts.options as opts from pyecharts.charts import Line
Line(init_opts=opts.InitOpts(width="1200px", height="600px"))
.add_yaxis( series_name="最低價", y_axis=low_prices, markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(value=-2, name="周最低", x=1, y=-1.5)] ), markline_opts=opts.MarkLineOpts( data=[ opts.MarkLineItem(type_="average", name="平均值"), opts.MarkLineItem(symbol="none", x="90%", y="max"), opts.MarkLineItem(symbol="circle", type_="max", name="最高點"), ] ), )
tooltip_opts=opts.TooltipOpts(trigger="axis"), toolbox_opts=opts.ToolboxOpts(is_show=True), xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=True)
.render("HTML名字填這里.html")
import pyecharts.options as opts from pyecharts.charts import Line ( Line(init_opts=opts.InitOpts(width="1200px", height="600px")) .add_xaxis(xaxis_data=price_dates) .add_yaxis( series_name="最高價", y_axis=heigh_prices, markpoint_opts=opts.MarkPointOpts( data=[ opts.MarkPointItem(type_="max", name="最大值"), opts.MarkPointItem(type_="min", name="最小值"), ] ), markline_opts=opts.MarkLineOpts( data=[opts.MarkLineItem(type_="average", name="平均值")] ), ) .add_yaxis( series_name="最低價", y_axis=low_prices, markpoint_opts=opts.MarkPointOpts( data=[opts.MarkPointItem(value=-2, name="周最低", x=1, y=-1.5)] ), markline_opts=opts.MarkLineOpts( data=[ opts.MarkLineItem(type_="average", name="平均值"), opts.MarkLineItem(symbol="none", x="90%", y="max"), opts.MarkLineItem(symbol="circle", type_="max", name="最高點"), ] ), ) .set_global_opts( title_opts=opts.TitleOpts(title="茅臺股票歷史數據可視化", subtitle="日期、最高價、最低價可視化"), tooltip_opts=opts.TooltipOpts(trigger="axis"), toolbox_opts=opts.ToolboxOpts(is_show=True), xaxis_opts=opts.AxisOpts(type_="category", boundary_gap=True), ) .render("everyDayPrice_change_line_chart2.html") )
以上是“python如何實現股票歷史數據可視化示例”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。