1.判断当前时间是否在交易时段里

def DuringTradingSession(VarietyCode) :

# 函数功能:判断当前时间是否在交易时段里 # 参数 variety_code 为品种代码,例如:'IH' # 返回值为:True 或者 False Information = GetVarietyInfo2(VarietyCode) # 获取品种信息 NumberOfSession = len(Information['交易时段']) # 统计交易时段个数 CurrentTime = GetCurrentTime() # 查询当前时间 # 拼接小时、分钟、秒(整数类型) H = CurrentTime.hour M = CurrentTime.minute S = CurrentTime.second HMS = H * 10000 + M * 100 + S Count = 0 # 是否在交易时段计数器 for i in range(NumberOfSession): if Information['交易时段'][i]['小节开始'] * 100 < HMS < \ Information['交易时段'][i]['小节结束'] * 100 : Count += 1 if Count == 1: return True else: return False