株式の投資収益率を計算しようとしています。これは正しいと思いますが、精度をテストする方法がわかりません。このコードは、いくつかのことを計算します: 投資収益率: (終値間近)、終値での買い、始値での翌日の売り、空売り、空売りの日の取引。多分これはそれをより明確にするでしょう:
library(quantmod)
library(PerformanceAnalytics)
getSymbols('F', src='yahoo',from='2015-01-01')
data <- get('F')
adjD <- adjustOHLC(data, symbol.name='F')
#calculate normal investment return
clcl <- Delt(Lag(Cl(adjD)), Cl(adjD), type='log')
chart.CumReturns(clcl)
#calculate after hours, from prev. day close to next day open
clop <- Delt(Lag(Cl(adjD)), Op(adjD), type='log')
chart.CumReturns(clop)
#then to calculate stock short
clopSh <- Delt(Cl(adjD), Lag(Cl(adjD)), type='log')
chart.CumReturns(clopSh)
#then to calculate day trade short, sell open to buy close
opclSh <- Delt(Cl(adjD), Op(adjD), type='log')
chart.CumReturns(opclSh)
提案?特に空売りの計算方法が気になります。