|
@@ -6,17 +6,16 @@ import time
|
|
|
|
|
|
hug.API(__name__).http.output_format = hug.output_format.json
|
|
|
|
|
|
-username = "账号"
|
|
|
-password = "密码"
|
|
|
+username = ""
|
|
|
+password = ""
|
|
|
|
|
|
@hug.get('/hz_server')
|
|
|
def hello():
|
|
|
return 1
|
|
|
# return 'wind true'
|
|
|
|
|
|
-
|
|
|
# 同花顺登录函数
|
|
|
-def thslogindemo():
|
|
|
+def thslogin():
|
|
|
# 输入用户的帐号和密码
|
|
|
thsLogin = THS.THS_iFinDLogin(username, password)
|
|
|
print(thsLogin)
|
|
@@ -29,8 +28,10 @@ def thslogindemo():
|
|
|
@hug.get('/edbInfo/ths')
|
|
|
def GetEdbDataByThs(EdbCode, StartDate, EndDate):
|
|
|
print("GetEdbDataByThs")
|
|
|
- thsLogin = THS.THS_iFinDLogin(username, password)
|
|
|
thsEDBDataQuery = THS.THS_EDBQuery(EdbCode, StartDate, EndDate, True)
|
|
|
+ print(thsEDBDataQuery)
|
|
|
+
|
|
|
+
|
|
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":start GetEdbDataByThs")
|
|
|
print("thsEDBDataQuery")
|
|
|
print(thsEDBDataQuery)
|
|
@@ -38,13 +39,23 @@ def GetEdbDataByThs(EdbCode, StartDate, EndDate):
|
|
|
|
|
|
result = json.loads(thsEDBDataQuery)
|
|
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":end GetEdbDataByThs")
|
|
|
+
|
|
|
+ if result["errorcode"]==-1010:
|
|
|
+ thsLogin = THS.THS_iFinDLogin(username, password)
|
|
|
+ print("登录一次")
|
|
|
+ print(thsLogin)
|
|
|
+ if (thsLogin == 0 or thsLogin == -201):
|
|
|
+ thsEDBDataQuery = THS.THS_EDBQuery(EdbCode, StartDate, EndDate, True)
|
|
|
+ thsEDBDataQuery = thsEDBDataQuery.decode("unicode_escape")
|
|
|
+ result = json.loads(thsEDBDataQuery)
|
|
|
+ else:
|
|
|
+ print("已登录")
|
|
|
+
|
|
|
return result
|
|
|
|
|
|
@hug.get('/edbInfo/ths/future_good')
|
|
|
def GetFutureGoodEdbDataByThs(EdbCode, StartDate, EndDate):
|
|
|
print("THS_HistoryQuotes start")
|
|
|
- thsLogin = THS.THS_iFinDLogin(username, password)
|
|
|
-
|
|
|
filed = 'lastclose,open,high,low,close,avgprice,change,changeper,volume,amount,hsl,lastsettlement,settlement,zdsettlement,zdfsettlement,ccl,ccbd,zf,zjlx,zjcd'
|
|
|
# filed = 'open,high,low,close,volume,amount,settlement,ccl,zjlx'
|
|
|
params = 'Interval:D,CPS:1,baseDate:1900-01-01,Currency:YSHB,fill:Previous'
|
|
@@ -58,6 +69,16 @@ def GetFutureGoodEdbDataByThs(EdbCode, StartDate, EndDate):
|
|
|
print(thsEDBDataQuery)
|
|
|
thsEDBDataQuery = thsEDBDataQuery.decode("unicode_escape")
|
|
|
result = json.loads(thsEDBDataQuery)
|
|
|
+ if result["errorcode"]==-1010:
|
|
|
+ thsLogin = THS.THS_iFinDLogin(username, password)
|
|
|
+ print("登录一次")
|
|
|
+ print(thsLogin)
|
|
|
+ if (thsLogin == 0 or thsLogin == -201):
|
|
|
+ thsEDBDataQuery = THS.THS_HistoryQuotes(EdbCode, filed, params, StartDate, EndDate, True)
|
|
|
+ thsEDBDataQuery = thsEDBDataQuery.decode("unicode_escape")
|
|
|
+ result = json.loads(thsEDBDataQuery)
|
|
|
+ else:
|
|
|
+ print("已登录")
|
|
|
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ":end GetFutureGoodEdbDataByThs")
|
|
|
return result
|
|
|
|
|
@@ -105,6 +126,6 @@ def GetEdbDataByThsDs(StockCode, EdbCode, StartDate, EndDate):
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
# ths登录函数
|
|
|
- thslogindemo()
|
|
|
+ thslogin()
|
|
|
app = __hug__.http.server()
|
|
|
run(app=app, reloader=True, port=7000)
|