操作指南
轉換 DataFrame
轉換 DataFrame
from twmarket import Client
from twmarket.integrations import to_pandas, to_polars
with Client() as market:
statement = market.mops.income_statement("2330", year=2026, quarter=2)
revenue = market.mops.revenue("2330", year=2026, month=8)
accounts = to_polars(statement)
monthly_revenue = to_pandas(revenue)
print(accounts.head())
print(monthly_revenue.head())轉換預設保留 Decimal;price_type="float" 可轉為浮點數。
財報展開為科目/期間/衡量項目的長表。單位沿用來源;來源未標示時為 None。
使用 with/async with 管理連線。Client(cache_ttl=60) 啟用快取;
即時報價與有效契約查驗略過快取。