예제 #1
0
 def PlotMoneyOnMarketAll(self, ax):
     ax.plot(toNumIndex(self.dataSubset.index, self.data['Money']),
             self.data['Money'],
             '-.',
             label='Money on market',
             linewidth=1.2,
             color='#FF0000')
예제 #2
0
 def PlotPriceLine(self, ax, price):
     '''
      price - dataframe/series with price values and indexes,
     '''
     pos = price.index.get_loc(price.index.max())
     # Draw line
     priceLine = CreateHorizontalLine(price.index, price.values[pos],
                                      price.values[pos])
     xindex = toNumIndex(price.index, priceLine)
     ax.plot(xindex,
             priceLine,
             '--',
             color='#000000',
             linewidth=1.0,
             alpha=0.6)
     # Draw annotation
     bbox_props = dict(boxstyle='larrow,pad=0.3',
                       fc='w',
                       ec='0.5',
                       alpha=0.6)
     ax.annotate('%2.2f' % price.values[pos],
                 xy=(pos, price.values[pos]),
                 xytext=(15, -3),
                 textcoords='offset points',
                 bbox=bbox_props)
예제 #3
0
 def toNumIndex(self, df):
     ''' Changed df index to numbers index
         calculated from base DateTime
     '''
     import pandas as pd
     if (type(df) is pd.DataFrame) or (type(df) is pd.Series):
         return toNumIndex(self.index, df)
     return self.index.get_loc(df)
예제 #4
0
# PLOT 1
# #####################################################
# #####################################################
plot2 = plt.subplot(gs[0:2, :])
stockData.PlotAll(plot2)
stockData.PlotAllAssets(plot2)
plt.ylabel('Price (%s)' % (info.GetCurrency()))
plt.grid()
plt.title('%s - History' % stockData.GetStockCode())
plt.legend(loc='upper left')

# OBV - ALL
if (stockData.hasVolume()):
    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')