当前位置: 首页>>代码示例>>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;未经允许,请勿转载。