4

Python & tushare 实现命令行盯盘

 3 years ago
source link: http://abcdxyzk.github.io/blog/2021/04/15/tools-shares/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Python & tushare 实现命令行盯盘

2021-04-15 15:22:00

https://blog.csdn.net/u011323949/article/details/102937856

pip install tushare
pip install pandas
# -*- coding:utf-8 -*-
import tushare as ts
import os
import threading
import time
from datetime import datetime

codes = ['000756', '601288', '601988', '601319', '600929']

while 1:
	df = ts.get_realtime_quotes(codes);

	os.system("clear")
	print datetime.now()
	for k in range(0, len(codes)):
		p1 = float(df['price'][k])
		p2 = float(df['pre_close'][k])
		print "%s %s %.3f %.3f %.3f%%" % (df['code'][k], df['name'][k], p1, p2, (p1 - p2) / p2 * 100)

	time.sleep(10);

Posted by kk

2021-04-15 15:22:00tools, base

« udp vpn, 代理dota2 微信公众号自定义菜单 »


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK