library(tidyverse) library(lubridate) library(stringr) library(fPortfolio) library(ZStockModels) # Set global options for knitr knitr::opts_chunk$set( comment = "#>", echo = FALSE, warning = FALSE, message = FALSE, collapse = TRUE ) options(tibble.print_min = 10L, tibble.print_max = 20L)
# Open gta stock databse stock_db <- stock_db(gta_db, "GTA_SQLData") open_stock_db(stock_db) # Initate the stock database invisible(init_stock_db(stock_db)) stock_name_list <- stock_name_list(stock_db) stock_field_list <- stock_field_list(stock_db) # Get names of all stock table from database db_tables <- list_stock_tables(stock_db) knitr::kable( x = db_tables, caption = "Tables in GTA Stock Database", align = "l" )
# load monthly return of stocks ds_trd_mnth.df <- get_table_dataset(stock_db, table_name = "TRD_Mnth_月个股回报率") ds_stocks_mretwd.fts <- fetch_stock_field_dataset(ds_source.df = ds_trd_mnth.df, stock_cd_list = stock_cd_list, replaceNA = "zeros", target_field = "mretwd", date_field = "trdmnt") # load montly return of market ds_trd_cnmont.df <- get_table_dataset(stock_db, table_name = "TRD_Cnmont_综合市场月度回报") ds_market_cmretwdtl.fts <- fetch_stock_field_dataset(ds_source.df = ds_trd_cnmont.df, stock_cd_list = stock_cd_list, replaceNA = "zeros", target_field = "cmretwdtl", date_field = "trdmnt")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.