[第24期] 使用yfinance與PyQt計算股票的KD值/Calculate KD value of the stock by using yfinance and PyQt
[第24期] Calculate KD value of the stock by using yfinance and PyQt/使用yfinance與PyQt計算股票的KD值 1
This video shows how to use yfinance and PyQt to calculate KD value of the stock .
The content includes:
Input Taiwan stock ticker
Calculate K and D valuse with yfinance
本視頻說明如何使用yfinance與PyQt計算股票的KD值。
內容包含:
輸入台灣股票代號
使用yfinance計算KD值
程式碼:
def calculate_kd(self):
stock_code = self.stock_code_lineEdit.text()
if not stock_code:
return
# 從Yahoo Finance獲取股票歷史價格資料
stock = yf.Ticker(stock_code + “.TW”)
history = stock.history(period=”max”)
# 計算KD值
1 | low_min = history["Low"].rolling(window=9).min() |
# 顯示結果
kd_result = “最新K值:{:.2f},最新D值:{:.2f}”.format(k[-1], d[-1])
self.result_label.setText(kd_result)
文章設定 標籤 沒有符合的建議 發布日期: 2023/3/11 中午12:15 永久連結 位置 選項 文章:編輯