Hi Team
We are receiving issue while fetching data from LSEG Worspace API while the similar code is working fine in Eikon. Please check provide the solution as soon as possible
CODE:-
import refinitiv.data as rd
from refinitiv.data.discovery import Screener
from refinitiv.data.content import search
from datetime import datetime, timedelta
import pandas as pd
from refinitiv.data.discovery import (
convert_symbols,
SymbolTypes
)
#deals_fields = ['TR.NIDealID','TR.NISdcPackageNumber','TR.NIMasterDealType.code',"TR.NIAllManagersRole(Concat='|').code","TR.NIManagersRole(Concat='|').code",'TR.NIIssueDate()','TR.NIIssuer','TR.NIIssuerPermId',"R.NIIssueType(Concat='|')",'TR.NITransactionStatus','TR.NIIssuerNation','TR.NICurrentFilingDate','TR.NIOfferPrice',"TR.NIProceedsAmtInclOverallotSoldAllMkts(Scale=6)","TR.NIIssuerExchTicker(Concat='|')",'TR.NISecurityTypeAllMkt',"TR.NIOfferingTechnique(Concat='|')","TR.NIGrossSpreadAsPctOfPrincipalAmtThisMktPrint","TR.NIIssuerDomicileSubRegion",'TR.NIIssuerDomicileRegion','TR.NIIssuerTRBCBusinessSector','TR.NIIssuerTRBCEcoSec',"TR.NILeadLeftBookrunner(Concat='|')","TR.NIBookOrCoManager(Concat='|')","TR.NIParentBookOrCoManager(IncludeNull=True,Concat='|')","TR.NIAllManagers(IncludeNull=True,Concat='|')","TR.NILeadManagers(IncludeNull=True,Concat='|')","TR.NIParentLeadManagers(IncludeNull=True,Concat='|')","TR.NIISINAtOffer(Concat='|')","TR.NIIssuerCusip9(Concat='|')","TR.NIIssuerSEDOL","TR.NIPrimaryTickerSymbol(IncludeNull=True,Concat='|')"]
deals_fields = ['TR.NIDealID','TR.NISdcPackageNumber','TR.NIMasterDealType.code',"TR.NIAllManagersRole(Concat='|').code","TR.NIManagersRole(Concat='|').code",'TR.NIIssueDate()','TR.NIIssuer','TR.NIIssuerPermId',"R.NIIssueType(Concat='|')",'TR.NITransactionStatus','TR.NIIssuerNation','TR.NICurrentFilingDate','TR.NIOfferPrice',"TR.NIProceedsAmtInclOverallotSoldAllMkts(Scale=6)","TR.NIIssuerExchTicker(Concat='|')",'TR.NISecurityTypeAllMkt',"TR.NIOfferingTechnique(Concat='|')","TR.NIGrossSpreadAsPctOfPrincipalAmtThisMktPrint","TR.NIIssuerDomicileSubRegion",'TR.NIIssuerDomicileRegion','TR.NIIssuerTRBCBusinessSector','TR.NIIssuerTRBCEcoSec',"TR.NILeadLeftBookrunner(Concat='|')","TR.NIBookOrCoManager(Concat='|')","TR.NIParentBookOrCoManager(IncludeNull=True,Concat='|')","TR.NIAllManagers(IncludeNull=True,Concat='|')","TR.NILeadManagers(IncludeNull=True,Concat='|')","TR.NIParentLeadManagers(IncludeNull=True,Concat='|')","TR.NIISINAtOffer(Concat='|')","TR.NIIssuerCusip9(Concat='|')","TR.NIIssuerSEDOL","TR.NIIssuerPrimayTickerSymbol"]
rd.open_session()
current_date = datetime.strftime(today_date , '%Y%m%d')
end_date = today_date - timedelta(days=8)
end_date = datetime.strftime(end_date, '%Y%m%d')
deals_screen = "SCREEN(U(IN(DEALS)/*UNV:DEALSBOND*/),TR.NIisECM=False, BETWEEN(TR.NIIssueDate(IncludeNull=True),{0},{1})/*dt:Date*/, CURN=USD)"
deals_screen = deals_screen.format(current_date, end_date)
today_date = datetime.strptime(current_date , '%Y%m%d') - timedelta(days=1)
Error:-
SCREEN(U(IN(DEALS)/*UNV:DEALSBOND*/),TR.NIisECM=False, BETWEEN(TR.NIIssueDate(IncludeNull=True),20241017,20241009)/*dt:Date*/, CURN=USD)
[2024-10-18T15:25:32.464722+05:30] - [ERROR] - [sessions.desktop.workspace.2] - [12152] | MainThread
Session is not opened. Can't send any request
Traceback (most recent call last):
lt = rd.get_data(deals_screen,deals_fields)
File C:\python3.10\latest\lib\site-packages\refinitiv\data\_fin_coder_layer\get_data_func.py:50 in get_data
raise_if_closed(session)
File C\python3.10\latest\lib\site-packages\refinitiv\data\_core\session\tools.py:38 in raise_if_closed
raise ValueError(error_message)
ValueError: Session is not opened. Can't send any request