Problem with calculating Bitcoin financial metrics | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Problem with calculating Bitcoin financial metrics

Hello everyone! I need your help. For some reason, this code returns incorrect data in the section "Main metrics for Bitcoin". I compared the result of the code with data from the Internet and saw that they do not match. The program calculates the Sharpe ratio for Bitcoin higher than 1. But on the web resources you can find information that this ratio for Bitcoin should be negative at all: -0.37. I wrote this program in accordance with the course "Python for Finance" within Code Repo. Please help me fix it. If you can find an error in the calculations, I will be very grateful! https://code.sololearn.com/cZoe8RrfZdZM/?ref=app

29th Apr 2022, 8:48 PM
Anton Panasiuk
Anton Panasiuk - avatar
3 Answers
+ 3
SharpeRatio = (Rp - Rf) / Dp # where: # Rp = return of portfolio # Rf = risk-free rate # Dp = standard deviation of the portfolio’s excess return
30th Apr 2022, 1:35 PM
JaScript
JaScript - avatar
+ 2
JaScript , okay, what about volatility? And is return of portfolio the same as cumulative return and is calculated with .cumprod() function?
30th Apr 2022, 1:41 PM
Anton Panasiuk
Anton Panasiuk - avatar
+ 2
Anton Panasiuk , Dp = „volatility“ and all your answers can be found in web, for example here: https://en.wikipedia.org/wiki/Sharpe_ratio
30th Apr 2022, 1:49 PM
JaScript
JaScript - avatar