123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- __author__ = 'weijie'
- from EmQuantAPI import *
- from datetime import timedelta, datetime
- import time
- import traceback
- import json
- from StockRestPojo import StockRestPojo
- from dbOperation import dbOperation
- from threading import Thread
- import db_config
- def csqCallback(quantdata):
- current_time = datetime.strftime(datetime.now(),"%H:%M:%S")
- time1 = "09:15:00"
- time2 = "11:30:00"
- time3 = "12:59:00"
- time4 = "15:00:00"
- if (current_time > time1 and current_time < time2) or (current_time > time3 and current_time < time4):
- try:
- fileName = "/www/wwwroot/csqdata/tempindex/" + str(round(time.time() * 1000000)) + ".txt"
- with open(fileName, 'w', encoding="utf-8") as file:
- file.write(str(quantdata.Data))
- except Exception as e:
- print(str(e))
- elif current_time > time4:
- try:
- fileName = "/www/wwwroot/csqdata/tempindex/after/" + str(round(time.time() * 1000000)) + ".txt"
- with open(fileName, 'w', encoding="utf-8") as file:
- file.write(str(quantdata.Data))
- except Exception as e:
- print(str(e))
- # elif current_time < time1:
- # # 盘前数据
- # try:
- # fileName = "/www/wwwroot/csqdata/bond/InFront/" + str(round(time.time() * 1000000)) + ".txt"
- # with open(fileName, 'w', encoding="utf-8") as file:
- # file.write(str(quantdata.Data))
- # except Exception as e:
- # print(str(e))
- class TempIndexRestData:
- # 指数数据抓取
- def toGet(self):
- try:
- # 上证指数 深圳指数 创业板指数 沪深300 中小板指 深证综指
- data = c.csq("000001.SH,399001.SZ,399006.SZ,399300.SZ,399005.SZ,399106.SZ,159982.SZ,IXIC.GI,US30USD.FX,159919.SZ,159912.SZ,510050.SH,159922.SZ,HSI.HI","Date,Time,Now,High,Low,Open,PreClose,Roundlot,Volume,Amount,Change,PctChange,Speed",'Pushtype=2',csqCallback)
- print(data)
- except Exception as ee:
- print("error >>>",ee)
- traceback.print_exc()
|