-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCandlestickChart - Copy.py
More file actions
40 lines (30 loc) · 1.09 KB
/
CandlestickChart - Copy.py
File metadata and controls
40 lines (30 loc) · 1.09 KB
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
import pandas as pd
import numpy as np
import datetime as dt
import yfinance as yf
import pandas_datareader as pdr
import plotly.express as px
import plotly.graph_objects as go
yr = input("From what year do you want to start the analysis (Ex. 2022): ")
mon = input("From what month do you want to start the analysis (Ex. 08 or 12): ")
day = input("From what day do you want to start the analysis (Ex. 08 or 12): ")
start_date = yr+"-"+mon+"-"+day
end_date = dt.date.today().strftime('%Y-%m-%d')
a = input("Please type in the stock you wish to analyze: ")
tickers = []
tickers.append(a)
each_df = {}
for ticker in tickers:
each_df[ticker] = pdr.DataReader(ticker, 'yahoo', start_date, end_date)
fig = go.Figure(data=[go.Candlestick(x=each_df[ticker].index,
open=each_df[ticker]['Open'],
high=each_df[ticker]['High'],
low=each_df[ticker]['Low'],
close=each_df[ticker]['Close'])])
fig.update_layout(
title='Candlestick Chart for ' + ticker,
yaxis_title='Price',
xaxis_title='Date',
hovermode='x'
)
fig.show()