1 Star 0 Fork 1

镜花/ministock

forked from 盘丝/ministock 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
minianalysis.py 2.02 KB
一键复制 编辑 原始数据 按行查看 历史
盘丝 提交于 2021-07-23 12:15 . 数据可视化分析
from minifun import *
from pyecharts import options as opts
from pyecharts.charts import Parallel
bankuai_dic = {}
stock_df = get_block_list(bk='BK0448', pz=200)
stock_df['上市日期'] = pd.to_datetime(stock_df['上市日期'], format='%Y%m%d')
stock_df = stock_df[stock_df['上市日期'] < '2021-01-01']
stock_ls = list(stock_df['代码'])
season_pc = []
ns_pc = []
for sc in stock_ls:
sk = get_stock_kline(sc, 'S')
pcls = sk['涨幅'].to_list()
season_pc.append(pcls[-2])
ns_pc.append(pcls[-1])
stock_df['季涨幅'] = season_pc
stock_df['最新季涨幅'] = ns_pc
s_dff = stock_df[['流通市值', '毛利率', 'ROE', '季涨幅', 'pe', '最新季涨幅']]
s_dff = s_dff[s_dff['ROE']!='-']
s_dff = s_dff[s_dff['流通市值'] < 400]
s_dff = s_dff[s_dff['ROE'] > -3]
s_dff = s_dff[s_dff['pe'] > -100]
c1 = s_dff['季涨幅'] >= 10
c2 = s_dff['季涨幅'] >= 0
c3 = s_dff['季涨幅'] < 0
c4 = s_dff['季涨幅'] < -10
s1 = s_dff[c1]
s2 = s_dff[~c1 & c2]
s3 = s_dff[c3 & ~c4]
s4 = s_dff[c4]
data1 = s1.values.tolist()
data2 = s2.values.tolist()
data3 = s3.values.tolist()
data4 = s4.values.tolist()
c = (Parallel(init_opts=opts.InitOpts(height="800px")).add_schema([
opts.ParallelAxisOpts(dim=0, name="流通市值"),
opts.ParallelAxisOpts(dim=1, name="毛利率"),
opts.ParallelAxisOpts(dim=2, name="ROE"),
opts.ParallelAxisOpts(dim=3, name="季涨幅"),
opts.ParallelAxisOpts(dim=4, name="PE"),
opts.ParallelAxisOpts(dim=5, name="最新季涨幅"),
]).add("季涨幅>10", data1, linestyle_opts=opts.LineStyleOpts(width=2, color='rgba(255,0,0,0.7)')).add(
"季涨幅>0", data2, linestyle_opts=opts.LineStyleOpts(width=2, color='rgba(255,255,0,0.7)')).add(
"-季涨幅<0",
data3,
linestyle_opts=opts.LineStyleOpts(width=2, color='rgba(0,0,255,0.7)')).add(
"季涨幅<-10",
data4,
linestyle_opts=opts.LineStyleOpts(
width=2, color='rgba(0,255,0,0.7)')).render("parallel_category.html"))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/hiphops/ministock.git
git@gitee.com:hiphops/ministock.git
hiphops
ministock
ministock
master

搜索帮助