當前位置: 首頁>>代碼示例>>Python>>正文


Python finance.candlestick_ohlc方法代碼示例

本文整理匯總了Python中matplotlib.finance.candlestick_ohlc方法的典型用法代碼示例。如果您正苦於以下問題:Python finance.candlestick_ohlc方法的具體用法?Python finance.candlestick_ohlc怎麽用?Python finance.candlestick_ohlc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.finance的用法示例。


在下文中一共展示了finance.candlestick_ohlc方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _candlestick_ax

# 需要導入模塊: from matplotlib import finance [as 別名]
# 或者: from matplotlib.finance import candlestick_ohlc [as 別名]
def _candlestick_ax(df, ax):
    quotes = df.reset_index()
    quotes.loc[:, 'datetime'] = mdates.date2num(quotes.loc[:, 'datetime'].astype(dt.date))
    fplt.candlestick_ohlc(ax, quotes.values, width=0.4, colorup='red', colordown='green') 
開發者ID:X0Leon,項目名稱:XQuant,代碼行數:6,代碼來源:chart.py

示例2: _get_plot_function

# 需要導入模塊: from matplotlib import finance [as 別名]
# 或者: from matplotlib.finance import candlestick_ohlc [as 別名]
def _get_plot_function(self):
        try:
            from mpl_finance import candlestick_ohlc
        except ImportError as e:
            try:
                from matplotlib.finance import candlestick_ohlc
            except ImportError:
                raise ImportError(e)

        def _plot(data, ax, **kwds):
            candles = candlestick_ohlc(ax, data.values, **kwds)
            return candles

        return _plot 
開發者ID:sinhrks,項目名稱:japandas,代碼行數:16,代碼來源:plotting.py

示例3: candle_show

# 需要導入模塊: from matplotlib import finance [as 別名]
# 或者: from matplotlib.finance import candlestick_ohlc [as 別名]
def candle_show(self, stock_data, scatter_data):
    # 創建子圖
    fig, ax = plt.subplots(figsize=(192.0 / 72, 108.0 / 72))
    mpf.candlestick_ohlc(ax, stock_data, width=self.width, colordown=self.colordown, colorup=self.colorup, alpha=1)
    ax.grid(True)
    plt.show() 
開發者ID:xbfighting,項目名稱:ChZhShCh,代碼行數:8,代碼來源:plot_test.py

示例4: candle_show

# 需要導入模塊: from matplotlib import finance [as 別名]
# 或者: from matplotlib.finance import candlestick_ohlc [as 別名]
def candle_show(self, stock_data, top_bottom_data):

        # 創建子圖
        fig, ax = plt.subplots(figsize=(192.0 / 72, 108.0 / 72))
        ax.xaxis.set_major_locator(ticker.MultipleLocator(self.xaxis_cycle))
        ax.xaxis.set_major_formatter(ticker.FuncFormatter(self.__format_date))
        mpf.candlestick_ohlc(ax, stock_data, width=self.width, colordown=self.colordown, colorup=self.colorup, alpha=1)

        # title 各種設置
        plt.rcParams['font.sans-serif'] = ['SimHei']
        plt.rcParams['axes.unicode_minus'] = False

        plt.title(self.title)
        plt.xlabel(self.xlabel)
        plt.ylabel(self.ylabel)

        # 頂底、圖例等
        if len(top_bottom_data) > 0:
            x = []
            y = []
            for i in top_bottom_data:
                x.append(i[0])
                y.append(i[1])
            plt.plot(x, y, '--y*', label='分筆')
            plt.legend()  # 展示圖例

        ax.grid(True)
        # plt.savefig('E:\PythonChZhShCh\\' + code + k_type + start_date + end_date + '.png')
        plt.show()

    # MA 畫圖 
開發者ID:xbfighting,項目名稱:ChZhShCh,代碼行數:33,代碼來源:show.py

示例5: draw

# 需要導入模塊: from matplotlib import finance [as 別名]
# 或者: from matplotlib.finance import candlestick_ohlc [as 別名]
def draw(self, number, length = CANDLE_FIG_LENGTH):

        reader = Reader(number)
        series = [[] for x in xrange(7)]

        # Candle Stick
        candle_sticks = []

        idx = -1
        while True:
            idx +=1 
            row = reader.getInput()
            if row == None: break
            for i in [1, 3, 4, 5, 6]:
                series[i].append(float(row[i]))
                # matplotlib 的 candlestick_ohlc 依序放入 [編號, 收盤, 最高, 最低, 開盤] 會畫出 K 線圖
            candle_sticks.append((
                idx,
                float(row[6]),
                float(row[4]),
                float(row[5]),
                float(row[3])
            ))            
            
        bool_up_series, ma_series, bool_down_series = self._getBooleanBand(series[6])
        
        # Draw Figure
        line_width = CANDLE_FIG_LINE_WIDTH
        
        fig, axarr = plt.subplots(2, sharex=True)

        candlestick_ohlc(axarr[0], candle_sticks[-length:], width=CANDLE_STICK_WIDTH)
        
        x_axis = range(len(series[6]))
        # set zorder 讓 candlestick 可以在上麵
        axarr[0].plot(x_axis[-length:], ma_series[-length:], c='#00ff00', ls='-', lw=line_width, zorder=-5)
        axarr[0].plot(x_axis[-length:], bool_up_series[-length:], c='#ff0000', ls='-', lw=line_width, zorder=-4)
        axarr[0].plot(x_axis[-length:], bool_down_series[-length:], c='#0000ff', ls='-', lw=line_width, zorder=-3)
        axarr[0].plot(x_axis[-length:], series[4][-length:], c='#ff3399', ls='-', lw=line_width, zorder=-2)
        axarr[0].plot(x_axis[-length:], series[5][-length:], c='#0099ff', ls='-', lw=line_width, zorder=-1)
        
        axarr[0].set_title(self._getFigTitle(number))
        
        axarr[1].plot(x_axis[-length:], series[1][-length:], c='#000000', ls='-', lw=line_width)
        
        # set figure arguments
        fig.set_size_inches(FIGURE_WIDTH, FIGURE_HEIGHT)

        # output figure
        
        fig.savefig(CANDLE_FIG_PATH+'/'+number+'.png', dpi=FIGURE_DPI)

        plt.clf()
        plt.close('all') 
開發者ID:Asoul,項目名稱:stockflow,代碼行數:56,代碼來源:CandleDrawer.py


注:本文中的matplotlib.finance.candlestick_ohlc方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。