kk Blog —— 通用基础


date [-d @int|str] [+%s|"+%F %T"]
netstat -ltunp
sar -n DEV 1

Python & tushare 实现命令行盯盘

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

依赖

1
2
pip install tushare
pip install pandas

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# -*- 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:
	try:
		df = ts.get_realtime_quotes(codes);
	except:
		print "get err\n";
		time.sleep(3);
		continue;

	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);