Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show a legend for plotted values #408

Closed
Seneo1 opened this issue Jun 15, 2021 · 1 comment
Closed

Show a legend for plotted values #408

Seneo1 opened this issue Jun 15, 2021 · 1 comment
Labels
question Further information is requested

Comments

@Seneo1
Copy link

Seneo1 commented Jun 15, 2021

import yfinance as yf, datetime as dt
ticker = "AAPL"
df = pd.DataFrame()
start = dt.datetime.today() - dt.timedelta(1825)
end = dt.datetime.today()
df[ticker] = yf.download(ticker, start, end)["Adj Close"]
df.fillna(method='bfill', axis=0, inplace=True)
df['200-day Exponential MA'] = df.ewm(span=200, adjust=False).mean()
df['50-day Exponential MA'] = df[ticker].ewm(span=50, adjust=False).mean()
df.plot()

This displays a plot with a legend of the ticker and a description of the moving averages. Does mplfinance have the same function?
chart

import mplfinance as mpf
df = yf.download(ticker, start, end)
mpf.plot(df, volume=True, tight_layout=True, style="binance", type="candle", mav=(50,200))

Because although this plots the averages, it is up to the viewer to guess which MA is which, and someone unfamiliar with the code would not be able to tell if it is an exponential or simple moving average.
chart2

@Seneo1 Seneo1 added the question Further information is requested label Jun 15, 2021
@DanielGoldfarb
Copy link
Collaborator

duplicate of #276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants