from pandas_datareader import data import datetime from bokeh.plotting import figure, show, output_file start = datetime.datetime(2015, 11, 1) end = datetime.datetime(2016, 3, 15) df = data.DataReader(name="GOOG", data_source="yahoo", start=start, end=end) date_increase = df.index[df.Close > df.Open] date_decrease = df.index[df.Close < df.Open] def inc_dec(c, o): if c > o: value = "Increase" elif c < o: value = "Decrease" else: value = "Equal" return value df["Status"] = [inc_dec(c, o) for c, o in zip(df.Close, df.Open)] df["Middle"] = (df.Open + df.Close0)/2df["Height"] = abs(df.Close - df.Open) p = figure(x_axis_type='datetime', width=1000, height=1000, sizing_mode="scale_width") p.title = "Candlestick Chart"p.grid.grid_line_alpha = 0.3 hours_12 = 12*60*60*1000 p.segment(df.index, df.High, df.index, df.low, color="black") p.rect(df.index[df.Status == "Increase"], df.Middle(df.Status == "Increase"),
hours_12, df.Height[df.Status == "Increase"], fill_color="#CCFFFF", line_color="black") p.rect(df.index[df.Status == "Decease"], df.Middle(df.Status == "Decrease"),
hours_12, df.Height[df.Status == "Decrease"], fill_color="#FF3333", line_color="black") output_file("CS.html")
The graph came out looking like this:
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more. rastreo satelital
ReplyDelete