代码拉取完成,页面将自动刷新
同步操作将从 macroan/traderStock-gui 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#coding=utf-8
import datetime
import time
from threading import Timer
class MyTimer:
#count==-1 无限次
def __init__(self, sec, count, fun, *args, **kwargs):
self._tm = sec
self._fn = fun
self.count = count
self.args = args
self.kwargs = kwargs
self.isStart = True
def _do_func(self):
if self._fn:
self._fn(self.args, self.kwargs)
self._do_start()
def _do_start(self):
if self.isStart:
if self.count > 0:
self.count -= 1
if self.count == 0:
self.isStart = False
self._timer = Timer(self._tm, self._do_func)
self._timer.start()
else:
print("the timer is stoped!")
def start(self):
self.isStart = True
self._do_start()
def stop(self):
try:
self.isStart = False
self._timer.cancel()
print("the timer is stoped!")
except:
pass
def join(self):
self._timer.join()
def dayCount(newdf, olddf):
newday = str(newdf.iloc[0]['date'])
oldday = str(olddf.iloc[0]['date'])
d1 = datetime.datetime.strptime(newday, "%Y-%m-%d").date()
d2 = datetime.datetime.strptime(oldday, "%Y-%m-%d").date()
if d1 <= d2:
return 0
daycount = (d1 - d2).days
cnt = 0
mc = min(daycount, len(newdf.index))
for i in xrange(0, mc):
if str(newdf.iloc[i]['date']) == oldday :
break
cnt = cnt + 1
return cnt
def is_same_week(date1, date2):
d1 = datetime.datetime.strptime(date1, "%Y-%m-%d").date()
d2 = datetime.datetime.strptime(date2, "%Y-%m-%d").date()
daycount = (d1 - d2).days
if daycount == 0:
return True
if daycount > 4:
return False
for i in xrange(1, daycount+1):
date = d1 - datetime.timedelta(days=i)
if is_weekend(date):
return False
return True
def is_weekend(date):
return date.weekday() in [5,6]
def is_not_tradetime(date):
t = date.time()
opentime = datetime.time(9,30,0)
endtime = datetime.time(15,0,0)
if t < opentime or t > endtime:
return True
return False
def now():
return datetime.datetime.now()
def timestamp():
now = datetime.datetime.now()
ans_time = int(time.mktime(now.timetuple()))
return ans_time
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。