A python program that tries to access the eikon api does not return a result. It will only work if you restart the service, but it may be hours later when you try to access the api
log:
[INFO:2023-10-07 09:46:39,467] web.views views.py:944:get bond dirty price request: {'code': ['JPYCNY=R'], 'endDate': '2023-07-31', 'interval': 'daily', 'startDate': '2023-07-28'}
[INFO:2023-10-07 09:46:39,467] web.views views.py:23:set_rv_app_key: 4b45e9df491c43af8266bde1e96d1e94692ae941
[INFO:2023-10-07 09:46:39,469] pyeikon session.py:378:Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...
code:
def get_exchange_rate_history_price(request):
success = True
val = json.loads(request.body)
loggers.info("get bond dirty price request: " + str(val))
code = val.get("code")
startDate = val.get("startDate")
endDate = val.get("endDate")
return_dict = {'return_code': '200', 'return_info': 'success', 'result': False}
set_rv_app_key()
rd.open_session()
# response = bond.Definition(
# instrument_code="CND100063XD1",
# fields=['DirtyPrice'],
# pricing_parameters=bond.PricingParameters(
# market_data_date="2023-05-05")).get_data()
try:
df = ek.get_timeseries(code,
# fields=["OPEN", "CLOSE"],
start_date=startDate,
end_date=endDate,
interval='daily',
calendar=None,
corax=None,
normalize=False,
raw_output=True)
except Exception as result:
errorMsg = str(result)
loggers.error("get bond dirty price exception: " + str(result))
success = False
if success:
print(df)
# print(df.keys())
# print(df.values())
dflist = list(df.values())
# print(dflist[0])
newList = dflist[0]
for dt in newList:
print(dt)
if (dt['statusCode'] == 'Error'):
newList.remove(dt)
print(newList)
#
# print(dflist[0][0])
# obj1 = dflist[0][0]
# print(obj1['dataPoints'])
# data_dict = ["timeseriesData", newList]
# print(dflist.get(0))
# numy = df.to_json()
# loggers.info("get stock info response: " + numy)
# data.to_excel("C:\\dpp\\refinitive\\test\\stock.xlsx", sheet_name='Sheet1', index=False)
# return_dict['result'] = json.loads(numy)
# return_dict['result'] = json.loads(json.dumps(newList))
return_dict['result'] = json.loads(json.dumps(df))
else:
return_dict['return_code'] = 500
return_dict['return_info'] = errorMsg
return_dict['result'] = {}
return HttpResponse(json.dumps(return_dict), content_type="application/json")
pls help me solve this problem