PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import yfinance as yf
import matplotlib.pyplot as plt
import numpy as np
btc_data = yf.Ticker('BTC-USD')
print(btc_data.info['description']+"\n")
print("————————————————————————————————————————————————————\n")
print("Close prices for last 5 days:\n")
print(btc_data.history(period='5d')['Close'], "\n")
btc_cls = btc_data.history(period='2y')['Close']
btc_pct = btc_cls.pct_change()
btc_ret = ( (btc_pct + 1).cumprod() ) * 100
print("————————————————————————————————————————————————————\n")
print("Growth of $100 investment over the past two years:\n")
print(btc_ret, "\n")
btc_vlt = np.std( btc_data.history(period='1mo')['Close'].pct_change() * 100 )
ann_vlt = np.std( btc_data.history(period='1y')['Close'].pct_change() * 100 ) * np.sqrt(365)
btc_lst_y = btc_data.history(period='1y')['Close'].pct_change()
btc_shrp = (
np.mean(btc_lst_y) / np.std(btc_lst_y) * np.sqrt(365)
) * 100
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run