-
Notifications
You must be signed in to change notification settings - Fork 0
/
Financial_Data_Visualization.py
66 lines (54 loc) · 1.45 KB
/
Financial_Data_Visualization.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import matplotlib as mpl
# a = mpl.__version__
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import yfinance as yf
import numpy as np
import pandas as pd
import cufflinks as cf
import plotly.offline as plyo
plt.style.use("seaborn-v0_8")
mpl.rcParams['font.family'] = 'serif'
def load_data(ticker, start_date, end_date):
dataset = yf.download(ticker, start=start_date, end=end_date)
return dataset
def data_info(dataset):
df = pd.DataFrame(dataset)
df.info()
quotes = df[['Open', 'High', 'Low', 'Adj Close']]
quotes.tail()
return df, quotes
def financial_plot(quotes):
qf = cf.QuantFig(
quotes,
title=ticker,
legend='top',
name='EUR/USD'
)
plyo.iplot(
qf.iplot(asFigure=True),
image='png',
filename='qf_01'
)
qf.add_bollinger_bands(periods=15,
boll_std=2)
plyo.iplot(
qf.iplot(asFigure=True),
image='png',
filename='qf_02'
)
qf.add_rsi(periods=14,
showbands=False)
plyo.iplot(
qf.iplot(asFigure=True),
image='png',
filename='qf_03'
)
plt.show()
if __name__ == '__main__':
ticker = 'NVDA'
start_date = '2023-01-26'
end_date = '2023-05-26'
dataset_ = load_data(ticker, start_date, end_date)
df_, quotes_ = data_info(dataset_)
financial_plot(quotes_)