Skip to content

Commit

Permalink
feat: add TaiwanStockKBar
Browse files Browse the repository at this point in the history
  • Loading branch information
linsamtw committed Sep 24, 2023
1 parent 9fc8e61 commit 1e01cdd
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/tutor/TaiwanMarket/DataList.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
在台灣金融市場,我們擁有 45 種資料集,如下:
在台灣金融市場,我們擁有 46 種資料集,如下:

#### 技術面 Technical

Expand All @@ -14,6 +14,7 @@
- [當日沖銷交易標的及成交量值 TaiwanStockDayTrading](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstockdaytrading)
- [加權、櫃買報酬指數 TaiwanStockTotalReturnIndex](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstocktotalreturnindex)
- [台灣各股十年線資料表 TaiwanStock10Year](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstock10year)
- [台灣分 K 資料表 TaiwanStockKBar](https://finmind.github.io/tutor/TaiwanMarket/Technical/#k-taiwanstockkbar-sponsor)

#### 籌碼面 Chip

Expand Down
59 changes: 57 additions & 2 deletions docs/tutor/TaiwanMarket/Technical.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
在台股技術面,我們擁有 11 種資料集,如下:
在台股技術面,我們擁有 12 種資料集,如下:

- [台股總覽 TaiwanStockInfo](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstockinfo)
- [台股總覽(含權證) TaiwanStockInfoWithWarrant](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstockinfowithwarrant)
Expand All @@ -11,6 +11,7 @@
- [當日沖銷交易標的及成交量值 TaiwanStockDayTrading](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstockdaytrading)
- [加權、櫃買報酬指數 TaiwanStockTotalReturnIndex](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstocktotalreturnindex)
- [台灣各股十年線資料表 TaiwanStock10Year](https://finmind.github.io/tutor/TaiwanMarket/Technical/#taiwanstock10year)
- [台灣分 K 資料表 TaiwanStockKBar](https://finmind.github.io/tutor/TaiwanMarket/Technical/#k-taiwanstockkbar-sponsor)


根據上述資料表逐一說明怎麼使用,另外具體資料表 schemas 請參考 [finmindapi](http://api.finmindtrade.com/docs#/default/method_api_v4_data_get)
Expand Down Expand Up @@ -960,4 +961,58 @@
| 1 | 2020-04-06 | 0053 | 28.68 |
| 2 | 2020-04-06 | 0055 | 14.31 |
| 3 | 2020-04-06 | 0056 | 24.59 |
| 4 | 2020-04-06 | 0061 | 16.28 |
| 4 | 2020-04-06 | 0061 | 16.28 |


#### 台灣分 K 資料表 TaiwanStockKBar (只限 [sponsor](https://finmindtrade.com/analysis/#/Sponsor/sponsor) 會員使用)

- 資料更新時間 **星期一至五 15:50**,實際更新時間以 API 資料為主

!!! example
=== "Python-request"
```python
import requests
import pandas as pd
url = "https://api.finmindtrade.com/api/v4/data"
parameter = {
"dataset": "TaiwanStockKBar",
"data_id": "2330",
"start_date": "2023-09-22",
"token": "", # 參考登入,獲取金鑰
}
resp = requests.get(url, params=parameter)
data = resp.json()
data = pd.DataFrame(data["data"])
print(data.head())
```
=== "R"
```R
library(httr)
library(data.table)
library(dplyr)
url = 'https://api.finmindtrade.com/api/v4/data'
response = httr::GET(
url = url,
query = list(
dataset="TaiwanStockKBar",
data_id= "2330",
start_date= "2023-09-22",
token = "" # 參考登入,獲取金鑰
)
)
data = content(response)
df = data$data %>%
do.call('rbind',.) %>%
data.table
head(df)

```

!!! output
| | date | minute | stock_id | open | high | low | close | volume |
|---:|:-----------|:---------|-----------:|-------:|-------:|------:|--------:|---------:|
| 0 | 2023-09-22 | 09:00:00 | 2330 | 523 | 524 | 522 | 524 | 3893 |
| 1 | 2023-09-22 | 09:01:00 | 2330 | 524 | 524 | 523 | 524 | 159 |
| 2 | 2023-09-22 | 09:02:00 | 2330 | 523 | 524 | 522 | 523 | 548 |
| 3 | 2023-09-22 | 09:03:00 | 2330 | 522 | 523 | 522 | 522 | 208 |
| 4 | 2023-09-22 | 09:04:00 | 2330 | 522 | 523 | 522 | 522 | 179 |

0 comments on commit 1e01cdd

Please sign in to comment.