Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7
quant, financial data, economic data
License
ShichenXie/pedquant
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
pedquant (Public Economic Data and QUANTitative analysis) provides aninterface to access public economic and financial data for economicresearch and quantitative analysis. The functions are grouped into threemain categories,
- ed_* (economic data) functions load economic data fromNBS andFRED;
- md_* (market data) functions load the forex, money, bond, stock,future market data from public data sources, including 163, Sina, qqfinance and etc.
- pq_* (quantitative analysis) functions create technicalindicators, visualization charts and industrial index etc for timeseries data.
The functions in this package are designed to write minimum codes forsome common tasks in quantitative analysis process. Since the parametersto get data can be interactively specify, it’s very easy to start. Theloaded data have been carefully cleansed and provided in a unifiedformat.
pedquant package has advantages on multiple aspects, such as theformat of loaded data is a list of data frames, which can be easilymanipulated indata.table ortidyverse packages; high performance onspeed by usingdata.table andTTR; and interactive charts byusingecharts4r. Similar worksincludingtidyquant orquantmod.
- Install the release version of
pedquantfrom CRAN with:
install.packages("pedquant")- Install the developing version of
pedquantfromgithub with:
devtools::install_github("shichenxie/pedquant")The following examples show you how to import data.
library(pedquant)packageVersion('pedquant')#> [1] '0.2.4'# loading data## import eocnomic datadat1 = ed_fred('GDPCA')#> 1/1 GDPCAdat2 = ed_nbs(geo_type='nation', freq='quarterly', symbol='A010101')## import market dataFAAG = md_stock(c('META', 'AMZN', 'AAPL', 'GOOG'), date_range = '10y')#> 1/4 meta#> 2/4 amzn#> 3/4 aapl#> 4/4 googINDX = md_stock(c('^000001','^399001'), date_range = '10y')#> 1/2 ^000001#> 2/2 ^399001# double moving average strategy## add technical indicatorsdata("dt_banks")dtbnkti = pq_addti(dt_banks, x='close_adj', sma=list(n=200), sma=list(n=50))## crossover signalslibrary(data.table)dtorders = copy(dtbnkti[['601988.SH']])[ sma_50 %x>% sma_200, `:=`(side = 1, prices = close_adj) ][sma_50 %x<% sma_200, `:=`(side = -1, prices = close_adj) ][order(date) ][, (c('side', 'prices')) := lapply(.SD, shift), .SDcols = c('side', 'prices') ][,.(symbol, name, date, side, prices) ][!is.na(side)]head(dtorders)#> symbol name date side prices#> 1: 601988.SH 中国银行 2021-04-20 1 5.76#> 2: 601988.SH 中国银行 2021-08-19 -1 5.67#> 3: 601988.SH 中国银行 2021-11-18 1 5.70#> 4: 601988.SH 中国银行 2021-11-25 -1 5.71#> 5: 601988.SH 中国银行 2022-01-18 1 5.72# chartinge = pq_plot(setDT(dt_banks)[symbol=='601988.SH'], y='close_adj', addti = list(sma=list(n=200), sma=list(n=50)), orders = dtorders)# e[['601988.SS']]This package still on the developing stage. If you have any issue whenusing this package, please update to the latest version from github. Ifthe issue still exists, report it atgithubpage. Contributions inany forms to this project are welcome.
About
quant, financial data, economic data
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.