Date arguments in datastream call

Hi,
I'm new to datastream and have the below two python calls. The first calculates the return over the period in the field brackets and the second is a daily return series of S&P 500.
OneYear=ds.get_data(tickers=Ticker_list, fields=['PCH#(X(RI),6-30-20,6-30-21)'], kind = 0)
Return_Series=ds.get_data (tickers='S&PCOMP', fields=['PCH#(X(RI),-1D)','RI'], start='-4Q', end='-1Q', kind=1)
I have a couple questions.
1) I got some help from the helpdesk on these, but what is the difference between the two formats (other than the dates are within the field argument in the OneYear example) and under what circumstances would I use one option vs. the other?
2) Related to question 1), how can i specify a variable for the date argument in these examples (e.g., if i have an "end_date" variable? I tried entering that in the end field in the Return_Series example but it didn't seem to work.
3) Are there any training resources where I should check for these types of answers?
Thanks very much.
Best Answer
-
Yes, you can. However, from the usage guide, the date formats are different.
The data format of the PCH expression is DD/MM/YY while the data format of the start and end parameters in the get_data method is YYYY-MM-DD.
The code looks like this:
start_date_qtr = '2021-03-31'
end_date = '2021-06-30'
start_date_pch = '31/03/21'
end_date_pch = '30/06/21'
fields = "PCH#(X(RI),{},{})".format(start_date_pch, end_date_pch)
OneYear=ds.get_data(tickers='S&PCOMP', fields=[fields], kind = 0)
Return_Series=ds.get_data (tickers='S&PCOMP', fields=['PCH#(X(RI),-1D)','RI'], start=start_date_qtr, end=end_date, kind=1)0
Answers
-
Refer to the PCH expression's usage guide, "PCH#(Expression,Start Date,End Date)" calculates a single percentage change in value between two dates so it uses the data on the start date and the end date to calculate a percentage change.
"PCH#(Expression,Period)" calculates the percentage change for a time period continuously between the start and end dates for the display period.
0 -
Great, thanks very much. What about question 2)? Is it possible to include variables in the date arguments for either (both) functions ?
Something like the below?
OneYear=ds.get_data(tickers=Ticker_list, fields=['PCH#(X(RI),start_date_qtr,end_date)'], kind = 0)
Return_Series=ds.get_data (tickers='S&PCOMP', fields=['PCH#(X(RI),-1D)','RI'], start=start_date_qtr, end=end_date, kind=1)
where start_date_qtr = '3-31-21' and end_date = '6-30-21'
0 -
Great, thank you. Last question on this tag I think. Is there a way within the get_data call to only display trade dates (i.e., exclude holidays)?
For example, when i run the aforementioned time series for Q2 (March 31, 2021-June 30, 2021), I notice that April 2, 2021 comes up as having zero as return value and the same RI as April 1, 2021 (because April 2, 2021 was Good Friday and the market was closed). Can i exclude holidays within the function or do i have to take care of this with python functions? Thanks.
0 -
Hi, does anybody know the answer to my question on excluding holidays? Thanks!
0 -
The answer has been provided on0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 690 Datastream
- 1.4K DSS
- 629 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 559 WebSocket API
- 39 FX Venues
- 15 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 24 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 279 Open PermID
- 45 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 713 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
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 106 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 95 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛