-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·46 lines (39 loc) · 1.35 KB
/
main.py
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#http://hq.sinajs.cn/list=sh600538,sz000002,sz000656,sz002133,sz002613,sh601099,sh601872,sh601668,sh603133,sh603603,sz000655
#http://live.sina.com.cn/zt/f/v/finance/globalnews1?tag=10 a股新闻
import time
import datetime
from utils import date_utils,data_utils
import argparse
import numpy as np
import os
from utils.net_utils import HtmlDownloader
import curses
if __name__=='__main__':
'''
如果是交易时间则30s更新一次,
否则30分钟更新一次
'''
scr = curses.initscr()
curses.echo()
scr.nodelay(True)
FIRST=True
try:
while True:
if scr.getch()==ord('q'):
break
if (date_utils.is_off() or date_utils.is_weekend()) and not FIRST:
curses.napms(3*1000)
continue
# out='\n'.join([str(value) for value in data_utils.get_stocks(HtmlDownloader())])+'\n'+'-'*100
stocks=data_utils.get_stocks(HtmlDownloader())
for i in range(len(stocks)):
scr.addstr(i,0,str(stocks[i]))
# if (date_utils.is_off() or date_utils.is_weekend()):
# out+='\n市场闭市......\n停止更新......'
scr.refresh()
curses.napms(3000)
FIRST=False
except Exception as e:
print(repr(e))
finally:
curses.endwin()