Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

quant, financial data, economic data

License

NotificationsYou must be signed in to change notification settings

ShichenXie/pedquant

Repository files navigation

CRAN status

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.

Installation

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

Example

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']]

Issues and Contributions

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

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

    Packages

    No packages published

    Contributors2

    •  
    •  

    Languages


    [8]ページ先頭

    ©2009-2025 Movatter.jp