24.2 Code Repo Analyzing Bitcoin | Sololearn: Learn to code for FREE!


24.2 Code Repo Analyzing Bitcoin

Has anyone made progress up to the final code repo for the Python for Finance course?

12/7/2021 2:58:47 PM

Cory Peitsch

5 Answers

New Answer


import numpy as np import numpy_financial as npf #price for 2018-2021 bitcoin = [3869.47, 7188.46, 22203.31, 29391.78] devi1 = np.std(bitcoin) print(devi1)


This was a tricky one. I didn't know how to handle the ret= without weights axis value described in the volatility lesson. Turns out, this works: data = yf.Ticker('BTC-USD') x = data.history('1y')['Close'] ret = x risk = np.std(ret) * np.sqrt(252) sharpe = (np.mean(ret) / np.std(ret))*np.sqrt(252) print("Risk", risk) print("Sharpe", sharpe) plt.plot(x) plt.savefig('plot.png')


No there is confusion. There is no proper explanation given.


Ok, so I'm not the only one that thinks that. Thanks!


My problem is that I think I have it done, but nevertheless I am stuck. It doesn't show up as completed and therefore the following chapters are unavailable to me :-( Has anybody the same problem?