I was using python api to download daily data, it seemed that the whole process was not stable. was it because I used for cycles?
import lseg.data as ld# Install with `pip install lseg.data`
config = ld.get_config()
config.set_param("logs.transports.file.enabled", True)
config.set_param("logs.transports.file.name", "lseg-data-lib.log")
config.set_param("logs.level", "debug")
ld.open_session()
DateTable2['startDs']=DateTable2.startD.dt.strftime('%Y-%m-%d')
DateTable2['endDs']=DateTable2.endD.dt.strftime('%Y-%m-%d')
manualTable=pd.concat([manualTable,DateTable2],axis=0)
for jj in range(DateTable2.shape[0]):
nameTag=DateTable2.Expired_Call_RIC[jj]
print(nameTag)
ss=DateTable2.startDs[jj]
ee=DateTable2.endDs[jj]
tempData=ld.get_history(
universe=nameTag,
# fields=["TR.CLOSEPRICE"],
fields=["TR.OPENPRICE", "TR.HIGHPRICE", "TR.LOWPRICE", "TR.CLOSEPRICE"],
interval="1D",
start=ss,
end=ee
)
HistoryRecordOption=pd.concat([HistoryRecordOption,tempData],axis=0)
theTargetCode=['TYU2^2', 'TYZ2^2', 'TYH3^2', 'TYM3^2', 'TYU3^2', 'TYZ3^2', 'TYH24^2', 'TYM24^2', 'TYU24^2', 'TYZ24^2', 'TYH25^2', 'TYM25^2', 'TYU25^2']
---------------------------------------------------------------------------LDError
Traceback (most recent call last)Cell
In[13], line 27
25 ss=DateTable2.startDs[jj] 26 ee=DateTable2.endDs[jj]
---> 27
tempData=ld.get_history( 28 universe=nameTag, 29 # fields=["TR.CLOSEPRICE"], 30 fields=["TR.OPENPRICE", "TR.HIGHPRICE", "TR.LOWPRICE", "TR.CLOSEPRICE"], 31 interval="1D", 32 start=ss, 33 end=ee 34 ) 35 HistoryRecordOption=pd.concat([HistoryRecordOption,tempData],axis=0) 36 # time.sleep(61)File
c:\Users\Bob\AppData\Local\Programs\Python\Python313\Lib\site-packages\lseg\data\_access_layer\get_history_func.py:212
, in get_history
(universe, fields, interval, start, end, adjustments, count, parameters, header_type)
210 if exceptions and all(exceptions): 211 except_msg = "\n\n".join(exceptions)
--> 212
raise LDError(message=except_msg) 214 if not any({adc_data, hp_data, cust_inst_data}): 215 return DataFrame()
LDError
: Unable to collect data for the field 'TR.OPENPRICE' and some specific identifier(s). Requested universes: ['TY1225J2^J22']. Requested fields: ['TR.OPENPRICE', 'TR.HIGHPRICE', 'TR.LOWPRICE', 'TR.CLOSEPRICE']
If I manually use the questioned
'TY1225J2^J22', I can download the data. But if it was in the for cycle, also the code fails.
@Jirapongse Here is the
lseg-data-lib.log file content.
[2025-11-13T13:02:21.237077+08:00] - [sessions.desktop.workspace.1] - [DEBUG] - [21660 - MainThread] - [_desktop_session] - [__init__] - DesktopSession created with following parameters: app_key="DEFAULT_WORKSPACE_APP_KEY", name="workspace" base_url="http://localhost:9000" platform_path_rdp="/api/rdp" platform_path_udf="/api/udf" handshake_url="/api/handshake"
[2025-11-13T13:02:21.237480+08:00] - [sessions.desktop.workspace.1] - [DEBUG] - [21660 - MainThread] - [_session] - [_connection] - Created session connection SessionCxnType.DESKTOP
[2025-11-13T13:02:21.237569+08:00] - [sessions.desktop.workspace.1] - [DEBUG] - [21660 - MainThread] - [_session_provider] - [session_provider] - Session created: DesktopSession
name = workspace
connection = DesktopConnection
stream_auto_reconnection = True
handshake_url = http://localhost:9000/api/handshake
state = OpenState.Closed
session_id = 1
logger_name = sessions.desktop.workspace.1