Skip to content

Instantly share code, notes, and snippets.

@Ray901
Created June 14, 2022 05:46
Show Gist options
  • Save Ray901/d91ab0dbc2e411df58903a53d778a469 to your computer and use it in GitHub Desktop.
Save Ray901/d91ab0dbc2e411df58903a53d778a469 to your computer and use it in GitHub Desktop.
rm(list=ls())
library(httr)
library(data.table)
library(dplyr)
library(plotly)
url = 'https://api.finmindtrade.com/api/v4/data'
config_proxy <- httr::config(
proxy = curl::ie_get_proxy_for_url(),
proxyauth = 8,
proxyuserpwd = ":",
ssl_verifypeer = 0
)
response = httr::GET(
url = url,
query = list(
dataset="TaiwanStockPrice",
data_id= "2330",
start_date= "2010-01-01",
end_date= as.character(Sys.Date()),
token = "" # 參考登入,獲取金鑰
),
config_proxy
)
data = content(response)
df = data$data %>%
do.call('rbind',.) %>%
data.table
fig <- df %>% plot_ly(x = ~date, type="candlestick",
open = ~open, close = ~close,
high = ~max, low = ~min)
fig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment