J'essaie de calculer le retour sur investissement pour les actions. Je pense que c'est juste, mais je ne sais pas comment tester la précision. Le code calcule plusieurs choses: retour sur investissement: (proche de la clôture), acheter à la vente le jour suivant sur la vente ouverte, vente à découvert, vente à découvert. Peut-être que cela le rendra plus clair:Calcul du retour sur investissement, y compris vente à découvert
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)
Suggestions? Particulièrement concerné comment je calcule la vente à découvert.