Robot-Wealth / rsims

R package for financial simulation
Other
38 stars 16 forks source link

total equity for futures #15

Open KZARCA opened 1 year ago

KZARCA commented 1 year ago

Hi! I might have spotted an error. Total equity is computed within calc_port_returns as the sum of exposures.

    results_df %>% dplyr::group_by(date) %>% dplyr::summarise(totalequity = sum(exposure, 
        na.rm = TRUE))

For the futures contracts, shouldn't it computed as the margin + cash exposure ?

    results_df %>% dplyr::group_by(date) %>% dplyr::summarise(totalequity = sum(margin + first(exposure),
        na.rm = TRUE))

If that's the case, I can open a PR if you want. Best