Giter Site home page Giter Site logo

stock's Introduction

说明,项目迁移到了Gitee 啦,最后一次修改,2023-06-02 执行存档

项目迁移到这里了:此项目后续更新访问这里:

https://gitee.com/pythonstock/stock

github项目后续就Archives存档了,不再更新了!

csdn的pythonstock专栏地址,相关资料都在这里有说明:

https://blog.csdn.net/freewebsys/category_9285317.html

pythonstock V2 项目简介

特别说明:股市有风险投资需谨慎,本项目只能用于Python代码学习,股票分析,投资失败亏钱不负责,不算BUG。

项目地址:https://github.com/pythonstock/stock
PythonStock V2 是基于Python的pandas,akshare,bokeh,tornado,stockstats,ta-lib等框架开发的全栈股票系统。
项目创建于2017年7月17日,每月不定期更新。
1)可以直接使用docker直接本地部署运行,整个项目在docker hub上压缩后200MB,本地占用500MB磁盘空间。
2)使用Docker解决了Python库安装问题,使用Mariadb(MySQL)存储数据。借助akshare抓取数据。
3)使用cron做定时任务,每天进行数据抓取计算,每天18点开始进行数据计算,计算当日数据,使用300天数据进行计算,大约需要15分钟计算完毕。
4)股票数据接口防止被封,按天进行数据缓存,储存最近3天数据,每天定时清除,同时使用read_pickle to_pickle 的gzip压缩模式存储。
5)使用tornado开发web系统,支持每日股票数据-东财,龙虎榜-个股上榜-新浪,数据中心-大宗交易行情等。
6)数据展示系统,是通用数据展示系统,配置字典模板之后,页面自动加载数据,并完成数据展示,后续自己开发的指标数据可以加入进去。
7)增加曲线数据分析,在查看股票中,可以直接跳转到东方财富页面查看相关信息,点击指标之后使用Bokeh将多达 17 个指标的数据绘图,进行图表展示。
8) 2.0 最大的更新在于替换tushare库(因部分库不能使用),使用akshare进行数据抓取。

基础库版本

1,pandas使用【 1.3.5 】版本,升级了
2,numpy使用【 1.21.5 】版本,升级了
3,akshare使用【 1.3.50 】版本,升级了
4,bokeh使用【 2.4.2 】版本,升级了
5,stockstats使用【 0.3.2 】版本

2.0 说明 image image

bokeh 绘图指标数据:

image

然后根据3个指标进行股票数据计算:


KDJ:
1,超买区:K值在80以上,D值在70以上,J值大于90时为超买。一般情况下,股价有可能下跌。投资者应谨慎行事,局外人不应再追涨,局内人应适时卖出。
2,超卖区:K值在20以下,D值在30以下为超卖区。一般情况下,股价有可能上涨,反弹的可能性增大。局内人不应轻易抛出股票,局外人可寻机入场。

RSI:
1.当六日指标上升到达80时,表示股市已有超买现象,如果一旦继续上升,超过90以上时,则表示已到严重超买的警戒区,股价已形成头部,极可能在短期内反转回转。
2.当六日强弱指标下降至20时,表示股市有超卖现象,如果一旦继续下降至10以下时则表示已到严重超卖区域,股价极可能有止跌回升的机会。

CCI
1、当CCI>﹢100时,表明股价已经进入非常态区间——超买区间,股价的异动现象应多加关注。
2、当CCI<﹣100时,表明股价已经进入另一个非常态区间——超卖区间,投资者可以逢低吸纳股票。

购买条件结果表:guess_indicators_lite_buy_daily
购买条件结果表:guess_indicators_lite_sell_daily

每日股票指标数据计算17个指标如下(数据表 guess_indicators_daily):

计算指标 说明
1,交易量delta指标分析 The Volume Delta (Vol ∆)
2,计算n天差 可以计算,向前n天,和向后n天的差。
3,n天涨跌百分百计算 可以看到,-n天数据和今天数据的百分比。
4, CR指标 http://wiki.mbalib.com/wiki/CR%E6%8C%87%E6%A0%87 价格动量指标 CR跌穿a、b、c、d四条线,再由低点向上爬升160时,为短线获利的一个良机,应适当卖出股票。 CR跌至40以下时,是建仓良机。而CR高于300~400时,应注意适当减仓。
5,最大值,最小值 计算区间最大值 volume max of three days ago, yesterday and two days later stock["volume_-3,2,-1_max"] volume min between 3 days ago and tomorrow stock["volume_-31_min"] 实际使用的时候使用 -22 可计算出5天的最大,最小值。
6, KDJ指标 http://wiki.mbalib.com/wiki/%E9%9A%8F%E6%9C%BA%E6%8C%87%E6%A0%87 随机指标(KDJ)一般是根据统计学的原理,通过一个特定的周期(常为9日、9周等)内出现过的最高价、 最低价及最后一个计算周期的收盘价及这三者之间的比例关系,来计算最后一个计算周期的未成熟随机值RSV, 然后根据平滑移动平均线的方法来计算K值、D值与J值,并绘成曲线图来研判股票走势。 (3)在使用中,常有J线的指标,即3乘以K值减2乘以D值(3K-2D=J),其目的是求出K值与D值的最大乖离程度, 以领先KD值找出底部和头部。J大于100时为超买,小于10时为超卖。
7,SMA指标 http://wiki.mbalib.com/wiki/Sma 简单移动平均线(Simple Moving Average,SMA) 可以动态输入参数,获得几天的移动平均。
8, MACD指标 http://wiki.mbalib.com/wiki/MACD 平滑异同移动平均线(Moving Average Convergence Divergence,简称MACD指标),也称移动平均聚散指标 MACD 则可发挥其应有的功能,但当市场呈牛皮盘整格局,股价不上不下时,MACD买卖讯号较不明显。 当用MACD作分析时,亦可运用其他的技术分析指标如短期 K,D图形作为辅助工具,而且也可对买卖讯号作双重的确认。
9, BOLL指标 http://wiki.mbalib.com/wiki/BOLL 布林线指标(Bollinger Bands)
10, RSI指标 http://wiki.mbalib.com/wiki/RSI 相对强弱指标(Relative Strength Index,简称RSI),也称相对强弱指数、相对力度指数 2)强弱指标保持高于50表示为强势市场,反之低于50表示为弱势市场。 (3)强弱指标多在70与30之间波动。当六日指标上升到达80时,表示股市已有超买现象,如果一旦继续上升,超过90以上时,则表示已到严重超买的警戒区,股价已形成头部,极可能在短期内反转回转。
11, W%R指标 http://wiki.mbalib.com/wiki/%E5%A8%81%E5%BB%89%E6%8C%87%E6%A0%87 威廉指数(Williams%Rate)该指数是利用摆动点来度量市场的超买超卖现象。
12, CCI指标 http://wiki.mbalib.com/wiki/%E9%A1%BA%E5%8A%BF%E6%8C%87%E6%A0%87 顺势指标又叫CCI指标,其英文全称为“Commodity Channel Index”, 是由美国股市分析家唐纳德·蓝伯特(Donald Lambert)所创造的,是一种重点研判股价偏离度的股市分析工具。 1、当CCI指标从下向上突破﹢100线而进入非常态区间时,表明股价脱离常态而进入异常波动阶段, 中短线应及时买入,如果有比较大的成交量配合,买入信号则更为可靠。 2、当CCI指标从上向下突破﹣100线而进入另一个非常态区间时,表明股价的盘整阶段已经结束, 将进入一个比较长的寻底过程,投资者应以持币观望为主。 CCI, default to 14 days
13, TR、ATR指标 http://wiki.mbalib.com/wiki/%E5%9D%87%E5%B9%85%E6%8C%87%E6%A0%87 均幅指标(Average True Ranger,ATR)均幅指标(ATR)是取一定时间周期内的股价波动幅度的移动平均值,主要用于研判买卖时机。
14, DMA指标 http://wiki.mbalib.com/wiki/DMA DMA指标(Different of Moving Average)又叫平行线差指标,是目前股市分析技术指标中的一种中短期指标,它常用于大盘指数和个股的研判。 DMA, difference of 10 and 50 moving average stock[‘dma’]
15, DMI,+DI,-DI,DX,ADX,ADXR指标 http://wiki.mbalib.com/wiki/DMI 动向指数Directional Movement Index,DMI) http://wiki.mbalib.com/wiki/ADX 平均趋向指标(Average Directional Indicator,简称ADX) http://wiki.mbalib.com/wiki/%E5%B9%B3%E5%9D%87%E6%96%B9%E5%90%91%E6%8C%87%E6%95%B0%E8%AF%84%E4%BC%B0 平均方向指数评估(ADXR)实际是今日ADX与前面某一日的ADX的平均值。ADXR在高位与ADX同步下滑,可以增加对ADX已经调头的尽早确认。 ADXR是ADX的附属产品,只能发出一种辅助和肯定的讯号,并非入市的指标,而只需同时配合动向指标(DMI)的趋势才可作出买卖策略。 在应用时,应以ADX为主,ADXR为辅。
16, TRIX,MATRIX指标 http://wiki.mbalib.com/wiki/TRIX TRIX指标又叫三重指数平滑移动平均指标(Triple Exponentially Smoothed Average)
17, VR,MAVR指标 http://wiki.mbalib.com/wiki/%E6%88%90%E4%BA%A4%E9%87%8F%E6%AF%94%E7%8E%87 成交量比率(Volumn Ratio,VR)(简称VR),是一项通过分析股价上升日成交额(或成交量,下同)与股价下降日成交额比值, 从而掌握市场买卖气势的中期技术指标。

使用方法(依赖docker)

使用 mariadb 和 stock 两个镜像

mkdir -p /data/mariadb/data
docker pull pythonstock/pythonstock:latest
docker pull mariadb:latest

docker run --name mariadb -v /data/mariadb/data:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=mariadb -p 3306:3306 -d mariadb:latest

docker run -itd --link=mariadb --name stock  \
    -v /data/notebooks:/data/notebooks \
    -p 8888:8888 \
    -p 9999:9999 \
    pythonstock/pythonstock:latest

直接启动stock ,使用其他 mysql 数据库,需要配置变量方式:

docker run -itd --name stock  \
    -v /data/notebooks:/data/notebooks \
    -p 8888:8888 \
    -p 9999:9999 \
    -e MYSQL_HOST=127.0.0.1 \
    -e MYSQL_USER=root \
    -e MYSQL_PWD=mariadb \
    -e MYSQL_DB=stock_data \
    pythonstock/pythonstock:latest

或者使用docker compose

安装docker-compose https://www.runoob.com/docker/docker-compose.html

sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose up -d

要想修改文件进行调试,增加当前目录映射,加入到stock里面:

        volumes:
            - "./jobs:/data/stock/jobs"
            - "./libs:/data/stock/libs"
            - "./web:/data/stock/web"

进入镜像:

docker exec -it stock bash 
sh /data/stock/jobs/cron.daily/run_daily

说明,启动容器后,会调用。run_init.sh 进行数据初始化,同时第一次执行后台执行当日数据。 以后每日18点(只有18点左右才有今日的数据)进行股票数据抓取并计算。

本地访问端口

http://localhost:9999 股票系统

股票系统设计

相关博客资料: https://blog.csdn.net/freewebsys/category_9285317.html

数据分析清洗使用pandas,numpy。 http://pandas.pydata.org/

数据存储到磁盘上,使用Mysql数据库。存储股票数据。 https://pypi.python.org/pypi/mysqlclient

web框架使用tornado http://www.tornadoweb.org/en/stable/

tornado web系统 http://docs.pythontab.com/tornado/introduction-to-tornado/

架构设计

全系使用python实现。因为都是python的类库,互相之间调用方便。 从数据抓取,数据处理,到数据展示数据运算都是python实现。

最终的数据都到前端展示出来。主要分为4个文件夹。

jobs 抓取数据并存储实现类。

libs 通用工具类。

web 前端展示框架。

supervisor 进程管理工具。

应用部署

需要mysql数据库启动。项目放到/data/stock 目录。

CREATE DATABASE IF NOT EXISTS `stock_data` CHARACTER SET utf8 COLLATE utf8_general_ci;

使用 :

http://docs.sqlalchemy.org/en/latest/core/reflection.html

更新日志

15 发布一个 2.0 的版本 - 2021-10-11

构建基础版本 pythonstock/pythonstock:base-2021-09 在这个镜像的基础上使用 akshare 1.1.9 折腾几个月,终于把2.0 弄好了,为啥弄2.0 因为之前发现 tushare的数据不能抓取了。需要注册成 pro 版本,但是pro 还有积分限制。 诸多不便吧,于是换成了 akshare 库了,大改了,需要找到相关的新库。然后在些代码。 删除掉了 ta-lib 安装了之后从来没有用到,jupyter 也是没有用。占空间影响下载心情。将镜像进一步减小。

14 bokeh 升级到 2.4.0 版本

目录 /usr/local/lib/python3.7/site-packages 使用脚本进行升级。

13 升级ak到v1.0.80 做好每日东方财经数据

https://www.akshare.xyz/zh_CN/latest/data/stock/stock.html#id1 限量: 单次返回所有 A 股上市公司的实时行情数据

600开头的股票是上证A股,属于大盘股,其中6006开头的股票是最早上市的股票, 6016开头的股票为大盘蓝筹股;900开头的股票是上证B股; 000开头的股票是深证A股,001、002开头的股票也都属于深证A股, 其中002开头的股票是深证A股中小企业股票;200开头的股票是深证B股; 300开头的股票是创业板股票;400开头的股票是三板市场股票。

过滤包括:600,6006,601,000,001,002,且不包括ST的股票数据。

增加数据库utf8 参数 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

12 升级基础镜像到3.7 python,保障 akshare 0.6.10 以上版本支持

发现 akshare 要求升级python 3.7 以上版本才可以,需要升级基础镜像。 然后 akshare 就可以升级到 0.9.65 的最新版本了。 新版本就可以按照日期进行查询,解决 TypeError: stock_zh_a_daily() got an unexpected keyword argument 'start_date' 这个问题了。

11 使用 akshare 做相关股票数据抓取

**的股市开盘时间为:每周一至周五的上午9:30——11:30, 下午13:00——15:00。**股市收盘时间为:每周一至周五的下午3点。

实时行情数据 接口: stock_zh_a_spot 目标地址: http://vip.stock.finance.sina.com.cn/mkt/#hs_a 描述: A 股数据是从新浪财经获取的数据, 重复运行本函数会被新浪暂时封 IP, 建议增加时间间隔 限量: 单次返回所有 A 股上市公司的实时行情数据

历史行情数据 日频率 接口: stock_zh_a_daily 目标地址: https://finance.sina.com.cn/realstock/company/sh600006/nc.shtml(示例) 描述: A 股数据是从新浪财经获取的数据, 历史数据按日频率更新; 注意其中的 sh689009 为 CDR, 请 通过 stock_zh_a_cdr_daily 接口获取 限量: 单次返回指定 A 股上市公司指定日期间的历史行情日频率数据

10 增加东方财经弹窗窗口、增加指标计算弹窗窗口

发现了一个东方财富的页面,是给pc端用的。 可以做个弹出框放到系统中。不进行调整了,长宽高可以做的小点。使用iframe引入界面。否则有跨域和样式问题。

修改指标页面,改成窗口弹窗,做页面适配,方便查看。

9,增加日历

古老的jquery 代码:
		$( ".date-picker" ).datepicker({
			language: 'zh-CN', //设置语言
            format:"yyyymmdd",
            showOtherMonths: true,
            selectOtherMonths: false,
            autoclose: true,
			todayHighlight: true
        });
针对日期类型的搜索条件增加日历

https://www.bootcss.com/p/bootstrap-datetimepicker/ 不是使用jQuery的时间。

8,发现MariaDb 版本不兼容问题,最后切换成mysql,使用 mysql:5.7 镜像

相关数据执行只支持到10.5.4,版本可以使用,但是10.5.8 就有问题了。 限制死了版本。看来软件也不能瞎升级,都用最新的有问题。可以解决数据问题。 使用 mysql:5.7 镜像,更通用些,不折腾mariaDb了。

7,解决 Bokeh JS兼容问题。

升级 bokeh 到 2.1.1 版本

https://pypi.org/project/bokeh/#files

升级JS,因为 lib 包升级导致问题。

6,升级 bokeh 到 2.1.1 版本


https://pypi.org/project/bokeh/#files

5,解决日志打印问题


配置 main.py 
tornado.options.parse_command_line()

然后启动配置参数:
/usr/local/bin/python3 /data/stock/web/main.py -log_file_prefix=/data/logs/web.log

4,解决跑数据问题

# 通过数据库链接 engine。
def conn():
    try:
        db = MySQLdb.connect(MYSQL_HOST, MYSQL_USER, MYSQL_PWD, MYSQL_DB, charset="utf8")
        # db.autocommit = True
    except Exception as e:
        print("conn error :", e)
    db.autocommit(on=True)
    return db.cursor()

之前升级过代码,造成 db.cursor() 问题。

3,增加多字段排序

1,点击是单个字段进行排序。

2,按照【shift】,点击多个,即可完成多字段排序。

3,服务端分页排序。

4,按照多个字段进行筛选查询。

2,使用pandas处理重复数据

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop_duplicates.html

    data = get_data(year, quarter)
    # 处理重复数据,保存最新一条数据。
    data.drop_duplicates(subset="code", keep="last")

1,web使用datatable显示报表

通用数据配置,在 libs/stock_web_dic.py 配置数据之后,可以实现动态加载菜单,根据数据库表的行列显示数据。

不用一个表一个表进行开发,通用数据展示。

stock's People

Contributors

0xhjk avatar golangpkg avatar jennyshining avatar nicozhang avatar yuj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stock's Issues

小白请教执行sh /data/stock/jobs/cron.daily/run_daily

Traceback (most recent call last):
File "/usr/local/lib/python3.6/urllib/request.py", line 1349, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/local/lib/python3.6/http/client.py", line 1272, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1318, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1267, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1038, in _send_output
self.send(msg)
File "/usr/local/lib/python3.6/http/client.py", line 976, in send
self.connect()
File "/usr/local/lib/python3.6/http/client.py", line 948, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/local/lib/python3.6/socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/daily_job.py", line 30, in stat_all
data = ts.top_list(datetime_str)
File "/usr/local/lib/python3.6/site-packages/tushare/stock/billboard.py", line 64, in top_list
if(du.is_holiday(date)):
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 91, in is_holiday
df = trade_cal()
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 83, in trade_cal
df = pd.read_csv(ct.ALL_CAL_FILE)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 431, in _read
filepath_or_buffer, encoding, compression
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 172, in get_filepath_or_buffer
req = urlopen(filepath_or_buffer)
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 141, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/lib/python3.6/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/18h_daily_job.py", line 38, in stat_index_all
common.insert_db(data, "ts_index_all", False, "date,code")
File "/data/stock/libs/common.py", line 59, in insert_db
insert_other_db(MYSQL_DB, data, table_name, write_index, primary_keys)
File "/data/stock/libs/common.py", line 68, in insert_other_db
insp = inspect(engine_mysql)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/inspection.py", line 64, in inspect
ret = reg(subject)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 139, in _insp
return Inspector.from_engine(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 135, in from_engine
return Inspector(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 108, in init
bind.connect().close()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2266, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 104, in init
else engine.raw_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2373, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/18h_daily_job.py", line 57, in stat_today_all
common.insert_db(data, "ts_today_all", False, "date,code")
File "/data/stock/libs/common.py", line 59, in insert_db
insert_other_db(MYSQL_DB, data, table_name, write_index, primary_keys)
File "/data/stock/libs/common.py", line 68, in insert_other_db
insp = inspect(engine_mysql)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/inspection.py", line 64, in inspect
ret = reg(subject)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 139, in _insp
return Inspector.from_engine(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 135, in from_engine
return Inspector(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 108, in init
bind.connect().close()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2266, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 104, in init
else engine.raw_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2373, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 104, in stat_all_batch
count = common.select_count(sql_count, params=[datetime_int, '300%', '%st%'])
File "/data/stock/libs/common.py", line 111, in select_count
with conn() as db:
File "/data/stock/libs/common.py", line 52, in conn
db.autocommit(on=True)
UnboundLocalError: local variable 'db' referenced before assignment
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 40, in stat_all_lite_buy
data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 438, in read_sql
chunksize=chunksize,
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1218, in read_query
result = self.execute(*args)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1087, in execute
return self.connectable.execute(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2237, in execute
connection = self._contextual_connect(close_with_result=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2305, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 75, in stat_all_lite_sell
data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 438, in read_sql
chunksize=chunksize,
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1218, in read_query
result = self.execute(*args)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1087, in execute
return self.connectable.execute(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2237, in execute
connection = self._contextual_connect(close_with_result=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2305, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
(Background on this error at: http://sqlalche.me/e/13/e3q8)
rm -f /data/cache/hist_data_cache/2021-04/
root@dd0d5595457a:/data#
C:\Users\hlc>docker exec -it stock bash
root@929f1f0e5dbe:/data# sh /data/stock/jobs/cron.daily/run_daily
Traceback (most recent call last):
File "/usr/local/lib/python3.6/urllib/request.py", line 1349, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/local/lib/python3.6/http/client.py", line 1272, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1318, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1267, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/local/lib/python3.6/http/client.py", line 1038, in _send_output
self.send(msg)
File "/usr/local/lib/python3.6/http/client.py", line 976, in send
self.connect()
File "/usr/local/lib/python3.6/http/client.py", line 948, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/local/lib/python3.6/socket.py", line 704, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/local/lib/python3.6/socket.py", line 745, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Temporary failure in name resolution

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/daily_job.py", line 30, in stat_all
data = ts.top_list(datetime_str)
File "/usr/local/lib/python3.6/site-packages/tushare/stock/billboard.py", line 64, in top_list
if(du.is_holiday(date)):
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 91, in is_holiday
df = trade_cal()
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 83, in trade_cal
df = pd.read_csv(ct.ALL_CAL_FILE)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 431, in _read
filepath_or_buffer, encoding, compression
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 172, in get_filepath_or_buffer
req = urlopen(filepath_or_buffer)
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 141, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
response = self._open(req, data)
File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
'_open', req)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 1377, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/lib/python3.6/urllib/request.py", line 1351, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name resolution>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/18h_daily_job.py", line 38, in stat_index_all
common.insert_db(data, "ts_index_all", False, "date,code")
File "/data/stock/libs/common.py", line 59, in insert_db
insert_other_db(MYSQL_DB, data, table_name, write_index, primary_keys)
File "/data/stock/libs/common.py", line 68, in insert_other_db
insp = inspect(engine_mysql)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/inspection.py", line 64, in inspect
ret = reg(subject)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 139, in _insp
return Inspector.from_engine(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 135, in from_engine
return Inspector(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 108, in init
bind.connect().close()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2266, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 104, in init
else engine.raw_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2373, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/18h_daily_job.py", line 57, in stat_today_all
common.insert_db(data, "ts_today_all", False, "date,code")
File "/data/stock/libs/common.py", line 59, in insert_db
insert_other_db(MYSQL_DB, data, table_name, write_index, primary_keys)
File "/data/stock/libs/common.py", line 68, in insert_other_db
insp = inspect(engine_mysql)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/inspection.py", line 64, in inspect
ret = reg(subject)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 139, in _insp
return Inspector.from_engine(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 135, in from_engine
return Inspector(bind)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/reflection.py", line 108, in init
bind.connect().close()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2266, in connect
return self._connection_cls(self, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 104, in init
else engine.raw_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2373, in raw_connection
self.pool.unique_connection, _connection
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 304, in unique_connection
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 104, in stat_all_batch
count = common.select_count(sql_count, params=[datetime_int, '300%', '%st%'])
File "/data/stock/libs/common.py", line 111, in select_count
with conn() as db:
File "/data/stock/libs/common.py", line 52, in conn
db.autocommit(on=True)
UnboundLocalError: local variable 'db' referenced before assignment
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 40, in stat_all_lite_buy
data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 438, in read_sql
chunksize=chunksize,
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1218, in read_query
result = self.execute(*args)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1087, in execute
return self.connectable.execute(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2237, in execute
connection = self._contextual_connect(close_with_result=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2305, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 75, in stat_all_lite_sell
data = pd.read_sql(sql=sql_1, con=common.engine(), params=[datetime_int])
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 438, in read_sql
chunksize=chunksize,
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1218, in read_query
result = self.execute(*args)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1087, in execute
return self.connectable.execute(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2237, in execute
connection = self._contextual_connect(close_with_result=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2305, in _contextual_connect
self._wrap_pool_connect(self.pool.connect, None),
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2343, in wrap_pool_connect
e, dialect, self
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1585, in handle_dbapi_exception_noconnection
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2339, in _wrap_pool_connect
return fn()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 364, in connect
return _ConnectionFairy._checkout(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 778, in _checkout
fairy = _ConnectionRecord.checkout(pool)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 495, in checkout
rec = pool._do_get()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 140, in _do_get
self.dec_overflow()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/impl.py", line 137, in _do_get
return self._create_connection()
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 309, in _create_connection
return _ConnectionRecord(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 440, in init
self.__connect(first_connect_check=True)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 661, in _connect
pool.logger.debug("Error on connect(): %s", e)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/langhelpers.py", line 69, in exit
exc_value, with_traceback=exc_tb,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (1045, "Access denied for user 'root'@'172.17.0.2' (using password: YES)")
(Background on this error at: http://sqlalche.me/e/13/e3q8)
rm -f /data/cache/hist_data_cache/2021-04/

请教这是什么意思?此项目要独立的mysql吗,还是mariadb就足够了?

初始化提示表不存在

datetime_str: 2020-08-28
datetime_int: 20200828
insert sql: DELETE FROM stock_data.guess_indicators_lite_sell_daily WHERE date= '20200828'
error : (1146, "Table 'stock_data.guess_indicators_lite_sell_daily' doesn't exist")
error : (MySQLdb._exceptions.ProgrammingError) (1146, "Table 'stock_data.guess_indicators_daily' doesn't exist")
[SQL:
SELECT date, code, name, changepercent, trade, open, high, low,
settlement, volume, turnoverratio, amount, per, pb, mktcap,
nmc ,kdjj,rsi_6,cci
FROM stock_data.guess_indicators_daily WHERE date = %s
and kdjk <= 20 and kdjd <= 30 and kdjj <= 10 and rsi_6 <= 20 and cci <= -100

作者你好,我在docker部署之后点击买入猜想有个小Bug 找不到表

在左侧菜单点击 每日股票指标买入猜想 的时候 会报如下错误 找不到表

Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/tornado/web.py", line 1701, in _execute result = method(*self.path_args, **self.path_kwargs) File "/data/stock/web/dataTableHandler.py", line 136, in get stock_web_list = self.db.query(sql) File "/usr/local/lib/python3.6/site-packages/torndb.py", line 136, in query self._execute(cursor, query, parameters, kwparameters) File "/usr/local/lib/python3.6/site-packages/torndb.py", line 234, in _execute return cursor.execute(query, kwparameters or parameters) File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute res = self._query(query) File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query db.query(q) File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 259, in query _mysql.connection.query(self, query) MySQLdb._exceptions.ProgrammingError: (1146, "Table 'stock_data.guess_indicators_lite_buy_daily' doesn't exist")

执行run_daily脚本报错

root@c1ee33d1bbbb:/data# sh /data/stock/jobs/cron.daily/run_daily
Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/daily_job.py", line 30, in stat_all
data = ts.top_list(datetime_str)
File "/usr/local/lib/python3.6/site-packages/tushare/stock/billboard.py", line 64, in top_list
if(du.is_holiday(date)):
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 91, in is_holiday
df = trade_cal()
File "/usr/local/lib/python3.6/site-packages/tushare/util/dateu.py", line 83, in trade_cal
df = pd.read_csv(ct.ALL_CAL_FILE)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 676, in parser_f
return _read(filepath_or_buffer, kwds)
File "/usr/local/lib/python3.6/site-packages/pandas/io/parsers.py", line 431, in _read
filepath_or_buffer, encoding, compression
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 172, in get_filepath_or_buffer
req = urlopen(filepath_or_buffer)
File "/usr/local/lib/python3.6/site-packages/pandas/io/common.py", line 141, in urlopen
return urllib.request.urlopen(*args, **kwargs)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 564, in error
result = self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 756, in http_error_302
return self.parent.open(new, timeout=req.timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 404: Not Found

执行run_daily报错

执行
sh /data/stock/jobs/cron.daily/run_daily
报错信息如下:
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_daily_job.py", line 124, in stat_all_batch
stat_index_all(data, i)
File "/data/stock/jobs/guess_indicators_daily_job.py", line 218, in stat_index_all
data_new = concat_guess_data(stock_column, data)
File "/data/stock/jobs/guess_indicators_daily_job.py", line 248, in concat_guess_data
stock_guess = stock_guess.apply(apply_guess, stock_column=stock_column, axis=1) # , axis=1)
File "/usr/local/lib/python3.6/site-packages/pandas/core/frame.py", line 6878, in apply
return op.get_result()
File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 186, in get_result
return self.apply_standard()
File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 296, in apply_standard
values, self.f, axis=self.axis, dummy=dummy, labels=labels
File "pandas/_libs/reduction.pyx", line 620, in pandas._libs.reduction.compute_reduction
File "pandas/_libs/reduction.pyx", line 128, in pandas._libs.reduction.Reducer.get_result
File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 113, in f
return func(x, *args, **kwds)
File "/data/stock/jobs/guess_indicators_daily_job.py", line 270, in apply_guess
stock = common.get_hist_data_cache(code, date_start, date_end)
File "/data/stock/libs/common.py", line 186, in get_hist_data_cache
return pd.read_pickle(cache_file, compression="gzip")
File "/usr/local/lib/python3.6/site-packages/pandas/io/pickle.py", line 182, in read_pickle
return pickle.load(f)
EOFError: Ran out of input
rm -f /data/cache/hist_data_cache/2020-06/

指标页空白,日志报错(AttributeError("'NoneType' object has no attribute 'head'

[I 200802 16:17:37 dataIndicatorsHandler:27] 000001
[I 200802 16:17:37 dataIndicatorsHandler:27] 000001
[I 200802 16:17:37 dataIndicatorsHandler:51] Bad message (TypeError('not all arguments converted during string formatting',)): {'name': 'root', 'msg': 'error :', 'args': (AttributeError("'NoneType' object has no attribute 'head'",),), 'levelname': 'INFO', 'levelno': 20, 'pathname': '/data/stock/web/dataIndicatorsHandler.py', 'filename': 'dataIndicatorsHandler.py', 'module': 'dataIndicatorsHandler', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 51, 'funcName': 'get', 'created': 1596356257.799734, 'msecs': 799.7341156005859, 'relativeCreated': 2559465.4767513275, 'thread': 140460272067584, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 13, 'message': 'Bad message (TypeError('not all arguments converted during string formatting',)): {'name': 'root', 'msg': 'error :', 'args': (AttributeError("'NoneType' object has no attribute 'head'",),), 'levelname': 'INFO', 'levelno': 20, 'pathname': '/data/stock/web/dataIndicatorsHandler.py', 'filename': 'dataIndicatorsHandler.py', 'module': 'dataIndicatorsHandler', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 51, 'funcName': 'get', 'created': 1596356257.799734, 'msecs': 799.7341156005859, 'relativeCreated': 2559465.4767513275, 'thread': 140460272067584, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 13}', 'asctime': '200802 16:17:37', 'color': '', 'end_color': ''}
[I 200802 16:17:37 dataIndicatorsHandler:51] Bad message (TypeError('not all arguments converted during string formatting',)): {'name': 'root', 'msg': 'error :', 'args': (AttributeError("'NoneType' object has no attribute 'head'",),), 'levelname': 'INFO', 'levelno': 20, 'pathname': '/data/stock/web/dataIndicatorsHandler.py', 'filename': 'dataIndicatorsHandler.py', 'module': 'dataIndicatorsHandler', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 51, 'funcName': 'get', 'created': 1596356257.799734, 'msecs': 799.7341156005859, 'relativeCreated': 2559465.4767513275, 'thread': 140460272067584, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 13, 'message': 'Bad message (TypeError('not all arguments converted during string formatting',)): {'name': 'root', 'msg': 'error :', 'args': (AttributeError("'NoneType' object has no attribute 'head'",),), 'levelname': 'INFO', 'levelno': 20, 'pathname': '/data/stock/web/dataIndicatorsHandler.py', 'filename': 'dataIndicatorsHandler.py', 'module': 'dataIndicatorsHandler', 'exc_info': None, 'exc_text': None, 'stack_info': None, 'lineno': 51, 'funcName': 'get', 'created': 1596356257.799734, 'msecs': 799.7341156005859, 'relativeCreated': 2559465.4767513275, 'thread': 140460272067584, 'threadName': 'MainThread', 'processName': 'MainProcess', 'process': 13, 'message': 'Bad message (TypeError(\'not all arguments converted during string formatting\',)): {\'name\': \'root\', \'msg\': \'error :\', \'args\': (AttributeError("\'NoneType\' object has no attribute \'head\'",),), \'levelname\': \'INFO\', \'levelno\': 20, \'pathname\': \'/data/stock/web/dataIndicatorsHandler.py\', \'filename\': \'dataIndicatorsHandler.py\', \'module\': \'dataIndicatorsHandler\', \'exc_info\': None, \'exc_text\': None, \'stack_info\': None, \'lineno\': 51, \'funcName\': \'get\', \'created\': 1596356257.799734, \'msecs\': 799.7341156005859, \'relativeCreated\': 2559465.4767513275, \'thread\': 140460272067584, \'threadName\': \'MainThread\', \'processName\': \'MainProcess\', \'process\': 13, \'message\': \'Bad message (TypeError(\\\'not all arguments converted during string formatting\\\',)): {\\\'name\\\': \\\'root\\\', \\\'msg\\\': \\\'error :\\\', \\\'args\\\': (AttributeError("\\\'NoneType\\\' object has no attribute \\\'head\\\'",),), \\\'levelname\\\': \\\'INFO\\\', \\\'levelno\\\': 20, \\\'pathname\\\': \\\'/data/stock/web/dataIndicatorsHandler.py\\\', \\\'filename\\\': \\\'dataIndicatorsHandler.py\\\', \\\'module\\\': \\\'dataIndicatorsHandler\\\', \\\'exc_info\\\': None, \\\'exc_text\\\': None, \\\'stack_info\\\': None, \\\'lineno\\\': 51, \\\'funcName\\\': \\\'get\\\', \\\'created\\\': 1596356257.799734, \\\'msecs\\\': 799.7341156005859, \\\'relativeCreated\\\': 2559465.4767513275, \\\'thread\\\': 140460272067584, \\\'threadName\\\': \\\'MainThread\\\', \\\'processName\\\': \\\'MainProcess\\\', \\\'process\\\': 13}\', \'asctime\': \'200802 16:17:37\', \'color\': \'\', \'end_color\': \'\'}', 'asctime': '200802 16:17:37', 'color': '', 'end_color': ''}', 'asctime': '200802 16:17:37', 'color': '', 'end_color': ''}
[I 200802 16:17:37 dataIndicatorsHandler:52] #################### GetStockHtmlHandlerEnd ####################
[I 200802 16:17:37 dataIndicatorsHandler:52] #################### GetStockHtmlHandlerEnd ####################

离线安装的时候报错

环境:
Windows 10
Python 3.7.9

安装方式:
Github下载离线安装包,python setup.py install 命令安装

报错如下:
image

解决办法:
删除 setup.py 第一行的:

# coding:utf8

请问有没有完整的数据库脚本呀

Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/tornado/web.py", line 1697, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "/data/stock/web/dataTableHandler.py", line 136, in get
stock_web_list = self.db.query(sql)
File "/usr/local/lib/python3.6/site-packages/torndb.py", line 136, in query
self._execute(cursor, query, parameters, kwparameters)
File "/usr/local/lib/python3.6/site-packages/torndb.py", line 234, in _execute
return cursor.execute(query, kwparameters or parameters)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 209, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 315, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 226, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'stock_data.ts_stock_basics' doesn't exist")

run_daily报错http error 456

/data/stock/jobs/cron.daily/run_daily

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/18h_daily_job.py", line 49, in stat_today_all
data = ts.get_today_all()
File "/usr/local/lib/python3.6/site-packages/tushare/stock/trading.py", line 327, in get_today_all
newdf = _parsing_dayprice_json('hs_a', i)
File "/usr/local/lib/python3.6/site-packages/tushare/stock/trading.py", line 120, in _parsing_dayprice_json
text = urlopen(request, timeout=10).read()
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 456:

mac下 chown: changing ownership of '/var/lib/mysql/': Operation not permitted

2021-01-07 06:34:04+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.

chown: changing ownership of '/var/lib/mysql/': Operation not permitted

2021-01-07 06:34:11+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 1:10.5.8+maria~focal started.

chown: changing ownership of '/var/lib/mysql/': Operation not permitted

其他选股方式

有没有根据各种指标或者基本面数据进行选股的方式呢

Docker安装启动失败

安装步骤

  • docker命令
docker run -itd --name stock  \
	--network only \
	--restart always \
    -v /data/notebooks:/data/notebooks \
    -p 8808:8888 \
    -p 9909:9999 \
    -e MYSQL_HOST=mysql \
    -e MYSQL_USER=root \
    -e MYSQL_PWD=123456 \
    -e MYSQL_DB=stock_data \
    pythonstock/pythonstock:latest
  • 进入容器初始化
docker exec -it stock bash 
sh /data/stock/jobs/cron.daily/run_daily

初始化后的数据表:

WX20210129-151723

WEB运行正常,接口请求报错

WX20210129-150937

库里面没有Dockerfile

我看你最新提交加了
“本地构建
其中构建文件参考 Dockerfile ”

但是库里面并没有Dockerfile文件啊

还缺少一些其他的python文件,比如stockstats

还有数据库创建之后,数据表好像没有自动创建

能不能提交完整的程序,想自己在本地跑起来,谢谢

image

mac端 docker 数据库无法链接

Aborted connection 28 to db: 'stock_data' user: 'root' host: '172.17.0.3' (Got timeout reading communication packets)

一直报
[Warning] Aborted connection 75 to db: 'unconnected' user: 'unauthenticated' host: '172.17.0.1' (This connection closed normally without authentication)

Python

Python `````

my. Ltcbot.com/+2348129136349

数据严重不准

代码我没有跑, 我是按照博客上的方法运行的Python, 执行出来的数据跟看盘软件的数据严重不匹配。不可信

你好,安装完成后数据不显示

使用docker安装,一切正常,未提示错误,但是缺没有苏剧
尝试手动执行jobs下得run_init.sh,无法启动,
提示MySQLdb._exceptions.OperationalError: (2003, 'Can't connect to MySQL server on
'127.0.0.1' (111 "Connection refused")')
nohup: appending output to 'nohup.out'
cron: can't lock /var/run/crond.pid, otherpid may be 29: Resource temporarily un
available

卖出/买入猜想

卖出/买入猜想列表的股票是超卖/超买,不是应该超卖的是买入猜想吗?

执行 guess_indicators_lite_sell_daily_job 报错了。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_lite_buy_daily_job.py", line 50, in stat_all_lite
del stock_merge["date"] # 合并前删除 date 字段。
File "/usr/local/lib/python3.6/site-packages/pandas/core/generic.py", line 3759, in delitem
self._data.delete(key)
File "/usr/local/lib/python3.6/site-packages/pandas/core/internals/managers.py", line 1591, in delete
loc = self.items.get_loc(item)
File "/usr/local/lib/python3.6/site-packages/pandas/core/indexes/base.py", line 2648, in get_loc
return self._engine.get_loc(self._maybe_cast_indexer(key))
File "pandas/_libs/index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index.pyx", line 135, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/index_class_helper.pxi", line 109, in pandas._libs.index.Int64Engine._check_type
KeyError: 'date'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1278, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'stock_data.guess_indicators_lite_buy_daily' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/data/stock/libs/common.py", line 160, in run_with_args
run_fun(tmp_datetime_show) # 使用当前时间
File "/data/stock/jobs/guess_indicators_lite_sell_daily_job.py", line 84, in stat_index_calculate
data = pd.read_sql(sql=sql_1, con=common.engine(), params=[])
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 438, in read_sql
chunksize=chunksize,
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1218, in read_query
result = self.execute(*args)
File "/usr/local/lib/python3.6/site-packages/pandas/io/sql.py", line 1087, in execute
return self.connectable.execute(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2238, in execute
return connection.execute(statement, *multiparams, **params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1006, in execute
return self.execute_text(object, multiparams, params)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1181, in _execute_text
parameters,
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1318, in execute_context
e, statement, parameters, cursor, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1512, in handle_dbapi_exception
sqlalchemy_exception, with_traceback=exc_info[2], from
=e
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise

raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1278, in _execute_context
cursor, statement, parameters, context
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
cursor.execute(statement, parameters)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 259, in query
_mysql.connection.query(self, query)
sqlalchemy.exc.ProgrammingError: (MySQLdb._exceptions.ProgrammingError) (1146, "Table 'stock_data.guess_indicators_lite_buy_daily' doesn't exist")
[SQL:
SELECT buy_date, code, name, changepercent, trade, turnoverratio, pb, kdjj, rsi_6,
cci, wave_base, wave_crest, wave_mean, up_rate
FROM guess_indicators_lite_buy_daily where buy_date <= 20200711]
(Background on this error at: http://sqlalche.me/e/13/f405)

Mac的终端下出错

博主您好,首先谢谢您的分享!
我按照您的博客运行了代码,结果提示如下:
依赖镜像mariadb可以下载,并启动成功了;
但是tensorflow-stock镜像不能下载,报的是没有找到这样的文件,您没有共享这个文件吗?还是什么原因呢?如果不方便共享的话请告知一下,我就不在继续折腾了(已经折腾大半个月了,查了各种问题又尝试了各种方法,再次谢谢您的分享!)

终端运行报错结果如下:

******deMacBook-Pro:docker ******$ sh startStock.sh
docker: Error response from daemon: Conflict. The container name "/mariadb" is already in use by container "51f32a994b41c7b7febfd5194447105ad1771de9d51c4d81cf28a9673a5403d2". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
starting mariadb ...
wait 10 second , and create stock database .
mariadb is not running !!!
starting stock ...
Unable to find image 'github.com/pythonstock/stock/tensorflow-py3-stock:latest' locally
docker: Error response from daemon: error parsing HTTP 404 response body: invalid character 'N' looking for beginning of value: "Not Found".
See 'docker run --help'.
******deMacBook-Pro:docker ******$

有没有非docker部署方式啊

个人笔记本电脑,windows平台,用docker不是很方便,能否提供一下普通的python应用部署方式指导,提供一下数据库之类的配置文件,谢谢了

连接数据库报错

178, in raise_
raise exception
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/pool/base.py", line 656, in __connect
connection = pool._invoke_creator(self)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/strategies.py", line 114, in connect
return dialect.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 493, in connect
return self.dbapi.connect(*cargs, **cparams)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/init.py", line 130, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 185, in init
super().init(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (MySQLdb._exceptions.OperationalError) (2003, 'Can't connect to MySQL server on '127.0.0.1' (111 "Connection refused")')
(Background on this error at: http://sqlalche.me/e/13/e3q8)
rm -f /data/cache/hist_data_cache/2020-07/

background的网站打不开 百度查阅是连接数据库失败 但是我在容器里连接的应该也是容器内部的db吧? 求解

rm: cannot remove hist_data_cache,xxx : Is a directory

运行:

docker exec -it stock bash 
sh /data/stock/jobs/cron.daily/run_daily

报错:

NOTE: Behavior of MACDH calculation has changed as of July 2017 - it is now 1/2 of previous calculated values
Traceback (most recent call last):
  File "/data/stock/libs/common.py", line 160, in run_with_args
    run_fun(tmp_datetime_show)  # 使用当前时间
  File "/data/stock/jobs/guess_indicators_daily_job.py", line 124, in stat_all_batch
    stat_index_all(data, i)
  File "/data/stock/jobs/guess_indicators_daily_job.py", line 218, in stat_index_all
    data_new = concat_guess_data(stock_column, data)
  File "/data/stock/jobs/guess_indicators_daily_job.py", line 248, in concat_guess_data
    stock_guess = stock_guess.apply(apply_guess, stock_column=stock_column, axis=1)  # , axis=1)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/frame.py", line 6878, in apply
    return op.get_result()
  File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 186, in get_result
    return self.apply_standard()
  File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 313, in apply_standard
    results, res_index = self.apply_series_generator()
  File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 341, in apply_series_generator
    results[i] = self.f(v)
  File "/usr/local/lib/python3.6/site-packages/pandas/core/apply.py", line 113, in f
    return func(x, *args, **kwds)
  File "/data/stock/jobs/guess_indicators_daily_job.py", line 270, in apply_guess
    stock = common.get_hist_data_cache(code, date_start, date_end)
  File "/data/stock/libs/common.py", line 189, in get_hist_data_cache
    stock = ts.get_hist_data(code, start=date_start, end=date_end)
  File "/usr/local/lib/python3.6/site-packages/tushare/stock/trading.py", line 81, in get_hist_data
    js = json.loads(lines.decode('utf-8') if ct.PY3 else lines)
  File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 78670 (char 78669)
rm -f /data/cache/hist_data_cache/2020-07/
rm: cannot remove '/data/cache/hist_data_cache/2020-07/': Is a directory

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.