how to convert rics or symbols to mnem for dsws?
hi,
I am trying to retrieve historical price data for a list of instruments with python Eikon and datastream. My dynamic list of instruments come from Eikon port
TotalList=(['Portfolio(0867/*Total List*/)'])
dataset, err=ek.get_data(TotalList,['tr.PriceClose'])
rics1 =pd.DataFrame(dataset.loc[:1,'Instrument'])
rics2 = rics1["Instrument"]
rics3 = rics2.tolist()
How do I convert the list of symbols to a list of mnemonics so that I can pass it through to a datastream query?:
ds=dsws.Datastream(username=xxxxxxxxxxxxxx,password='xx')
df=ds.get_data (tickers='mnemonics',
fields=['P'], start='2018-01-01', end='2018-01-10', freq='D')
Many thanks
Best Answer
-
According to the function signature, the tickers argument of get_data method of dsws library cannot be a list. It must be a string of comma separated symbols. Try
df, err = ek.get_data('Portfolio(SAMPLE_RU_LRGCORE)',['TR.CommonName'])
df['DatastreamRICs'] = '<' + df['Instrument'] + '>'
ds_rics_str = df['DatastreamRICs'].str.cat(sep=',')
ds.get_data(ds_rics_str, fields=['P'],
start='2018-01-01', end='2018-01-10', freq='D')Note that the max number of symbols for get_data method of dsws library is 50. If your portfolio has more than 50 constituents, you need to split it into chunks of 50.
0
Answers
-
You don't need to convert RICs to Datastream mnemonics. You can use RICs in get_data method of DSWS library by enclosing each RIC into angle brackets, e.g.
ds.get_data('<MSFT.O>,<AAPL.O>,<IBM.N>', fields=['P'],
start='2018-01-01', end='2018-01-10', freq='D')0 -
Hi Alex,
thanks for the input!
Obviously new to this and still doing something wrong:
TotalList=(['Portfolio(500867312/*Total List*/)'])
dataset, err=ek.get_data(TotalAssetList,['tr.PriceClose'])
rics1 =pd.DataFrame(dataset.loc[:,'Instrument'])
rics1["Instrument"]='<'+rics1+'>'
rics2 = rics1["Instrument"]
rics3 = rics2.tolist()
df=ds.get_data (tickers=rics3,
fields=['ER#S'], start='2018-01-01', end='2018-01-10', freq='D')
print(df)get_data : Exception Occured
(<class 'AttributeError'>, AttributeError("'list' object has no attribute 'rfind'"), <traceback object at 0x00000190C20DC3C0>)
0 -
again, that worked well (for my equity dataset), thanks!
However I'm also trying to retrieve historical pricing for a number of fixed income instruments that have matured. so I'm using
fields =['TRPA']
which does not work with "<RICs>". Is there another workaround for converting RICs to Datastream mnemonics (or is this another misunderstanding?)?
0 -
I'm not sure I understand the scenario. Matured bonds don't have RICs. RICs for instruments that become inactive are removed from Refinitiv Real-Time network. If you have ISIN for the bond, you can use it to retrieve price history for that bond from Datastream, e.g.
ds.get_data('XS1035001921', fields=['MPD'],
start='2019-03-01', end='2019-04-01')Note that in the above example I used ISIN for a bond that matured on 2019-04-18.
And if for whatever reason you need Datastream mnemonic for this bond, you can get it using
ds.get_data('XS1035001921', fields=['MNEM'], kind=0)
0 -
thanks, had just realised that ISIN will provide data needed!
0
Categories
- All Categories
- 6 AHS
- 39 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛