Full disclosure - I'm very new to coding, I suspect the answer here could be rather simple (maybe somewhere charts should show up? I've made graphs in the past that have showed up though...), but I've spent probably a dozen hours trying different methods of printing candlestick charts. I mostly use Spyder, but I tried using PyCharm thinking maybe the IDE was the problem. I also tried Jupyter Notebook, but I couldn’t figure out the interface.
I've tried making the graph using Plotly and with mpl finance.
The closest I seemed to get was to get a blank chart (which seemed weird since I definitely had data in the dataframe. I’m also not sure how I got that, because I can’t get it any more.
This is the code I tried with Plotly:
import datetime as dt
import pandas as pd
from pandas_datareader import data as pdr
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import plotly.io as pio
pio.renderers.default = 'svg'
start = dt.datetime(2015, 2, 2)
end = "2022-08-01"
stock = ["AAPL"]
stock = pdr.DataReader(stock, 'yahoo', start, end)
print(stock.head())
ma50 = stock['Close'].rolling(window=50, min_periods=0).mean()
fig = make_subplots(rows=2, cols=1, shared_xaxes=True,vertical_spacing = .01, subplot_titles = ('price','volumne'))
fig = go.Figure(data=[go.Candlestick(x=stock.index,
open=stock['Open'],
high=stock['High'],
low=stock['Low'],
close=stock['Close'])])
This was the output:
Process finished with exit code 0
So I get that exit code 0 means there were no errors, but why is there also no graph, and how do I get the graph?
(Separately, why didn’t drop.na() remove the NaNs on the 50 day moving average?)
