factor_acount: factor_acount

Description Usage Arguments Format Details Examples

Description

create a R6 object of acount to analyse factor. can calculate the factor/number rank stock easily.

Usage

1
2
3
p <- factor_acount$new(con, buy_stock = NULL)
p$factor_update(buy_num, begin_date, end_date, wait_sell = F, refresh = T, show_trace = T)
p$show_wait_sell()

Arguments

con

connection for data

buy_stock

data.frame, column code, buy_date(date), num(int)

begin_date

int, the first date to backtest

end_date,

int, the end date to backtest

wait_sell,

logic. if True, sell the stock wait for sell every day

refresh,

logic, clean acount history

show_trace,

logic, print history day by day

...

the paramater inherit from stock_acount

Format

stock_acount$new(con, buy_stock)

to create new object

factor_update(buy_num, begin_date, end_date, wait_sell = F, refresh = T, show_trace = T)

factor buy top buy_num stock every month

show_wait_sell()

to show stock can't sell

Details

An R6Class generator object inherit from stock_acount

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
con <- odbcConnect('tiny')
my_acount <- factor_acount$new(con = con, 
                               buy_stock = data_all %>% 
                                  transmute(code = wind_code, buy_date = ymd(trade_dt)) %>%
                                  group_by(buy_date) %>% mutate(num = 1:n()))
my_acount$factor_update(20, 20170101, 20170531, wait_sell = T)

## End(Not run)

cloud-brain/backtest documentation built on Feb. 6, 2020, 11:17 p.m.