File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -38,21 +38,26 @@ export const computeRiskAndReturnOfPlayer = (
3838 return assetsWithReturns . map ( ( { totalAssetsReturn } ) => totalAssetsReturn )
3939 } )
4040
41- // TODO(JJ): 12 should rather be num_segments * 3 (because a segment is fixed as 3)
42- const bankReturnPA : number =
43- 12 * segmentEndResultsOfPlayer ?. [ 0 ] ?. facts . assetsWithReturns [ 1 ] . bankReturn
44-
4541 const num = totalAssetsReturns . length
4642
4743 const numResults = segmentEndResultsOfPlayer . length
4844 const lastResult = segmentEndResultsOfPlayer [ numResults - 1 ]
4945 const assetsWithReturns = lastResult . facts ?. assetsWithReturns
46+
47+ // TODO(JJ): 12 should rather be num_segments * 3 (because a segment is fixed as 3)
48+ const bankReturnPA : number =
49+ Math . pow (
50+ 1 + assetsWithReturns . slice ( - 1 ) [ 0 ] . accBankBenchmarkReturn ,
51+ 12 / num
52+ ) - 1
53+
5054 const lastAccReturn = assetsWithReturns . slice ( - 1 ) [ 0 ] . accTotalAssetsReturn
5155
5256 const risk = standardDeviation ( totalAssetsReturns ) * Math . sqrt ( 12 )
5357 const returns = Math . pow ( 1 + lastAccReturn , 12 / num ) - 1
5458 const sharpeRatio =
5559 risk > 0.0001 ? ( returns - bankReturnPA ) / risk : undefined
60+
5661 return {
5762 returns,
5863 risk,
You can’t perform that action at this time.
0 commit comments