|
@@ -3,11 +3,7 @@ from bottle import route, run, NORUN
|
|
|
from WindPy import w
|
|
|
import json
|
|
|
import pandas as pd
|
|
|
-import time
|
|
|
import os
|
|
|
-import sys
|
|
|
-from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
-import time
|
|
|
|
|
|
hug.API(__name__).http.output_format = hug.output_format.json
|
|
|
|
|
@@ -33,17 +29,14 @@ def GetEdbDataByWind(EdbCode, StartDate, EndDate):
|
|
|
|
|
|
print("getdata")
|
|
|
option = "Fill=Previous"
|
|
|
-
|
|
|
+
|
|
|
data = w.edb(EdbCode, StartDate, EndDate, option)
|
|
|
print("wind data")
|
|
|
print(data)
|
|
|
df = pd.DataFrame()
|
|
|
- if data.ErrorCode != 0: # Internet Timeout 超时退出
|
|
|
- os._exit(0)
|
|
|
- return "a"
|
|
|
- if data.ErrorCode != 0: # corrupted response. 错误响应也重启
|
|
|
+ if data.ErrorCode != 0 and data.ErrorCode != -40522017: # corrupted response. 如果不是提示超限,同时也不是正常返回,那么就退出
|
|
|
os._exit(0)
|
|
|
- return "b"
|
|
|
+ return "c"
|
|
|
df['DT'] = data.Times
|
|
|
df['CLOSE'] = data.Data[0]
|
|
|
df['ErrorCode'] = data.ErrorCode
|
|
@@ -57,7 +50,7 @@ def GetEdbDataByWind(EdbCode, StartDate, EndDate):
|
|
|
|
|
|
|
|
|
@hug.get('/edbInfo/wind/wsd')
|
|
|
-def GetEdbDataWindWsd(StockCode, EdbCode, StartDate, EndDate):
|
|
|
+def GetEdbDataWindWsd(StockCode, EdbCode, StartDate, EndDate, Days="", Period="", PriceAdj=""):
|
|
|
print("GetEdbDataByWind:", EdbCode)
|
|
|
isConnected = w.isconnected()
|
|
|
print("isconnected")
|
|
@@ -69,7 +62,15 @@ def GetEdbDataWindWsd(StockCode, EdbCode, StartDate, EndDate):
|
|
|
if isConnected == False:
|
|
|
return "{'ErrMsg':'启动Wind接口失败'}"
|
|
|
|
|
|
- option = "Fill=Previous"
|
|
|
+ options = ["Fill=Previous"]
|
|
|
+ if Days:
|
|
|
+ options.append(f"Days={Days}")
|
|
|
+ if Period:
|
|
|
+ options.append(f"Period={Period}")
|
|
|
+ if PriceAdj:
|
|
|
+ options.append(f"PriceAdj={PriceAdj}")
|
|
|
+ option = ";".join(options)
|
|
|
+ print(option)
|
|
|
wsd_data = w.wsd(StockCode, EdbCode, StartDate, EndDate, option)
|
|
|
|
|
|
if wsd_data.ErrorCode != 0: # Internet Timeout 超时退出
|
|
@@ -81,6 +82,7 @@ def GetEdbDataWindWsd(StockCode, EdbCode, StartDate, EndDate):
|
|
|
result = json.loads(json_data)
|
|
|
return result
|
|
|
|
|
|
+
|
|
|
# def check_wind_status():
|
|
|
# print("check wind login status")
|
|
|
# # wind 登录
|
|
@@ -107,6 +109,6 @@ if __name__ == "__main__":
|
|
|
if wStart.ErrorCode != 0:
|
|
|
print("启动万得API接口失败")
|
|
|
os._exit(0)
|
|
|
-
|
|
|
+
|
|
|
app = __hug__.http.server()
|
|
|
run(app=app, reloader=True, host='0.0.0.0', port=7000)
|