Chan
Chan

Reputation: 4291

Plotting a series of stock data in one figure using Python

I would like to plot a candle graph of open, high, low, close of a stock and mark my buy and sell positions over previous 12 months. (Fig 1)

Moreover, I want to put the volumes of the stocks under Fig 1. Let's denote it as Fig2.

Next, the DJIA candle graph in the same period is plotted under Fig 2, denoted as Fig 3.

Under Fig 3, one bar graph and one line graph are plotted (Fig 4 and Fig 5).

Finally, the x-values representing the time period is shown.

Is there any good library to do the task?

Thank you.

Upvotes: 0

Views: 738

Answers (1)

kpie
kpie

Reputation: 11080

It's funny how these questions don't get too much love... Anyway I was looking into market data recently and I know python can do nice violin plots with pandas and seaborne. The following snippet produces the attached images.

from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
import seaborn as sns
import matplotlib.pyplot as plt
yf.pdr_override() # <== that's all it takes :-)

# download Panel
tags = ["SPY", "AMZN"]
data = pdr.get_data_yahoo(tags, start="2017-01-01", end="2017-01-30")

#print(data["Open"]["AMZN"])
print(data)

sns.violinplot(x=data["Close"]["AMZN"].values, palette="muted")
plt.show()
sns.violinplot(x=data["Close"]["SPY"].values, palette="muted")
plt.show()

Amazon Stock price violin from January 2017 SPY Stock price violin from January 2017

Upvotes: 1

Related Questions