pedquant v0.1.3

0

Monthly downloads

0th

Percentile

Public Economic Data and Quantitative Analysis

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.

Readme

pedquant

CRAN
status Travis build
status

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,

  • ed_* (economic data) functions load economic data from NBS and FRED;
  • md_* (market data) functions load stock prices from Yahoo finance, stock prices and financial statements of SSE and SZSE shares from 163 Finance, and future prices from Sina Finance etc.
  • pq_* (quantitative analysis) functions create technical indicators, visualization charts and industrial index etc for time series data.

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.

Installation

  • Install the release version of pedquant from CRAN with:
install.packages("pedquant")
  • Install the developing version of pedquant from github with:
devtools::install_github("shichenxie/pedquant")

Example

The following examples show you how to import data and create charts.

library(pedquant)
#> Registered S3 method overwritten by 'xts':
#>   method     from
#>   as.zoo.xts zoo
## import eocnomic data
dat1 = ed_fred('GDPCA')
#> 1/1 GDPCA
dat2 = ed_nbs(geo_type='nation', freq='quarterly', symbol='A010101')

## import market data
FAAG = md_stock(c('FB', 'AMZN', 'AAPL', 'GOOG'), date_range = 'max') # from yahoo
#> 1/4 FB
#> 2/4 AMZN
#> 3/4 AAPL
#> 4/4 GOOG
INDX = md_stock(c('^000001','^399001'), date_range = 'max', source = '163')
#> 1/2 ^000001
#> 2/2 ^399001

# candlestick chart with technical indicators
pq_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 prices
pq_plot(FAAG, multi_series = list(nrow=2, scales = 'free_y'), date_range = '3y')
#> $multi_series

Issues and Contributions

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.

Functions in pedquant

Name Description
md_stock_adjust adjust stock price for split and dividend
pq_to_freq converting frequency of daily data
pq_return calculating returns by frequency
pq_plot creating charts for time series
md_stock_financials query financial statements
pq_addti adding technical indicators
md_stock_symbol symbol components of exchange or index
pq_perf creating performance trends
pq_index creating weighted index
md_stock query stock market data
ed_code code list by category
ed_nbs query NBS economic data
md_future_symbol symbol of future market data
ed_fred query FRED economic data
md_future query future market data
ed_fred_symbol symbol of FRED economic data
ed_nbs_subregion subregion code of NBS economic data
md_cate query main market data by category
ed_nbs_symbol symbol of NBS economic data
No Results!

Last month downloads

Details

License GPL-3
URL https://github.com/ShichenXie/pedquant
BugReports https://github.com/ShichenXie/pedquant/issues
LazyData true
RoxygenNote 7.0.2
Encoding UTF-8
NeedsCompilation no
Packaged 2020-02-14 08:40:24 UTC; shichenxie
Repository CRAN
Date/Publication 2020-02-14 09:00:02 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/pedquant)](http://www.rdocumentation.org/packages/pedquant)