Tring to access fields via Datastream, Unknown error:

Context: I have a tickerlist which is defined like :
"CN:QJCH,CN:WAPH,III,U:MMM,DK:DSA,DK:DSB,K:AACA,W:SAGB,IN:AB,S:ABBN, and so on…. about 3200 tickers
all_batches_gmrgn1 = []
batch_size = 5
field_list1 = [
"GRM1MN", "GRM2MN", "GRM3MN",
"X(IBP)/X(BPS1MN)", "X(IBP)/X(BPS2MN)", "X(IBP)/X(BPS3MN)",
"X(EVT1MN)/X(SAL1MN)", "X(EVT2MN)/X(SAL2MN)", "X(EVT3MN)/X(SAL3MN)",
"X(IBP)/X(EPS1MN)", "X(IBP)/X(EPS2MN)", "X(IBP)/X(EPS3MN)",
"X(DPS1MN)/X(IBP)*100.00", "X(DPS2MN)/X(IBP)*100.00", "X(DPS3MN)/X(IBP)*100.00",
"ROE1MN", "ROE2MN", "ROE3MN"
]
total_batches = len(tickerlist) / batch_size
for i in range(0, len(tickerlist), batch_size):
batch_number = i // batch_size + 1
batch_list = tickerlist[i:i + batch_size]
batch_str = ", ".join(batch_list)
batch_str_quoted = f'"{batch_str}"'
try:
df = ds.get_data(
tickers=batch_str_quoted,
fields=field_list1,
kind=0
)
df.drop('Currency', axis=1, inplace=True, errors='ignore')
all_batches_gmrgn1.append(df)
print(f" Processed batch {batch_number} out of {total_batches}")
except Exception as e:
print(f" Error in batch {batch_number} out of {total_batches}: {e}")
gmrgn1_combined = pd.concat(all_batches_gmrgn1)
gmrgn1_combined
Output received is: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
"CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM1MN | Index was out of range. Must be non-negative a... | |
---|---|---|---|
1 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM2MN | Index was out of range. Must be non-negative a... |
2 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | GRM3MN | Index was out of range. Must be non-negative a... |
3 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | X(IBP)/X(BPS1MN) | Index was out of range. Must be non-negative a... |
4 | "CN:QJCH, CN:WAPH, III, U:MMM, DK:DSA" | X(IBP)/X(BPS2MN) | Index was out of range. Must be non-negative a... |
Can You please check why
Answers
-
Thank you for reaching out to us.
It could be this code:
batch_str_quoted = f'"{batch_str}"'
It doesn't require to add quotes to the batch_str. You can directly assign the batch_str to the tickers parameter.
for i in range(0, len(tickerlist), batch_size): batch_number = i // batch_size + 1 batch_list = tickerlist[i:i + batch_size] batch_str = ",".join(batch_list) try: df = ds.get_data( tickers=batch_str, fields=field_list1, kind=0 )
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 48 Data Fusion
- 34 Data Model Discovery
- 689 Datastream
- 1.4K DSS
- 627 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
- 278 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 706 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
- 96 Workspace SDK
- 11 Element Framework
- 5 Grid
- 19 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛