Python监控股价并通过微信提醒

本文介绍了如何使用Python监控特定股票价格,通过设置买卖点并在达到这些点位时自动发送微信提醒。教程包括了所需库的导入、微信登录、实时股价监控及相应的微信通知逻辑。
部署运行你感兴趣的模型镜像

01

Python监控股价并通过微信提醒

炒股盯盘太累,能在设置的买卖点进行智能提醒吗?

没错,python可以帮你实现:通过python编程实现股价实时监控,并在买卖点通过微信发送信息自动提醒!

今天,梅朵就来给大家演示:Python监控股价并通过微信提醒的方法!

Python在买卖点进行微信提醒

方法介绍

1.导入依赖库

主要是导入微信依赖包和股票包。

from wxpy import *import tushare as tsimport json

2.登录微信

登录微信。

my_friend = bot.friends().search('stock')[0]#换为自己的昵称

3.股票实时股价监控

主要是获取股票实时股价,并根据设置的买卖点进行盯盘判断,符合买卖条件时进行微信提醒。

stock=['000001']#换为监控的股票代码 data=ts.get_realtime_quotes(stock) price_now=float(data['price'].to_list()[0]) price_buy_1=float(data['bid'].to_list()[0]) price_sell_1=float(data['ask'].to_list()[0]) while (12<price_now<13) is True: data=ts.get_realtime_quotes(stock) price_now=float(data['price'].to_list()[0]) price_buy_1=float(data['bid'].to_list()[0]) price_sell_1=float(data['ask'].to_list()[0]) if(price_now<=12): my_friend.send("当前股价低于设置的买入点"+"\n"+ "可考虑买入!"+"\n"+ "当前股价为:"+str(price_now)+"\n"+ "当前买一价:"+str(price_buy_1)+"\n"+ "当前卖一价:"+str(price_sell_1)) if(price_now>=13): my_friend.send("当前股价高于设置的卖出点"+"\n"+ "可考虑卖出!"+"\n"+ "当前股价为:"+str(price_now)+"\n"+ "当前买一价:"+str(price_buy_1)+"\n"+ "当前卖一价:"+str(price_sell_1))

完整代码

from wxpy import *import tushare as tsimport json if __name__=="__main__": bot = Bot(cache_path=True) my_friend = bot.friends().search('stock')[0]#换为自己的昵称 stock=['000001']#换为监控的股票代码 data=ts.get_realtime_quotes(stock) price_now=float(data['price'].to_list()[0]) price_buy_1=float(data['bid'].to_list()[0]) price_sell_1=float(data['ask'].to_list()[0]) while (12<price_now<13) is True: data=ts.get_realtime_quotes(stock) price_now=float(data['price'].to_list()[0]) price_buy_1=float(data['bid'].to_list()[0]) price_sell_1=float(data['ask'].to_list()[0]) if(price_now<=12): my_friend.send("当前股价低于设置的买入点"+"\n"+ "可考虑买入!"+"\n"+ "当前股价为:"+str(price_now)+"\n"+ "当前买一价:"+str(price_buy_1)+"\n"+ "当前卖一价:"+str(price_sell_1)) if(price_now>=13): my_friend.send("当前股价高于设置的卖出点"+"\n"+ "可考虑卖出!"+"\n"+ "当前股价为:"+str(price_now)+"\n"+ "当前买一价:"+str(price_buy_1)+"\n"+ "当前卖一价:"+str(price_sell_1))

您可能感兴趣的与本文相关的镜像

Python3.10

Python3.10

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值