|
@@ -15,14 +15,7 @@ import db_config
|
|
|
|
|
|
print("开始了")
|
|
print("开始了")
|
|
def mainCallback(quantdata):
|
|
def mainCallback(quantdata):
|
|
- """
|
|
|
|
- mainCallback 是主回调函数,可捕捉如下错误
|
|
|
|
- 在start函数第三个参数位传入,该函数只有一个为c.EmQuantData类型的参数quantdata
|
|
|
|
- :param quantdata:c.EmQuantData
|
|
|
|
- :return:
|
|
|
|
- """
|
|
|
|
print ("mainCallback",str(quantdata))
|
|
print ("mainCallback",str(quantdata))
|
|
- print("开始了2222")
|
|
|
|
#登录掉线或者 登陆数达到上线(即登录被踢下线) 这时所有的服务都会停止
|
|
#登录掉线或者 登陆数达到上线(即登录被踢下线) 这时所有的服务都会停止
|
|
if str(quantdata.ErrorCode) == "10001011" or str(quantdata.ErrorCode) == "10001009":
|
|
if str(quantdata.ErrorCode) == "10001011" or str(quantdata.ErrorCode) == "10001009":
|
|
print ("Your account is disconnect. You can force login automatically here if you need.")
|
|
print ("Your account is disconnect. You can force login automatically here if you need.")
|
|
@@ -62,7 +55,7 @@ def cstCallBack(quantdata):
|
|
if "None" == str(result[2][j]):
|
|
if "None" == str(result[2][j]):
|
|
continue
|
|
continue
|
|
stockRestPojo = StockRestPojo()
|
|
stockRestPojo = StockRestPojo()
|
|
- stockRestPojo.date = "20201105"
|
|
|
|
|
|
+ stockRestPojo.date = "20201106"
|
|
stockRestPojo.time = str(result[0][j])
|
|
stockRestPojo.time = str(result[0][j])
|
|
stockRestPojo.now = str(result[1][j])
|
|
stockRestPojo.now = str(result[1][j])
|
|
stockRestPojo.high = str(result[2][j])
|
|
stockRestPojo.high = str(result[2][j])
|
|
@@ -70,8 +63,8 @@ def cstCallBack(quantdata):
|
|
stockRestPojo.open = str(result[4][j])
|
|
stockRestPojo.open = str(result[4][j])
|
|
stockRestPojo.preclose = str(result[5][j])
|
|
stockRestPojo.preclose = str(result[5][j])
|
|
stockRestPojo.roundlot = ""
|
|
stockRestPojo.roundlot = ""
|
|
- stockRestPojo.change = str(value[8])
|
|
|
|
- stockRestPojo.pctchange = str(value[9])
|
|
|
|
|
|
+ stockRestPojo.change = ""
|
|
|
|
+ stockRestPojo.pctchange = ""
|
|
stockRestPojo.volume = str(result[6][j])
|
|
stockRestPojo.volume = str(result[6][j])
|
|
stockRestPojo.amount = str(result[7][j])
|
|
stockRestPojo.amount = str(result[7][j])
|
|
stockRestPojo.volumeratio = ""
|
|
stockRestPojo.volumeratio = ""
|
|
@@ -110,10 +103,10 @@ def cstCallBack(quantdata):
|
|
|
|
|
|
datTime = ""
|
|
datTime = ""
|
|
if len(str(result[0][j])) != 6:
|
|
if len(str(result[0][j])) != 6:
|
|
- datTime = time.mktime(time.strptime("202011050" + str(result[0][j]), "%Y%m%d%H%M%S"))
|
|
|
|
|
|
+ datTime = time.mktime(time.strptime("202011060" + str(result[0][j]), "%Y%m%d%H%M%S"))
|
|
stockRestPojo.realTime = str(int(datTime))
|
|
stockRestPojo.realTime = str(int(datTime))
|
|
else:
|
|
else:
|
|
- datTime = time.mktime(time.strptime("20201105" + str(result[0][j]), "%Y%m%d%H%M%S"))
|
|
|
|
|
|
+ datTime = time.mktime(time.strptime("20201106" + str(result[0][j]), "%Y%m%d%H%M%S"))
|
|
stockRestPojo.realTime = str(int(datTime))
|
|
stockRestPojo.realTime = str(int(datTime))
|
|
|
|
|
|
min_ = time.localtime(datTime).tm_min # 获取分钟
|
|
min_ = time.localtime(datTime).tm_min # 获取分钟
|
|
@@ -190,10 +183,10 @@ try:
|
|
stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where 1 = 1 order by id asc")
|
|
stockPojoList = db.query_list("select id, code, name, list_date listDate, seralid from t_stock_base_info where 1 = 1 order by id asc")
|
|
# cst使用范例
|
|
# cst使用范例
|
|
for stockPojo in stockPojoList:
|
|
for stockPojo in stockPojoList:
|
|
- sql = "SELECT count(1) count FROM data_rt_" + stockPojo['code'].replace(".", "_").lower() + " WHERE `date` = '20201105'"
|
|
|
|
|
|
+ sql = "SELECT count(1) count FROM data_rt_" + stockPojo['code'].replace(".", "_").lower() + " WHERE `date` = '20201106'"
|
|
count = db.query_one(sql)
|
|
count = db.query_one(sql)
|
|
if int(count['count']) <= 4000:
|
|
if int(count['count']) <= 4000:
|
|
- sql1 = "delete from data_rt_" + stockPojo['code'].replace(".", "_").lower() + " where date = '20201105'"
|
|
|
|
|
|
+ sql1 = "delete from data_rt_" + stockPojo['code'].replace(".", "_").lower() + " where date = '20201106'"
|
|
db.dele(sql1)
|
|
db.dele(sql1)
|
|
data = c.cst(stockPojo['code'], 'Time,Now,High,Low,Open,PreClose,Volume,Amount,HighLimit,LowLimit,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5,ClosedTime,ClosedVolume,ClosedAmount', '093001', '150000','',cstCallBack)
|
|
data = c.cst(stockPojo['code'], 'Time,Now,High,Low,Open,PreClose,Volume,Amount,HighLimit,LowLimit,BuyPrice1,BuyPrice2,BuyPrice3,BuyPrice4,BuyPrice5,BuyVolume1,BuyVolume2,BuyVolume3,BuyVolume4,BuyVolume5,SellPrice1,SellPrice2,SellPrice3,SellPrice4,SellPrice5,SellVolume1,SellVolume2,SellVolume3,SellVolume4,SellVolume5,ClosedTime,ClosedVolume,ClosedAmount', '093001', '150000','',cstCallBack)
|
|
db.close()
|
|
db.close()
|