Learn R Programming

pedquant (version 0.1.3)

md_stock_adjust: adjust stock price for split and dividend

Description

md_stock_adjust adjusts the open, high, low and close stock prices for split and dividend.

Usage

md_stock_adjust(dt, source, adjust = "split", adjfactor = NULL)

Arguments

dt

a list/dataframe of time series datasets that didnt adjust for split or dividend.

source

the available data sources are 'yahoo' (http://finance.yahoo.com) and '163' (http://money.163.com).

adjust

adjust the OHLC prices for split (default), or dividend (both split and dividend). If it is NULL, return the original data. For the yahoo data, the original data already adjust for split, and use the 'close_adj' column to adjust; for the 163 data, the original doesnot adjust any factors, and use the splits, dividends and issues to adjust.

adjfactor

adjust factors, including splits and dividends. Defaults to NULL, which will load adjust factors from source. It can also download from md_stock when type set as adjfactor.

Examples

Run this code
# NOT RUN {
dt = md_stock('600547', source = '163', date_range = 'max', 
              type = 'history', adjust = NULL)
ds = md_stock('600547', source = '163', date_range = 'max', 
              type = 'adjfactor')

dtadj = md_stock_adjust(dt, source = '163', adjust = 'dividend', 
                        adjfactor = ds)
# }

Run the code above in your browser using DataLab