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:
0
Answers
-
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
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 629 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 86 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛