Time out error when downloading bonds from the govsrch

Dear community, I am trying to download bonds information data from the govsrch using the following code:
# Define the start and end dates
start_date = '2025-01-01'
end_date = '2025-06-30'
# Generate a list of dates between the start and end dates
date_range = pd.date_range(start=start_date, end=end_date)
# Convert to a list of strings if needed
date_list_as_strings = [date.strftime('%Y-%m-%d') for date in date_range]
rd.get_config()["http.request-timeout"] = 400
rd.open_session() df_tot = [] for t in date_list_as_strings:
response = search.Definition(
view = search.Views.GOV_CORP_INSTRUMENTS,
top = 10000,
filter = "((DbType eq 'CORP') and RCSAssetCategory eq 'A:J' and ((IssueDate ge "+t+" and IssueDate le "+t+")))",
navigators = "IssueDate(calc:sum_FaceIssuedUSD,calc:sum_FaceOutstandingUSD,calc:sum_FaceIssuedTotal,type:histogram,buckets:100)",
select = "IssuerOrgid,RIC,EJVAssetID,DTSubjectName,BusinessEntity,PI,FaceIssuedUSD,""FaceOutstandingUSD,IssueDate,CouponRate,MaturityDate,ISIN,RCSDomicileLeaf,RCSCountryOfIncorporationLeaf,DBSTicker,RCSDomicileGenealogy""IsESGBond,KPITypeDescription,IsGreenBond,MaturityStandardYield,InstrumentTypeDescription,IssuePrice,FaceIssuedTotal,CouponFrequencyDescription,RCSCurrencyLeaf""RCSBondGradeLeaf,RCSCoveredBondGenealogy,IsCallable,IsPutable,RCSUseOfProceedsLeaf,RCSCurrencyLeaf"
).get_data()
df=response.data.df
if t == start_date:
df_tot = df
else: df_tot = df_tot.append(df)
print(t)
df_tot.shape[0]
but I am getting the error:
An error occurred while requesting URL('http://localhost:9000/api/rdp/discovery/search/v1/').ReadTimeout('timed out')
This error pops out not always at the same "t" when I relaunch the code.
Can anyone help me?
Thanks!
Answers
-
Hello @Giacomo_C
I think you might be hitting the rate limits as described in the Reference document for the search API. Running a complex search filter for every day in a date range might be causing this. You can try to optimize the query and reduce the number of calls and also pace out each successive call.
To get help with formulating a search query, please raise a content ticket at LSEG MyAccount.
0 -
Thank you Gurpreet,
I added a sleep time of 5' and it seems to be working now.
Do you know how can I except the timeout error?
Thanks again
0 -
You can use the try/except command to catch the exception. For example:
try: response = search.Definition( view = search.Views.EQUITY_QUOTES, filter = "AssetType eq 'EQUITY' and RCSAssetClass eq 'ORD' and IsPrimaryIssueRIC eq true", select = "DocumentTitle, RIC, AssetState", top=10000 ).get_data() response.data.df except Exception as ex: print("Exception: "+str(ex))
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 37 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 697 Datastream
- 1.5K DSS
- 632 Eikon COM
- 5.2K Eikon Data APIs
- 12 Electronic Trading
- 1 Generic FIX
- 7 Local Bank Node API
- 4 Trading API
- 2.9K Elektron
- 1.4K EMA
- 256 ETA
- 563 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
- 25 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 281 Open PermID
- 46 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 23 RDMS
- 2K Refinitiv Data Platform
- 749 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
- 123 Open DACS
- 1.1K RFA
- 107 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 中文论坛