Python Finance Analyzing Bitcoin | Sololearn: Learn to code for FREE!

+2

Python Finance Analyzing Bitcoin

Hello, i'm struggling with the last Code Repo task for the Python Finance Course: Tasks 1. Calculate the volatility of Bitcoin and output the risk %. 2. Calculate and output the Sharpe ratio. My code is a mess with lot of trial and error: import numpy as np import numpy_financial as npf import matplotlib.pyplot as plt import yfinance as yf #Task1: Calculate the Volatility of Bitcoin and output the Risk % #Task2: Calculate tand output the Sharpe Ratio #Need to calculate the returns data = yf.Ticker('BTC-USD') #Daily return d = yf.download('BTC-USD', start='2020-01-01') #Calculate percentage change pc = d['Close'].pct_change() x = data.history('1y')['Close'] start = 1000 / x[0] #Volatility #To do this use the std.dv of my returns vol = (np.std(d)) print(vol) annual_std = np.std(vol) * np.sqrt(252) print(annual_std) y = np.multiply(start, x) plt.plot(y) plt.savefig('plot.png')

11/29/2021 1:18:14 AM

Thomas Dent

2 Answers

New Answer

+5

Please put the code in Code Playground and then pass the link. I know a person who has already passed the course and knows a lot about the subject: Lobo Solitario

+1