Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
81 lines (57 sloc) 3.83 KB
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# pedquant
[![CRAN status](https://www.r-pkg.org/badges/version/pedquant)](https://cran.r-project.org/package=pedquant)
[![](http://cranlogs.r-pkg.org/badges/grand-total/pedquant)](https://cran.r-project.org/package=pedquant)
[![Travis build status](https://travis-ci.org/ShichenXie/pedquant.svg?branch=master)](https://travis-ci.org/ShichenXie/pedquant)
`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](http://data.stats.gov.cn) and [FRED](http://data.stats.gov.cn);
- md_* (market data) functions load stock prices from [Yahoo finance](http://finance.yahoo.com), stock prices and financial statements of SSE and SZSE shares from [163 Finance](http://quotes.money.163.com/stock#1b01), and future prices from [Sina Finance](https://finance.sina.com.cn/futuremarket/) 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](http://r-datatable.com/) or [tidyverse](http://tidyverse.org) packages; high performance on speed by use [data.table](http://r-datatable.com/) and [TTR](https://github.com/joshuaulrich/TTR); and modern graphics by using ggplot2. At this moment, `pedquant` can only handle EOD (end of date) data. Similar works including [tidyquant](https://github.com/business-science/tidyquant) or [quantmod](https://github.com/joshuaulrich/quantmod), which are much mature for financial analysis.
## Installation
- Install the release version of `pedquant` from CRAN with:
```r
install.packages("pedquant")
```
- Install the developing version of `pedquant` from [github](https://github.com/shichenXie/pedquant) with:
``` r
devtools::install_github("shichenxie/pedquant")
```
## Example
The following examples show you how to import data and create charts.
```{r data}
library(pedquant)
## import eocnomic data
dat1 = ed_fred('GDPCA')
dat2 = ed_nbs(geo_type='national', freq='quarterly', symbol='A010101')
## import market data
FAAG = md_stock(c('FB', 'AMZN', 'AAPL', 'GOOG'), date_range = 'max') # from yahoo
INDX = md_stock(c('^000001','^399001'), date_range = 'max', source = '163')
```
```{r charts1}
# candlestick chart with technical indicators
pq_plot(INDX$`^000001`, chart_type = 'candle', date_range = '1y', addti = list(
sma = list(n=50), macd=list()
))
```
```{r charts2}
# comparing prices
pq_plot(FAAG, multi_series = list(nrow=2, scales = 'free_y'), date_range = '3y')
```
## 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](https://github.com/ShichenXie/pedquant/issues). Contributions in any forms to this project are welcome.
If you like this package, you can buy me a coffee.
![alipay](man/figures/README-p-alipay.jpg){width=0.50}
![wechat](man/figures/README-p-wechat.jpg){width=0.50}
You can’t perform that action at this time.