Provides an interface to access public economic and financial data for economic research and quantitative analysis. The data sources including NBS, FRED, Yahoo Finance, 163 Finance and etc.
pedquant
(Public Economic Data and QUANTitative analysis) provides an
interface to access public economic and financial data for economic
research and quantitative analysis. The functions are grouped into three
main categories,
The functions in this package are designed to write minimum codes for some common tasks in quantitative analysis process. Since the parameters to get data can be interactively specify, it’s very easy to start. The loaded data have been carefully cleansed and provided in a unified format. More public data sources are still under cleansing and developing.
pedquant
package has advantages on multiple aspects, such as the
format of loaded data is a list of data frames, which can be easily
manipulated in data.table or
tidyverse packages; high performance on speed by
use data.table and
TTR; and modern graphics by using
ggplot2. At this moment, pedquant
can only handle EOD (end of date)
data. Similar works including
tidyquant or
quantmod, which are much
mature for financial analysis.
pedquant
from CRAN with:install.packages("pedquant")
pedquant
from
github with:devtools::install_github("shichenxie/pedquant")
The following examples show you how to import data and create charts.
library(pedquant)## import eocnomic datadat1 = ed_fred('GDPCA')#> 1/1 GDPCAdat2 = ed_nbs(geo_type='national', freq='quarterly', symbol='A010101')## import market dataFAAG = md_stock(c('FB', 'AMZN', 'AAPL', 'GOOG'), date_range = 'max') # from yahoo#> 1/4 FB#> 2/4 AMZN#> 3/4 AAPL#> 4/4 GOOGINDX = md_stock(c('^000001','^399001'), date_range = 'max', source = '163')#> 1/2 ^000001#> 2/2 ^399001
# candlestick chart with technical indicatorspq_plot(INDX$`^000001`, chart_type = 'candle', date_range = '1y', addti = list(sma = list(n=50), macd=list()))
#> $`000001.SS`
#> TableGrob (2 x 1) "arrange": 2 grobs
#> z cells name grob
#> p0 1 (1-1,1-1) arrange gtable[layout]
#> p1 2 (2-2,1-1) arrange gtable[layout]
# comparing pricespq_plot(FAAG, multi_series = list(nrow=2, scales = 'free_y'), date_range = '3y')#> $multi_series
This package still on the developing stage. If you have any issue when using this package, please update to the latest version from github. If the issue still exists, report it at github page. Contributions in any forms to this project are welcome.
If you like this package, you can buy me a coffee.
NEWS.md
file to track changes to the package.