当前位置: 首页>>代码示例>>Python>>正文


Python mpl_finance.volume_overlay方法代码示例

本文整理汇总了Python中mpl_finance.volume_overlay方法的典型用法代码示例。如果您正苦于以下问题:Python mpl_finance.volume_overlay方法的具体用法?Python mpl_finance.volume_overlay怎么用?Python mpl_finance.volume_overlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpl_finance的用法示例。


在下文中一共展示了mpl_finance.volume_overlay方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _plotNetCapitalFlow

# 需要导入模块: import mpl_finance [as 别名]
# 或者: from mpl_finance import volume_overlay [as 别名]
def _plotNetCapitalFlow(self, df, ax, code):
        try:
            mf = df['mf_amt'].values

            close = df['close'].values.copy()
            open = df['open'].values.copy()

            close[mf>0] = 1; open[mf>0] = 0
            close[mf<=0] = 0; open[mf<=0] = 1

            volume_overlay(ax, open, close, abs(mf)/10**7, colorup='r', colordown='g', width=.5, alpha=1)

        except KeyError:
            # !!!刚上市新股的前几个交易日,有时万得没有资金净流入和成交量净流入的日线数据
            #self._info.print('[{0}: {1}]没有日线[资金净流入]数据'.format(code, self._daysEngine.stockAllCodesFunds[code]), DyLogData.warning)
            pass 
开发者ID:moyuanz,项目名称:DevilYuan,代码行数:18,代码来源:DyStockDataViewer.py

示例2: _plotKamaCandleStick

# 需要导入模块: import mpl_finance [as 别名]
# 或者: from mpl_finance import volume_overlay [as 别名]
def _plotKamaCandleStick(self, code, periods, left=None, right=None, top=None, bottom=None):
        def _dateFormatter(x, pos):
            if not (0 <= int(x) < df.shape[0]):
                return None

            return df.index[int(x)].strftime("%y-%m-%d")

        # get DataFrame
        df = self._daysEngine.getDataFrame(code)
        #maDf = DyStockDataUtility.getKamas(df, [5, 10], False)
        maDf = DyStockDataUtility.getDealMas(df, [5, 10, 20, 30, 60], False)

        # 数据对齐
        df = df.ix[periods]
        maDf = maDf.ix[periods]

        if df.shape[0] == 0 or maDf.shape[0] == 0:
            return

        # create grid spec
        gs = GridSpec(4, 1)
        gs.update(left=left, right=right, top=top, bottom=bottom, hspace=0)

        # subplot for price candle stick
        axPrice = plt.subplot(gs[:-1, :])
        axPrice.set_title('{0}({1}),考夫曼指标'.format(self._daysEngine.stockAllCodesFunds[code], code))
        axPrice.grid(True)

        # set x ticks
        x = [x for x in range(df.shape[0])]
        xspace = max((len(x)+9)//10, 1)
        axPrice.xaxis.set_major_locator(FixedLocator(x[:-xspace-1: xspace] + x[-1:]))
        axPrice.xaxis.set_major_formatter(FuncFormatter(_dateFormatter))

        # plot K-chart
        candlestick2_ohlc(axPrice, df['open'].values, df['high'].values, df['low'].values, df['close'].values, width=.9, colorup='r', colordown='g', alpha =1)

        # plot MAs
        for ma in maDf.columns:
            axPrice.plot(x, maDf[ma].values, label=ma)

        # plot volume
        axVolume = plt.subplot(gs[-1, :], sharex=axPrice)
        axVolume.grid(True)
        volume_overlay(axVolume, df['open'].values, df['close'].values, df['volume'].values/10**6, colorup='r', colordown='g', width=.9, alpha=1)

        axPrice.legend(loc='upper left', frameon=False) 
开发者ID:moyuanz,项目名称:DevilYuan,代码行数:49,代码来源:DyStockDataViewer.py

示例3: ohlc2cs

# 需要导入模块: import mpl_finance [as 别名]
# 或者: from mpl_finance import volume_overlay [as 别名]
def ohlc2cs(fname, dimension):
    # python preprocess.py -m ohlc2cs -l 20 -i stockdatas/EWT_testing.csv -t testing
    print("Converting olhc to candlestick")
    inout = fname
    df = pd.read_csv(fname, parse_dates=True, index_col=0)
    df.fillna(0)
    plt.style.use('dark_background')
    df.reset_index(inplace=True)
    df['Date'] = df['Date'].map(mdates.date2num)
    my_dpi = 96
    fig = plt.figure(figsize=(dimension / my_dpi,
                              dimension / my_dpi), dpi=my_dpi)
    ax1 = fig.add_subplot(1, 1, 1)
    candlestick2_ochl(ax1, df['Open'], df['Close'], df['High'],
                      df['Low'], width=1,
                      colorup='#77d879', colordown='#db3f3f')
    ax1.grid(False)
    ax1.set_xticklabels([])
    ax1.set_yticklabels([])
    ax1.xaxis.set_visible(False)
    ax1.yaxis.set_visible(False)
    ax1.axis('off')

    # create the second axis for the volume bar-plot
    # Add a seconds axis for the volume overlay
    ax2 = ax1.twinx()
    # Plot the volume overlay
    bc = volume_overlay(ax2, df['Open'], df['Close'], df['Volume'],
                        colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
    ax2.add_collection(bc)
    ax2.grid(False)
    ax2.set_xticklabels([])
    ax2.set_yticklabels([])
    ax2.xaxis.set_visible(False)
    ax2.yaxis.set_visible(False)
    ax2.axis('off')
    pngfile = "temp_class/{}.png".format(inout)
    fig.savefig(pngfile,  pad_inches=0, transparent=False)
    plt.close(fig)
    # normal length - end
    params = []
    params += ["-alpha", "off"]

    subprocess.check_call(["convert", pngfile] + params + [pngfile])
    print("Converting olhc to candlestik finished.") 
开发者ID:jason887,项目名称:Using-Deep-Learning-Neural-Networks-and-Candlestick-Chart-Representation-to-Predict-Stock-Market,代码行数:47,代码来源:predictme.py

示例4: ohlc2cs

# 需要导入模块: import mpl_finance [as 别名]
# 或者: from mpl_finance import volume_overlay [as 别名]
def ohlc2cs(fname, seq_len, dataset_type, dimension):
    print("Converting olhc to candlestick")
    symbol = fname.split('_')[0]
    symbol = symbol.split('/')[1]
    print(symbol)
    path = "{}".format(os.getcwd())
    # print(path)
    if not os.path.exists("{}/dataset/{}_{}/{}/{}".format(path, seq_len, dimension, symbol, dataset_type)):
        os.makedirs("{}/dataset/{}_{}/{}/{}".format(path,
                                                    seq_len, dimension, symbol, dataset_type))

    df = pd.read_csv(fname, parse_dates=True, index_col=0)
    df.fillna(0)
    plt.style.use('dark_background')
    df.reset_index(inplace=True)
    df['Date'] = df['Date'].map(mdates.date2num)
    for i in range(0, len(df)):
        # normal length - begin
        # candlestick ohlc normal
        c = df.ix[i:i + int(seq_len) - 1, :]
        # ohlc+volume
        useVolume = True
        if len(c) == int(seq_len):
            my_dpi = 96
            fig = plt.figure(figsize=(dimension / my_dpi,
                                      dimension / my_dpi), dpi=my_dpi)
            ax1 = fig.add_subplot(1, 1, 1)
            candlestick2_ochl(ax1, c['Open'], c['Close'], c['High'],
                              c['Low'], width=1,
                              colorup='#77d879', colordown='#db3f3f')
            ax1.grid(False)
            ax1.set_xticklabels([])
            ax1.set_yticklabels([])
            ax1.xaxis.set_visible(False)
            ax1.yaxis.set_visible(False)
            ax1.axis('off')

            # create the second axis for the volume bar-plot
            # Add a seconds axis for the volume overlay
            if useVolume:
                ax2 = ax1.twinx()
                # Plot the volume overlay
                bc = volume_overlay(ax2, c['Open'], c['Close'], c['Volume'],
                                    colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
                ax2.add_collection(bc)
                ax2.grid(False)
                ax2.set_xticklabels([])
                ax2.set_yticklabels([])
                ax2.xaxis.set_visible(False)
                ax2.yaxis.set_visible(False)
                ax2.axis('off')
            pngfile = 'dataset/{}_{}/{}/{}/{}-{}_combination.png'.format(
                seq_len, dimension, symbol, dataset_type, fname[11:-4], i)
            fig.savefig(pngfile,  pad_inches=0, transparent=False)
            plt.close(fig)

    print("Converting olhc to candlestik finished.") 
开发者ID:jason887,项目名称:Using-Deep-Learning-Neural-Networks-and-Candlestick-Chart-Representation-to-Predict-Stock-Market,代码行数:59,代码来源:preproccess_binclass.py

示例5: ohlc2cs

# 需要导入模块: import mpl_finance [as 别名]
# 或者: from mpl_finance import volume_overlay [as 别名]
def ohlc2cs(fname, seq_len, dataset_type, dimension, use_volume):
    # python preprocess.py -m ohlc2cs -l 20 -i stockdatas/EWT_testing.csv -t testing
    print("Converting olhc to candlestick")
    symbol = fname.split('_')[0]
    symbol = symbol.split('/')[1]
    print(symbol)
    path = "{}".format(os.getcwd())
    # print(path)
    if not os.path.exists("{}/dataset/{}_{}/{}/{}".format(path, seq_len, dimension, symbol, dataset_type)):
        os.makedirs("{}/dataset/{}_{}/{}/{}".format(path,
                                                    seq_len, dimension, symbol, dataset_type))

    df = pd.read_csv(fname, parse_dates=True, index_col=0)
    df.fillna(0)
    plt.style.use('dark_background')
    df.reset_index(inplace=True)
    df['Date'] = df['Date'].map(mdates.date2num)
    for i in range(0, len(df)):
        # ohlc+volume
        c = df.ix[i:i + int(seq_len) - 1, :]
        if len(c) == int(seq_len):
            my_dpi = 96
            fig = plt.figure(figsize=(dimension / my_dpi,
                                      dimension / my_dpi), dpi=my_dpi)
            ax1 = fig.add_subplot(1, 1, 1)
            candlestick2_ochl(ax1, c['Open'], c['Close'], c['High'],
                              c['Low'], width=1,
                              colorup='#77d879', colordown='#db3f3f')
            ax1.grid(False)
            ax1.set_xticklabels([])
            ax1.set_yticklabels([])
            ax1.xaxis.set_visible(False)
            ax1.yaxis.set_visible(False)
            ax1.axis('off')

            # create the second axis for the volume bar-plot
            # Add a seconds axis for the volume overlay
            if use_volume:
                ax2 = ax1.twinx()
                # Plot the volume overlay
                bc = volume_overlay(ax2, c['Open'], c['Close'], c['Volume'],
                                    colorup='#77d879', colordown='#db3f3f', alpha=0.5, width=1)
                ax2.add_collection(bc)
                ax2.grid(False)
                ax2.set_xticklabels([])
                ax2.set_yticklabels([])
                ax2.xaxis.set_visible(False)
                ax2.yaxis.set_visible(False)
                ax2.axis('off')
            pngfile = 'dataset/{}_{}/{}/{}/{}-{}.png'.format(
                seq_len, dimension, symbol, dataset_type, fname[11:-4], i)
            fig.savefig(pngfile, pad_inches=0, transparent=False)
            plt.close(fig)
        # normal length - end

    print("Converting olhc to candlestik finished.") 
开发者ID:rosdyana,项目名称:Going-Deeper-with-Convolutional-Neural-Network-for-Stock-Market-Prediction,代码行数:58,代码来源:preproccess_binclass.py


注:本文中的mpl_finance.volume_overlay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。