How to retrieve a sum of fields with RDP API?
As in Excel I want to get data for the following formula in Excel:
AVAIL(TR.CashAndSTInvestments,TR.CashandEquivalents+TR.Cash+TR.STInvestments)
I tried this jupyter notebook:
currency = "EUR"
bs_fields = ["AVAIL(""TR.CashAndSTInvestments"",""TR.CashandEquivalents""+""TR.Cash""+""TR.STInvestments"")"]
as_of_date = "2023-06-30"
freq = "FY"
period = "FY0, FY-2"
bs_result = fundamental_and_reference.Definition(
universe = ric_liste,
fields = bs_fields,
parameters = {"Scale": 6, "SDate": as_of_date, "Period": period, \
"FRQ": freq, "Curn": currency, "IncludePartial": "No"}
).get_data()
bs_result.data.df
I get the error:
Error code 234 | The 'TR.Cash' is unexpected in formula. A delimiter is probably missing before the lexeme.
I had tried only the "AVAIL"-function with two fields and it works with double ".
But in combination with the addition it doesn't work.
How can I get the result as requested?
Best Answer
-
Thank you for reaching out to us.
As I know, the fundamental_and_reference services on the desktop and RDP sessions are different.
The code that works on the desktop session may not work on the RDP session.
In stead of relying on the AVAIL function, you can do it in Python code.
For example:
currency = "EUR"
bs_fields = ["TR.CashAndSTInvestments","TR.CashandEquivalents","TR.Cash","TR.STInvestments"]
as_of_date = "2023-06-30"
freq = "FY"
period = "FY0, FY-2"
bs_result = fundamental_and_reference.Definition(
universe = ric_liste,
fields = bs_fields,
parameters = {"Scale": 6, "SDate": as_of_date, "Period": period, \
"FRQ": freq, "Curn": currency, "IncludePartial": "No"}
).get_data()
df1 = bs_result.data.df
df1["Cash and Equivalents"] = df1["Cash and Equivalents"].fillna(0)
df1["Cash"] = df1["Cash"].fillna(0)
df1["Short Term Investments"] = df1["Short Term Investments"].fillna(0)
df1["AVAIL_CASH"] = np.where(
df1['Cash and Short Term Investments'].isnull(),
df1['Cash and Equivalents']+df1['Cash']+df1['Short Term Investments'],
df1['Cash and Short Term Investments'])
df1The output is:
1
Answers
-
Hi @torben1 ,
I used the code you provided and can retrieve the data properly, could you please provide RICs you've used for further investigation.
currency = "EUR"
bs_fields = ["AVAIL(""TR.CashAndSTInvestments"",""TR.CashandEquivalents""+""TR.Cash""+""TR.STInvestments"")"]
ric_liste = ["GOOG.O", "AAPL.O"]
as_of_date = "2023-06-30"
freq = "FY"
period = "FY0, FY-2
bs_result = fundamental_and_reference.Definition(
universe = ric_liste,
fields = bs_fields,
parameters = {"Scale": 6, "SDate": as_of_date, "Period": period, \
"FRQ": freq, "Curn": currency, "IncludePartial": "No"}
).get_data()
bs_result.data.df0 -
The ric_liste is created as follows:
response = fundamental_and_reference.Definition(
["0#.STOXX"],
["TR.CompanyName", "TR.CompanyMarketCap"]
).get_data()
company0 = response.data.df
ric_liste = company0["Instrument"].tolist()
ric_liste = sorted(ric_liste)
0 -
@torben1
What is the RD session you are using?
I tested the code and it works fine with the desktop.workspace session.
0 -
I use the platform.rdp session.
0 -
Thank You for the solution. It works as described.
I understand that one has to retrieve all components of the sum and for the "Avail"-function one should make a separate column.
Thank you also for the python-solution for "ZAV" via "fillna(0)". It is the answer to another question I had put in this forum.
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 中文论坛