Skip to content

Instantly share code, notes, and snippets.

@Ray901
Ray901 / Py_FinMind_stock_Kline.py
Last active September 18, 2025 16:15
Python FinMind Stock kline
import requests
import pandas as pd
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from datetime import datetime
# ====== 設定區 ======
token = "" # ←請填入你的 FinMind API token
start_date = "2025-01-01"
@Ray901
Ray901 / app.py
Last active March 24, 2025 08:02
from shiny.express import input, render, ui
ui.input_selectize(
"var", "Select variable",
choices=["bill_length_mm", "body_mass_g"]
)
@render.plot
def hist():
from matplotlib import pyplot as plt
@Ray901
Ray901 / PyTaiwanCalendar.py
Last active January 14, 2025 05:45
Get Taiwan Calendar from API
import requests
import pandas as pd
import pyodbc
accountfile = 'Text.txt'
with open(accountfile) as data:
accounts = data.readlines()
BIDW = list(filter(lambda x:'DB_USER' in x, accounts))
@Ray901
Ray901 / tableau_workbook_connection_update.py
Created December 24, 2024 05:33
update tableau workbook password using Python tableau API
import tableauserverclient as TSC
import re
tableau_auth = TSC.TableauAuth('BI_USER', 'XXX')
server = TSC.Server('https://bi.com')
request_options = TSC.RequestOptions(pagesize=1000)
overwrite_credentials = True
search_server_regex = 'XXX.XXX.XXX.XXX'
@Ray901
Ray901 / Get_Tableau_UserFilter.R
Created April 15, 2024 09:48
Use R to get Tableau RLS User Filter
rm(list=ls())
library(xml2)
xml_Doc <- read_xml("tableau.twb")
xml_groupfilter <- xml_find_all(xml_Doc, ".//group[@name='[FilterA]']//groupfilter[@function='filter']")
userList <- lapply(xml_groupfilter,function(x){
tmpUser <- xml_attr(x,"expression")
@Ray901
Ray901 / update_workbook_datasources.R
Last active April 3, 2024 07:59
Update Tableau Workbook datasource password by R
rm(list=ls())
library(vvtableau)
tableau <- authenticate_server(
base_url = "https://tableau.server.com/",
username = "ABC",
password = "OOXX"
)
rm(list=ls())
library(httr)
library(data.table)
library(dplyr)
library(plotly)
url = 'https://api.finmindtrade.com/api/v4/data'
config_proxy <- httr::config(
@Ray901
Ray901 / MSMQ_TO_SQL.py
Last active April 6, 2020 07:57
get MSMQ data to SQL SERVER
# coding=utf-8
import win32com.client
import os
import pythoncom
import json
import pyodbc
from datetime import datetime
from datetime import timedelta
import time
rm(list=ls())
library(readODS)
library(lubridate)
library(tidyr)
library(RODBC)
setFiles <- paste0(
unique(gsub("-","",substr(ymd(seq.Date(as.Date('2015-01-01'),as.Date('2019-03-01'),by = "month")),1,7))),
"_cht.ods"
@Ray901
Ray901 / R_TGOS_ADDR.R
Created March 4, 2019 08:02
USE TGOS API CONVERT ADDRESS TO LAT, LON
rm(list=ls())
options(digits = 9)
library(httr)
library(xml2)
library(dplyr)
library(magrittr)
TGOS_ADDR <- function(setADDR) {