2026/01/23

python抓取元大rtd裡的欄位即時資料範例

 import xlwings as xw

import time


# 連接當前開啟的 Excel 檔案

wb = xw.Book('txf.xlsm')

sheet = wb.sheets['價格記錄']


while True:

    # 假設元大 RTD 資料在 A1 儲存格

    price = sheet.range('A2').value

    print(f"當前即時價格: {price}")


    # 根據需求設定取樣頻率 (例如每秒 1 秒)

    time.sleep(1)

沒有留言:

張貼留言