Eikon API - AsynclibraryNotFoundError
when we use Eikon API, it shows the error message. Please tell us the cause of this error, thanks.
Best Answer
-
Hi @xuke ,
Thank you for reaching out to us.
I don't reproduced your issue but found where this exception is raised in httpx dependency.
We need more information on your script and how eikon lib is used so could you share your code (without any personal id, login or password) ?
Could you also provide which Python version you're using and check eikon + httpx versions with this code?
import eikon
import httpx
print(httpx.__version__)
print(eikon.__version__)On your side, you can test following code to check if it's failing too (it should run without error):
import asyncio
from sniffio import current_async_library
async def print_lib():
library = current_async_library()
print("This is the current async lib: ", library)
asyncio.run(print_lib())0
Answers
-
def get_stock_commodity_code(request):
success = True
val = json.loads(request.body)
code = val.get("code")
date = val.get("date")
return_dict = {'return_code': '200', 'return_info': 'success', 'result': False}
set_rv_app_key()
try:
rd.open_session()
df = rd.discovery.search(
view=rd.discovery.Views.SEARCH_ALL,
top=1,
# filter="LocalFundCode in ('006038' '012728')",
filter="TickerSymbol eq '" + code + "' and ExpiryDateString eq '" + date + "' and DerivedCategory eq 'Future'",
select="DocumentTitle,RIC"
)
except Exception as result:
errorMsg = str(result)
loggers.error("get commodity info exception: " + str(result))
success = False
if success:
df.columns = ['instrument', 'ricCode']
result_data = df.to_json()
loggers.info("get commodity info response: " + result_data)
# data.to_excel("C:\\dpp\\refinitive\\test\\stock.xlsx", sheet_name='Sheet1', index=False)
return_dict['result'] = json.loads(result_data)
else:
return_dict['return_code'] = 500
return_dict['return_info'] = errorMsg
return_dict['result'] = {}
return HttpResponse(json.dumps(return_dict), content_type="application/json")0 -
First of all, I didn't see that an error is logged before the AsynciolibraryNotFoundError !
In previous lines, you should have some information similar to :[2024-01-18 18:16:25,071;s] - [INFO] - [log] - Send GET request to http://127.0.0.1:9060/api/status to detect API Proxy...
[2024-01-18 18:16:25,071;s] - [DEBUG] - [log] - Request to http://127.0.0.1:9060/api/status
....Could you share it ? (take care to remove your app key).
Note that you'll find tips and tricks to check your environment (especially if Eikon API proxy is available) in Troubleshooting Userguide.About your code, I reformat it:
def get_stock_commodity_code(request):
success = True
val = json.loads(request.body)
code = val.get("code")
date = val.get("date")
return_dict = {"return_code": "200", "return_info": "success", "result": False}
set_rv_app_key()
try:
rd.open_session()
df = rd.discovery.search(
view=rd.discovery.Views.SEARCH_ALL,
top=1,
# filter="LocalFundCode in ('006038' '012728')",
filter="TickerSymbol eq '"
+ code
+ "' and ExpiryDateString eq '"
+ date
+ "' and DerivedCategory eq 'Future'",
select="DocumentTitle,RIC",
)
except Exception as result:
errorMsg = str(result)
loggers.error("get commodity info exception: " + str(result))
success = False
if success:
df.columns = ["instrument", "ricCode"]
result_data = df.to_json()
loggers.info("get commodity info response: " + result_data)
# data.to_excel("C:\\dpp\\refinitive\\test\\stock.xlsx", sheet_name='Sheet1', index=False)
return_dict["result"] = json.loads(result_data)
else:
return_dict["return_code"] = 500
return_dict["return_info"] = errorMsg
return_dict["result"] = {}
return HttpResponse(json.dumps(return_dict), content_type="application/jsonMy feedbacks:
- you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.
- set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:
Is this correct or are the logs out of order? - The context of calling get_stock_commodity_code() could cause the error.
Is there any specific multi-threaded or multi-processed design?
0 -
we will try to run program with this advises
you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.
set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:
Is this correct or are the logs out of order?
0 -
we will try to run program with this advises
you should manage the rd.open_session() on initializing your application, and close it (rd.close_session()) on closing your application.
set_rv_app_key() is called before rd.open_session() but according to your initial log, it's the inverse:Is this correct or are the logs out of order?0 -
I noticed that during initialization, the initial steps are failing.
Could you verify that your Eikon product is allowed for Python usage. In Help>About Refinitiv Eikon, APPS tab, you should find REFINITIVHOLDINGS.EIKON.DATAAPIPROXY app:
Then test http://localhost:9060/api/status to verify if the Data API Proxy was started successfully:
0 -
this is right
0 -
Your versions arn't recent:
- Eikon 3.3.11
- DATA API PROXY 1.9.0.0
It could explain why it's failing.
Did it work before ?You should contact your Account Manager to upgrade to Eikon 3.6.6 (it contains API Proxy 1.10.0.0).
0 -
@pf Thanks for your advice. We connect the support hotline, but failed to upgrade from Eikon 3.3.11 (Data API Proxy 1.9.0.0) to Eikon 3.6.6 (Data API Proxy 1.10.0.0).
Below information for your reference.
Steps Done:
Eikon had been uninstalled and reinstalled by PC Admin.
1. Ended Excel, Word, PPT and Eikon processes.
2. Uninstalled the obsolete version of Eikon from Windows Control Panel > Programs and Features.
3. Downloaded the latest version Eikon 4.0.64, installed Eikon 4.0.64 and VBA71 one by one with PC Admin.
4. Logged in Eikon 4.0.64 successfully.
Checked the Data API Proxy version: it was showing Eikon 3.3.11 (Data API Proxy 1.9.0.0), failed to upgrade.
5. Referred to below link, tried the steps, the version still at Eikon 3.3.11 (Data API Proxy 1.9.0.0).0 -
Hi @xuke ,
Have you tried restart the machine and check the data API proxy version again? Some process of the proxy might not ended properly previously.
0 -
Hi Raksina,
Yes, already restart the machine. but the data API proxy version is still
{"statusCode":"ST_PROXY_READY","version":"3.3.11-eikon4"}
0 -
Hi @xuke ,
Thank you for your patience, could you please let me know if you're able to run the code properly?
And I'd like to confirm which Python library are you using? as in your code, seem like the 'rd' is being used.
Are you using the Refinitiv Data Library for Python
import refinitiv.data as rd
import eikon as ek
If it's the first one, could you please let me know which version of the data library you're using with the code below?
print(rd.__version__)
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛