def main(argv): reload(sys) sys.setdefaultencoding('utf-8') initMysql() loadData(datetime.strptime("20170718", "%Y%m%d"), datetime.strptime("20170725", "%Y%m%d")) disconnect()
def main(argv): reload(sys) sys.setdefaultencoding('utf-8') # runTask() initMysql() startForecast()
def runTask(): # 周六执行每周任务 if datetime.today().weekday() == 5 and datetime.now( ).hour >= 9 and datetime.now().hour < 10 and datetime.now().minute < 20: begin = datetime.now() # 执行每周任务 initMysql() getStockListByPE(0) getSh50() getSh300() getMSCI() updateLatestGoodStockListToConfig() updateNewList() updateNewGoodList() # getStockHistoryInfo() disconnect() end = datetime.now() sendMessageToMySelf( unicode("本周获取PEG的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def main(argv): reload(sys) sys.setdefaultencoding('utf-8') # runTask() initMysql() updateAllMACD()
def saveToDb(type, result): initMysql() date = datetime.now().strftime('%Y-%m-%d') insertSql = unicode( "INSERT INTO b_peg VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)") parameters = [] for i in range(1, len(result)): data = result[i].replace("\n", "").decode('GBK').split(',') parameters.append([ data[0], date, data[1], int(time.time()), data[2], data[3], data[4], data[5], data[6], data[7], data[8], type ]) batchInsert(insertSql, parameters) disconnect()
def runTask(): if datetime.today().weekday() < 5 and datetime.now().hour >= 23 and datetime.now().hour < 24 and datetime.now().minute < 20: sendMessageToMySelf(unicode("开始计算今日技术指标数据")) begin = datetime.now() initMysql() updateKDJ() disconnect() end = datetime.now() message = unicode("计算今日技术指标数据的任务执行完毕,当前时间:{0},执行用时:{1}").format(datetime.now(), end - begin) writeLog(message) sendMessageToMySelf(message) t = Timer(900, runTask) t.start()
def main(argv): reload(sys) sys.setdefaultencoding('utf-8') initMysql() codeList = ['600758', '600393', '601318', '600282', '600029'] result = [] result.append( unicode("{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13}\n").format("代码", "名称", "ma5", "ma10", "ma20", "ma30", "ma60", "ma120", "ma200", "ma240", "BIAS1(6日)", "BIAS2(12日)", "BIAS3(24日)", "10收盘价").encode( 'gbk')) date = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d') for code in codeList: sql = unicode( "SELECT code,date,MA5,MA10,MA20,MA30,MA60,MA120,MA250,closePrice from s_stock where code='{0}' and date='{1}'").format( code, date) data = select(sql) if (len(data) <= 0): (unicode("没有获取到均值数据, code: {0}, date: {1}").format(code, date)) i = i + 1 continue ma5 = data[0][2] ma10 = data[0][3] ma30 = data[0][5] ma60 = data[0][6] ma120 = data[0][7] ma250 = data[0][8] closePrice = float(data[0][9]) nvg6 = getMAData(6, code, date) nvg12 = getMAData(12, code, date) nvg24 = getMAData(24, code, date) bias1 = round((closePrice - nvg6) * 100 / nvg6, 2) bias2 = round((closePrice - nvg12) * 100 / nvg12, 2) bias3 = round((closePrice - nvg24) * 100 / nvg24, 2) peInfo = getPE(code)
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 19 and datetime.now().hour < 20 and datetime.now().minute < 20: sendMessageToMySelf(unicode("开始获取今日指数数据")) begin = datetime.now() initMysql() saveStockIndex() disconnect() end = datetime.now() sendMessageToMySelf( unicode("今日获取指数数据的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 9 and datetime.now().hour < 10 and datetime.now().minute <= 20: begin = datetime.now() sendMessageToMySelf(unicode("启动今日涨跌幅提醒程序")) initMysql() reminder() disconnect() end = datetime.now() sendMessageToMySelf( unicode("今日涨跌幅提醒程序运行结束,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 22 and datetime.now().hour < 23 and datetime.now().minute < 20: sendMessageToMySelf(unicode("开始进行明日技术指标预测")) begin = datetime.now() initMysql() disconnect() end = datetime.now() sys.setdefaultencoding('utf-8') sendMessageToMySelf( unicode("明日技术指标预测的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 22 and datetime.now().hour < 23 and datetime.now().minute < 25: sendMessageToMySelf(unicode("开始获取今日股票技术指标数据")) begin = datetime.now() initMysql() saveStockTech() disconnect() end = datetime.now() sys.setdefaultencoding('utf-8') sendMessageToMySelf( unicode("今日获取各个股票的技术指标数据的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 19 and datetime.now().hour < 20 and datetime.now().minute < 20: sendMessageToMySelf(unicode("开始获取今日股票行情数据")) begin = datetime.now() initMysql() saveStockInfo() checkHighChangePercentStockForcase() disconnect() end = datetime.now() sendMessageToMySelf( unicode("今日获取各个股票的行情数据的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def main(argv): try: reload(sys) sys.setdefaultencoding('utf-8') # sendMessageToMySelf(unicode("开始查询股票历史行情数据")) begin = datetime.now() initMysql() # getStockHistoryInfoFromDb() # getStockHistoryInfoFromConfig() updateStockOtherInfo() disconnect() end = datetime.now() message = unicode("查询股票历史行情数据的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin) writeLog(message) sendMessageToMySelf(message) except: writeExceptionLog('RealTimeRemindTask Error.')
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 9 and datetime.now().hour < 10 and datetime.now().minute <= 20: begin = datetime.now() sendMessageToMySelf(unicode("启动均线数据提醒")) initMysql() stockList = loadJsonConfig( os.path.abspath( os.path.join(os.getcwd(), "../config/avglineReminder.json"))) checkAvgline(stockList) disconnect() end = datetime.now() sendMessageToMySelf( unicode("今日均线数据提醒程序运行结束,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
def runTask(): if datetime.today().weekday() < 5 and datetime.now( ).hour >= 20 and datetime.now().hour < 21 and datetime.now().minute < 20: sendMessageToMySelf(unicode("开始获取AvgLine数据")) begin = datetime.now() initMysql() stockList = getCodeList() checkAvgLine("avgline.csv", stockList, False) stockList = select( unicode("SELECT code,name from s_stock_info") ) # loadJsonConfig(os.path.abspath(os.path.join(os.getcwd(), "../config/goodStockList.json"))) checkAvgLine("avgline_all.csv", stockList) disconnect() end = datetime.now() sendMessageToMySelf( unicode("今日获取AvgLine的任务执行完毕,当前时间:{0},执行用时:{1}").format( datetime.now(), end - begin)) t = Timer(900, runTask) t.start()
import os sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), ".."))) from db.MysqlUtil import select, initMysql, execute from stock.StockInfo import getPE '''os.system("python AvgLinePriceCheckTask.py &") # 获取每日均线数据,工作日20点以后获取 os.system("python StockIndexTask.py &") # 获取每日各个主要指数数据,工作日19点以后获取 os.system("python StockTechTask.py &") # 获取每日各个股票的技术指标数据,工作日22点以后获取 os.system("python StockInfoTask.py &") # 获取每日各个股票的行情数据,工作日19点以后获取 os.system("python UpdateMADataTask.py &") #更新今日均线数据,工作日21点以后获取 os.system("python UpdateBiasDataTask.py &") #更新今日bias数据,工作日21点以后获取 os.system("python RealTimeRemindTask.py &") #启动每日提醒任务,工作日9点以后启动 os.system("python DownPercentRemindTask.py &") #启动每日涨跌幅提醒任务,工作日9点以后启动 os.system("python StockChooseTask.py &") # 每周更新PEG数据 ''' # 更新股票名称 initMysql() sql = unicode("SELECT code from s_stock_tech GROUP by code order by code asc") data = select(sql) for item in data: code = item[0] name = getPE(code)[0] print code, name addSql = unicode( "insert into s_stock_info(code,name) values('{0}','{1}')").format( code, name) execute(addSql)
def main(argv): reload(sys) sys.setdefaultencoding('utf-8') initMysql() updateForecast()