Skip to content

其他

在台灣股票新聞面,我們擁有 2 種資料集,如下:

相關新聞表 TaiwanStockNews

(由於資料量過大,單次請求只提供一天資料)

Example

import requests
import pandas as pd
url = "https://api.finmindtrade.com/api/v4/data"
parameter = {
    "dataset": "TaiwanStockNews",
    "data_id":"2330",
    "start_date": "2020-04-01",
    "token": "", # 參考登入,獲取金鑰
}
data = requests.get(url, params=parameter)
data = data.json()
data = pd.DataFrame(data['data'])
print(data.head())
library(httr)
library(data.table)
library(dplyr)

url = 'https://api.finmindtrade.com/api/v4/data'
response = httr::GET(url = url,
                    query = list(
                    dataset="TaiwanStockNews",
                    data_id="2330",
                    start_date= "2020-04-01",
                    token = "" # 參考登入,獲取金鑰
                    )
)
data = response %>% content
df = do.call('cbind',data$data) %>%data.table
head(df)

Output

date stock_id description link source title
0 2020-04-01 00:00:00 2330 <a href="https://tw.news.yahoo.com/%E9%9B%B... https://tw.news.yahoo.com/%E9%9B%BB%E5%AD%90%E... Yahoo奇摩新聞
1 2020-04-01 00:57:33 2330 <a href="https://udn.com/news/story/6850/44... https://udn.com/news/story/6850/4458587 udn 聯合新聞網
2 2020-04-01 00:58:42 2330 <a href="https://finance.technews.tw/2020/0... https://finance.technews.tw/2020/04/01/tsmc-wa... 科技新報 TechNews
3 2020-04-01 00:59:38 2330 <a href="https://tw.news.yahoo.com/%E5%8F%B... https://tw.news.yahoo.com/%E5%8F%B0%E7%A9%8D%E... Yahoo奇摩股市
4 2020-04-01 02:40:00 2330 <a href="https://fnc.ebc.net.tw/FncNews/Con... https://fnc.ebc.net.tw/FncNews/Content/117374 東森財經新聞
{
    date: str,
    stock_id: str,
    description: str,
    link: str,
    source: str,
    title: str
}

台灣每月景氣對策信號表 TaiwanBusinessIndicator (只限 backer、sponsor 會員使用)

  • 資料區間:1982-01-01 ~ now

Example

import requests
import pandas as pd
url = "https://api.finmindtrade.com/api/v4/data"
parameter = {
    "dataset": "TaiwanBusinessIndicator",
    "start_date": "2024-04-01",
    "end_date": "2025-01-01",
    "token": "", # 參考登入,獲取金鑰
}
data = requests.get(url, params=parameter)
data = data.json()
data = pd.DataFrame(data['data'])
print(data.head())
library(httr)
library(data.table)
library(dplyr)

url = 'https://api.finmindtrade.com/api/v4/data'
response = httr::GET(url = url,
                    query = list(
                    dataset="TaiwanBusinessIndicator",
                    start_date= "2020-04-01",
                    "end_date": "2025-01-01",
                    token = "" # 參考登入,獲取金鑰
                    )
)
data = response %>% content
df = do.call('cbind',data$data) %>%data.table
head(df)

Output

date leading leading_notrend coincident coincident_notrend lagging lagging_notrend monitoring monitoring_color
0 2024-01-01 92.32 99.85 90.8 98.21 91.82 99.31 27 G
1 2024-02-01 92.71 100.35 91.45 98.99 91.68 99.25 29 G
2 2024-03-01 93.19 100.95 92.28 99.97 91.6 99.23 31 G
3 2024-04-01 93.75 101.63 93.23 101.07 91.52 99.22 35 YR
4 2024-05-01 94.29 102.28 94.21 102.19 91.41 99.16 36 YR
{
    date: str,
    leading: float32,
    leading_notrend: float32,
    coincident: float32,
    coincident_notrend: float32,
    lagging: float32,
    lagging_notrend: float32,
    monitoring: float32,
    monitoring_color: str
}