def Plot(self): # Create ZeroLine zeroLine = CreateHorizontalLine(self.macd.index, 0, 0) # Plot backgrounds x_axis = self.toNumIndex(self.signal) plt.fill_between(x_axis, self.signal, self.macd, where=self.signal < self.macd, color='#b3ffb3') plt.fill_between(x_axis, self.signal, self.macd, where=self.signal >= self.macd, color='#ffb3b3') # Plot plt.plot(self.toNumIndex(zeroLine), zeroLine, '--', color='#777777') plt.plot(self.toNumIndex(self.macd), self.macd, label='AMD MACD', linewidth=1.0, color='#FF0000') plt.plot(self.toNumIndex(self.signal), self.signal, label='Signal Line', linewidth=1.0, color='#008800') # Signals plottting if (self.buy is not None and self.buy.size): plt.plot(self.toNumIndex(self.buy), self.buy, 'o', color='#000000', ms=8) plt.plot(self.toNumIndex(self.buy), self.buy, 'o', label='Buy', color='#00FF00') if (self.sell is not None and self.sell.size): plt.plot(self.toNumIndex(self.sell), self.sell, 'o', color='#000000', ms=8) plt.plot(self.toNumIndex(self.sell), self.sell, 'o', label='Sell', color='#FF0000') # Plot trend lines upTrends = trend(self.macd, 'rising') downTrends = trend(self.macd, 'falling') upTrends.Plot('green', 'rising', 0.6) downTrends.Plot('red', 'falling', 0.6)
def Plot(self): # Base 50% line line50 = CreateHorizontalLine(self.rsi.index, 50, 50) plt.plot(self.toNumIndex(line50), line50, '-.', linewidth=1.0, color='#333333') # RSI plt.plot(self.toNumIndex(self.rsi), self.rsi, label='RSI' + str(self.n), linewidth=1.0, color='#000000') x_axis = self.toNumIndex(self.rsi) # OverBought overBought = CreateHorizontalLine(self.rsi.index, 70, 70, True) plt.plot(self.toNumIndex(overBought), overBought, '--', label='Overbought', color='#940006') plt.fill_between(x_axis, self.rsi, overBought['value'], where=self.rsi >= overBought['value'], color='#ffb3b3') # OverSold overSold = CreateHorizontalLine(self.rsi.index, 30, 30, True) plt.plot(self.toNumIndex(overSold), overSold, '--', label='Oversold', color='#169400') plt.fill_between(x_axis, self.rsi, overSold['value'], where=self.rsi <= overSold['value'], color='#b3ffb3') # Trend to Fall if (self.trendToFall.size): plt.plot(self.toNumIndex(self.trendToFall), self.trendToFall, '*', label='ToFall', color='#FFFF00') # Trend to Rise if (self.trendToRise.size): plt.plot(self.toNumIndex(self.trendToRise), self.trendToRise, '*', label='ToRise', color='#00FFFF') # May buy 50 if (self.fromBottom50.size): plt.plot(self.toNumIndex(self.fromBottom50), self.fromBottom50, 'go', label='MayBuy') # Plot trend lines upTrends = trend(self.rsi, 'rising') downTrends = trend(self.rsi, 'falling') upTrends.Plot('green', 'rising', 0.6) downTrends.Plot('red', 'falling', 0.6) plt.ylim(top=100, bottom=0)
plot2A = plot2.twinx() plot2A.plot(toNumIndex(obvTotal.index, obvTotal), obvTotal, label='OBV total') plot2A.legend(loc='upper left') plot2A.tick_params(axis='y', labelcolor='tab:blue') # Money on market - ALL if (stockData.hasVolume()): plot2B = plot2.twinx() stockData.PlotMoneyOnMarketAll(plot2B) plot2B.tick_params(axis='y', labelcolor='tab:red') plt.legend(loc='upper left') period = 2 upTrends = trend(stockData.GetData('Low'), 'rising') downTrends = trend(stockData.GetData('High'), 'falling') # Price OHLC plot3 = plt.subplot(gs[2:5, :]) bollinger.Plot() stockData.PlotCandle(plot3) stockData.PlotAssets() plt.ylabel('Price (%s)' % (info.GetCurrency())) plt.grid() plt.legend(loc='upper left') # Plot trend lines upTrends.Plot('green', 'rising', annotate=True) downTrends.Plot('red', 'falling', annotate=True) # Add return rates axle stockData.AddReturnRatesAxle(plot3)
def Plot(self): # Stoch %K and %D plt.plot(self.toNumIndex(self.k), self.k, label='%K' + str(self.n), linewidth=1.0, color='blue') plt.plot(self.toNumIndex(self.d), self.d, label='%D' + str(self.d_n), linewidth=1.0, color='red') x_axis = self.toNumIndex(self.k) # OverBought overBought = CreateHorizontalLine(self.k.index, self.overBoughtLvl, self.overBoughtLvl, True) plt.plot(self.toNumIndex(overBought), overBought, '--', label='Overbought', color='#940006') plt.fill_between(x_axis, self.k, overBought['value'], where=self.k >= overBought['value'], color='#ffb3b3') # OverSold overSold = CreateHorizontalLine(self.k.index, self.overSellLvl, self.overSellLvl, True) plt.plot(self.toNumIndex(overSold), overSold, '--', label='Oversold', color='#169400') plt.fill_between(x_axis, self.k, overSold['value'], where=self.k <= overSold['value'], color='#b3ffb3') # Signals plottting if (self.buy is not None and self.buy.size): plt.plot(self.toNumIndex(self.buy), self.buy, 'o', color='#000000', ms=8) plt.plot(self.toNumIndex(self.buy), self.buy, 'o', label='Buy', color='#00FF00') if (self.sell is not None and self.sell.size): plt.plot(self.toNumIndex(self.sell), self.sell, 'o', color='#000000', ms=8) plt.plot(self.toNumIndex(self.sell), self.sell, 'o', label='Sell', color='#FF0000') # Plot trend lines upTrends = trend(self.k, 'rising') downTrends = trend(self.k, 'falling') upTrends.Plot('green', 'rising', 0.6) downTrends.Plot('red', 'falling', 0.6) plt.ylim(top=100, bottom=0)