Convert python code to ‘import eikon as ek’
Hi Team,
Can you help me to use eikon api and use the command ‘import eikon as ek’ to import the code below?
import refinitiv.data as rd
rd.open_session()
rd.get_history(
universe='CBF24^2',
fields=["SETTLE"],
count=1,
)
Could you please provide the code that can be used through eikon package?
For some reason, seems "count" is not being recognized. Please advise. Thank you!
Best Answer
-
Hi @Mark Lucio ,
As the error message suggest the issue is with requested range. Since the instrument expired on Jan, 2024 and the function by default returns values for more recent periods, you get the error. Please consider adding start and end dates. I also removed count parameter to see the whole series:
ek.get_timeseries(
rics=['CBF24^2'],
fields=["CLOSE"],
interval="daily",
start_date='2022-01-01',
end_date='2024-01-01'
)Hope this helps.
Best regards,
Haykaz
0
Answers
-
Hi @Mark Lucio ,
Could you detail why "count" is not being recognized ? Do you have any error ?
On my side, same code returns this result:
CBF24^2 SETTLE
Date
2024-01-31 262.94Note that refinitiv-data library is meant to replace eikon, but for those who want to continue using it, it is included and can be used like this:
from refinitiv.data import eikon as ek
r1 = ek.get_data(...)
r2 = ek.get_timeseries(...)
...But with rd.get_history(), you can request much more fields than ek.get_timeseries()
0 -
Hi @pf, thank you for your assistance. Using the Python code above, it works fine.
However, since the client needs ‘import eikon as ek’, I am not certain how to convert the above code to ‘import eikon as ek’.
I tried to use:import refinitiv.dataplatform.eikon as ek
import datetime
ek.set_app_key('DEFAULT_CODE_BOOK_APP_KEY')
ek.get_timeseries(['CBF24^2'],
fields=["close"],
count=1,
interval="daily"
)
but it is showing error:Error with CBF24^2: No data available for the requested date range
CBF24^2: No data available for the requested date range |0 -
Hi @aramyan.h, thank you for your assistance as well. I will try to share this to client. Would you know if we can only see the last value instead of showing it as a timeseries?
This is the reason why we use the count=1 to only display one value. This is the equivalent of nbrows in Excel. I am looking for the code where the client do not need to indicate the start and end date which will show him/her the last value of these expired futures.
0 -
Hi @Mark Lucio ,
The best would have been to use ek.get_data for that scenario:
df, err = ek.get_data(instruments='CBF24^2', fields='CF_LAST')
dfHowever, this resulst in NA and the reason why can be checked by raising a content query via my.refinitiv.com
As a workaround I would suggest using get_timeseries but provide only a valid start_date and then pick the last value of the output:
df = ek.get_timeseries(
rics=['CBF24^2'],
fields=["CLOSE"],
interval="daily",
start_date='2020-01-01',
)
df['CLOSE'][-1]0 -
thank you @aramyan.h, will suggest this.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 中文论坛