PythonStock(15):使用bokeh 展示股票报表数据
来源:互联网 发布:淘宝店铺企业认证 编辑:程序博客网 时间:2024/04/30 12:10
前言
使用Python开发一个股票项目。
项目地址:
https://github.com/pythonstock/stock
相关资料:
http://blog.csdn.net/freewebsys/article/details/78294566
主要使用开发语言是python。
使用的lib库是pandas,tushare,TensorFlow,tornado等。
本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/78634996
未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
1,关于bokeh
bokeh 是一个超级方便的python画图工具。
但是想把这个东西集成到我的股票统计系统上面。
有一个问题。官方的demo给的是直接输出到html文件当中。
而和 tornado 集成上面也是一个封装。都不是我想要的方法。
直接找到 bokeh的源代码读了下,找到了方法。
2,分析
https://bokeh.pydata.org/en/latest/docs/user_guide/server.html
这个类很好的说明了下
https://github.com/bokeh/bokeh/blob/master/examples/embed/embed_themed.py
from bokeh.embed import componentsscript, div = components(p1, theme=theme)返回的是script 和 div 最关键的两个
一个简单的两个图形:
#!/usr/bin/python3# -*- coding: utf-8 -*-from tornado import genimport web.base as webBaseimport logging# 首映 bokeh 画图。from bokeh.plotting import figurefrom bokeh.embed import components# 获得页面数据。class GetDataIndicatorsHandler(webBase.BaseHandler): @gen.coroutine def get(self): code = self.get_argument("code", default=None, strip=False) print(code) # self.uri_ = ("self.request.url:", self.request.uri) # print self.uri_ try: print("#######") except Exception as e: print("error :", e) logging.info("####################GetStockHtmlHandlerEnd") comp_list = [] # prepare some data x = [1, 2, 3, 4, 5] y = [6, 7, 2, 4, 5] # create a new plot with a title and axis labels p = figure( plot_width=400, plot_height=300, title="simple line example", x_axis_label='x', y_axis_label='y' ) # add a line renderer with legend and line thickness p.line(x, y, legend="Temp.", line_width=2) comp1 = components(p) comp2 = components(p) comp_list.append(comp1) comp_list.append(comp2) self.render("stock_indicators.html", comp_list=comp_list)
页面显示:
<!-- 增加 bokeh 样式。--><link rel="stylesheet" href="/static/css/bokeh.min.css" type="text/css"/><link rel="stylesheet" href="/static/css/bokeh-widgets.min.css" type="text/css"/><link rel="stylesheet" href="/static/css/bokeh-tables.min.css" type="text/css"/><script type="text/javascript" src="/static/js/bokeh.min.js"></script><script type="text/javascript" src="/static/js/bokeh-widgets.min.js"></script><script type="text/javascript" src="/static/js/bokeh-tables.min.js"></script><script type="text/javascript" src="/static/js/bokeh-gl.min.js"></script><script type="text/javascript"> Bokeh.set_log_level("info");</script><h3 class="header smaller lighter blue">数据详细展示</h3><div class="table-header">1.</div> {% for index,element in enumerate(comp_list) %} <div class="row" id="_col_{{ index+1 }}" data-column="{{ index }}"> {% raw element[0] %} {% raw element[1] %} </div> {% end %}
其中 这些资源在的地址是:
/usr/local/lib/python3.5/dist-packages/bokeh/server
这个在安装之后才能有。
3,显示效果
直接在一个页面当中显示两个图片。可以展示多个股票分析数据
4,总结
bokeh 是一个非常方便的库,我在开发股票系统的时候,需要展示多个分析的报表。这个时候就需要并列的显示多个图表。
类库使用的非常方便。
本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/78634996
未经博主允许不得转载。
博主地址是:http://blog.csdn.net/freewebsys
https://bokeh.pydata.org/en/latest/docs/user_guide/quickstart.html
- PythonStock(15):使用bokeh 展示股票报表数据
- PythonStock(16):使用bokeh 展示,股票中的16个常用指标
- PythonStock(14):使用pandas 批量处理股票数据,批量计算股票指标
- PythonStock(11):使用pandas计算股票波峰波谷猜想
- PythonStock(12):使用python,pandas进行股票分析
- PythonStock(1):python 股票系统设计
- PythonStock(10):使用notebook + tushare + pandas 简单的股票分析,蜡烛图
- PythonStock(13):使用stockstats计算股票中的16个常用指标方法大全
- PythonStock(2):tushare宏观数据使用pandas入库,增加唯一索引
- PythonStock(7):使用 dataTable+Editor+python+Tornado 实现数据通用CRUD
- PythonStock(9):使用优矿uqer.io 进行简单的数据分析
- PythonStock(3):使用python tornado web进行开发
- PythonStock(4):使用python + dataTable 进行开发
- PythonStock(8):使用优矿web学习python入门
- bokeh
- Grafana 获取MySQL数据展示报表
- Web报表系统葡萄城报表:数据展示
- 使用程序分析股票数据
- 入职三个月后的一点感想
- java垃圾回收
- mysql5.7导出数据提示--secure-file-priv选项问题的解决方法
- 实验测试1《C++ Primer》第五版——第十一章 关联容器
- SQL注入详细过程
- PythonStock(15):使用bokeh 展示股票报表数据
- [6]_编译内核错误提示1:Unable to find the ncurses libraries or the 和 E: Unable to locate package ncurse
- 读书笔记《C++ Primer》第五版——第十二章 动态内存
- 实用idea代码编辑快捷键
- Spring boot下 拦截器中的Service空指针异常解决方法
- 数据结构之排序二叉树递归建立,递归查找
- Lintcode 612. K个最近的点
- 装饰模式
- 第十三周java作业--集合框架