写个脚本帮你每天盯着某几支股票,达到预设值时响铃提醒。这是最简单的股票应用,虽然谈不上智能,但是自动化――老盯着就容易冲动操作。 本例中实现了每5秒取一次股票数据,并在上证指数高于3200点,或601318低于49元时响提醒。
import os
import time
import tushare as ts
import pandas as pd
def check(code, low, high):
df = ts.get_realtime_quotes(code)
e = df[['code','name','price','time']]
p = df[u'price']
print e
if float(p[0]) > low and float(p[0]) < high:
return True
else :
return False
while True:
if check('sh', 3200, 10000) or check('601318',0,49):
os.system('play bell.wav')
exit()
time.sleep(5)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有