Question about getting bid ask of Isincodes by Codebook V2

I use the code below to get bid ask by codebook. My code is working but cannnot get the data whose isincode starts from JP. Could you tell me the reason if possible.
import pandas as pd
import lseg.data as ld
from lseg.data.content import symbol_conversion
EXCEL_IN = "2409_IsinCode.xlsx"
EXCEL_OUT = "BidAsk_20240930.xlsx"
TRADE_DT = "2024-09-30"
ld.open_session() # 1 回で OK
① ISIN 一覧を読み込むdf_isin = (pd.read_excel(EXCEL_IN, dtype=str)
.rename(columns=str.upper)
.dropna(subset=["ISINCODE"])
.assign(ISINCODE=lambda x: x["ISINCODE"].str.strip()))
isin_list = df_isin["ISINCODE"].tolist()
② 利用可能な RIC タイプを動的に抽出candidate_names = ["RIC_PRIMARY_EXCHANGE", "RIC_COMMON", "RIC_QUICK", "RIC"]
targets = [getattr(symbol_conversion.SymbolTypes, n)
for n in candidate_names if hasattr(symbol_conversion.SymbolTypes, n)]
if not targets:
raise RuntimeError("利用可能な RIC 系 SymbolTypes が見つかりません")
resp = symbol_conversion.Definition(
symbols = isin_list,
from_symbol_type = symbol_conversion.SymbolTypes.ISIN,
to_symbol_types = targets
).get_data()
df_raw = resp.data.df.copy()
if "FROM_SYMBOL" not in df_raw.columns:
df_raw = df_raw.reset_index().rename(columns={"index": "FROM_SYMBOL"})
df_conv = (df_raw
.rename(columns={
"FROM_SYMBOL": "ISINCODE",
"TO_SYMBOL_VALUE":"RIC",
"TO_SYMBOL_TYPE": "RIC_TYPE",
"DocumentTitle": "DocumentTitle"
}))
if "RIC_TYPE" not in df_conv.columns:
df_conv["RIC_TYPE"] = "RIC"
df_conv = (df_conv
.sort_values(["ISINCODE", "RIC_TYPE"])
.groupby("ISINCODE").first()
.reset_index()[["ISINCODE", "RIC", "DocumentTitle"]])
df_all = df_isin.merge(df_conv, on="ISINCODE", how="left")
⑤ RIC が取れた銘柄だけ価格取得ric_list = list(df_all["RIC"].dropna().unique())
if ric_list:
df_px = (ld.get_data(universe=ric_list,
fields=["BID", "ASK"])
.rename(columns={"Instrument": "RIC"}))
else:
df_px = pd.DataFrame(columns=["RIC", "BID", "ASK"])
df_final = df_all.merge(df_px, on="RIC", how="left")
⑦ Excel 出力df_final.to_excel(EXCEL_OUT, index=False)
print(f"✔ 完了: {EXCEL_OUT} を保存しました({len(df_final)} 行)")
ld.close_session()
Answers
-
Thank you for reaching out to us.
You need to enable debug log in the library by using the following code to verify what the problem is.
import lseg.data as ld
from lseg.data.content import symbol_conversion
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() …With this code before opening a session, the <date>-log-data-lib.log file will created in the current directory.
Please share the log file when the problem occurred.
0 -
Thank you for reply!
I will organize the issues and ask the questions again.0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 249 ETA
- 554 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 643 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
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 192 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛