import eikon as ek import hug from bottle import route, run import json import pandas as pd import urllib.parse hug.API(__name__).http.output_format = hug.output_format.json # 填写路透的key key = "" @hug.get('/hz_server') def hello(): return 'ek true' @hug.get('/edbInfo/ek') def GetEdbDataFromEk(EdbCode, StartDate, EndDate): EdbCode = urllib.parse.unquote(EdbCode) print("EdbCode") print(EdbCode) print(StartDate) print(EndDate) print("req start") data = ek.get_timeseries(EdbCode, fields='*', start_date=StartDate, end_date=EndDate) print("result start") print(data) print("是否唯一索引:", data.index.is_unique) if data.index.is_unique ==False: print("开始去重") data = data.groupby(data.index).first() print("结束去重") print(data) print("result end") dataJson = data.to_json() result = json.loads(dataJson) return result if __name__ == "__main__": ek.set_app_key(key) app = __hug__.http.server() run(app=app, reloader=True, port=7002)