## Market Profile Chart using Python!

Continuing from the earlier code where I created the profile data using 'Alphabets, here let me try to plot the chart. This one turned out bit tricky and used an example snippet from Matplotlib for stacked bar chart!Logic is simple, instead of Alphabets, have an a number for each occurrence, use Matplotlib stacked bar chart to plot the colors.mi=defaultdict(list) TGroups=df.groupby([pd.Grouper(key='DateTime', freq=frequency)]) #iterate over each group and add to dictionary, #dictonary keys are 'High' and 'Low' of each group, #rounded and values are char A, B incremented for each period(freq group) #default 30 min since we grouped based on freq, #for each group increment the char i.e +1 min_price=np.round(df.min().Low) max_price=np.round(df.max().High) for t,g in TGroups: g_min_price=np.round(g.Low.min()) g_max_price=np.round(g.High.max()) for price in range(int(min_price), int(max_price+1)): if (price > g_max_price) or (price < g_min_price): mi[price].append(0) else:…