投資有風(fēng)險(xiǎn),選擇需謹(jǐn)慎。 股票交易數(shù)據(jù)分析可直觀股市走向,對(duì)于如何把握股票行情,快速解讀股票交易數(shù)據(jù)有不可替代的作用!
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="最低價(jià)", 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="最高點(diǎn)"), ] ), )
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="最高價(jià)", 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="最低價(jià)", 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="最高點(diǎn)"), ] ), ) .set_global_opts( title_opts=opts.TitleOpts(title="茅臺(tái)股票歷史數(shù)據(jù)可視化", subtitle="日期、最高價(jià)、最低價(jià)可視化"), 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") )
到此這篇關(guān)于python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例的文章就介紹到這了,更多相關(guān)python股票數(shù)據(jù)可視化內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
標(biāo)簽:撫州 揚(yáng)州 迪慶 牡丹江 楊凌 聊城 南寧 六盤(pán)水
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python實(shí)現(xiàn)股票歷史數(shù)據(jù)可視化分析案例》,本文關(guān)鍵詞 python,實(shí)現(xiàn),股票,歷史數(shù)據(jù),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。