python类strpdate2num()的实例源码

main.py 文件源码 项目:finance-hacking 作者: wellsjo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def graphRawFX():
    date, bid, ask = np.loadtxt('data/GBPUSD1d.txt',
            unpack=True,
            delimiter=',',
            converters={0: mdates.strpdate2num('%Y%m%d%H%M%S')}
            )
    fig = plt.figure(figsize=(10,7))
    ax1 = plt.subplot2grid((40, 40), (0, 0), rowspan=40, colspan=40)
    ax1.plot(date, bid)
    ax1.plot(date, ask)
    plt.gca().get_yaxis().get_major_formatter().set_useOffset(False)
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

    for label in ax1.xaxis.get_ticklabels():
        label.set_rotation(45)

    ax1_2 = ax1.twinx()
    ax1_2.fill_between(date, 0, (ask-bid), facecolor='g', alpha=.3)

    plt.subplots_adjust(bottom=.23)

    plt.grid(True)
    plt.show()
plot_ohlc_example.py 文件源码 项目:ML-Forex-Forecasting 作者: jul1278 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
plot_ohlc.py 文件源码 项目:ML-Forex-Forecasting 作者: jul1278 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        #s = b.decode(encoding)
        return strconverter(b)
    return bytesconverter

# plot_ohlc_range
chart.py 文件源码 项目:rapidpythonprogramming 作者: thecount12 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def gData(stock): 
    stockFile=stock+".txt"
    date,closep,highp,lowp,openp,volume= np.loadtxt(stockFile,delimiter=',',unpack=True,converters={0: mdates.strpdate2num('%Y%m%d')})
    fig=plt.figure() 
    ax1=plt.subplot(1,1,1) # how much by how much by 
    ax1.plot(date,openp) 
    ax1.plot(date,highp) 
    ax1.plot(date,lowp) 
    ax1.plot(date,closep)
    ax1.xaxis.set_major_locator(mticker.MaxNLocator(10)) #max10days 
    ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
    for label in ax1.xaxis.get_ticklabels(): 
        label.set_rotation(45)
    plt.show()
graph.py 文件源码 项目:rapidpythonprogramming 作者: thecount12 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def graphData(stock):
        stockFile=stock+".txt"

        date,closep,highp,lowp,openp,volume= np.loadtxt(stockFile,delimiter=',',unpack=True,
                        converters={0: mdates.strpdate2num('%Y%m%d')})
        fig=plt.figure()
        ax1=plt.subplot(1,1,1) # how much by how much by 
        ax1.plot(date,openp)
        ax1.plot(date,highp)
        ax1.plot(date,lowp)
        ax1.plot(date,closep)

        #pretty it up
        ax1.xaxis.set_major_locator(mticker.MaxNLocator(10)) #max10days
        ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))

        # rotate
        for label in ax1.xaxis.get_ticklabels():
            label.set_rotation(45)


        plt.show()
main.py 文件源码 项目:WaveletQuotes 作者: JobyKK 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
testplot.py 文件源码 项目:WaveletQuotes 作者: JobyKK 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
test.py 文件源码 项目:WaveletQuotes 作者: JobyKK 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def bytespdate2num(fmt, encoding='utf-8'):
    strconverter = mdates.strpdate2num(fmt)
    def bytesconverter(b):
        s = b.decode(encoding)
        return strconverter(s)
    return bytesconverter
csv.py 文件源码 项目:lehrex 作者: lkluft 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def _get_mpl_date(dates, fmt='%d.%m.%Y %H:%M'):
    """Convert date strings into matplotlib time format.

    Parameters:
        dates (ndarray): Array containing date strings.
        fmt (str): Date string format [0].

    [0] http://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html

    Returns:
        np.array: Matplotlib time values.
    """
    return np.array([strpdate2num(fmt)(d) for d in dates])


问题


面经


文章

微信
公众号

扫码关注公众号