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


Python matplotlib.finance方法代碼示例

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


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

示例1: lPullYahooToTxtfile

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import finance [as 別名]
def lPullYahooToTxtfile(sSymbol):
    '''
        Use this to dynamically pull a sSymbol:
    '''
    try:
        print 'Currently Pulling', sSymbol
        print str(datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S'))
        #Keep in mind this is close high low open, lol.
        urlToVisit = 'http://chartapi.finance.yahoo.com/instrument/1.0/'+sSymbol+'/chartdata;type=quote;range=10y/csv'
        lStockLines = []
        try:
            sourceCode = urllib2.urlopen(urlToVisit).read()
            splitSource = sourceCode.split('\n')
            for eachLine in splitSource:
                splitLine = eachLine.split(',')
                if len(splitLine) == 6:
                    if 'values' not in eachLine:
                        lStockLines.append(eachLine)
            return lStockLines
        except Exception as e:
            print str(e), 'failed to organize pulled data.'
    except StandardError, e:
        print str(e), 'failed to pull pricing data' 
開發者ID:OpenTrading,項目名稱:OpenTrader,代碼行數:25,代碼來源:OTPpnAmgc.py

示例2: plot_p

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import finance [as 別名]
def plot_p(df):
    import matplotlib.pyplot as plt
    from matplotlib.finance import candlestick2_ohlc
    fig, ax = plt.subplots()
    candlestick2_ohlc(ax,
                      df['price_open'].values,
                      df['price_high'].values,
                      df['price_low'].values,
                      df['price_close'].values,
                      width=0.6,
                      colorup='g',
                      colordown='r',
                      alpha=1)
    plt.show()
    print('Done.') 
開發者ID:philipperemy,項目名稱:deep-learning-bitcoin,代碼行數:17,代碼來源:utils.py

示例3: save_to_file

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import finance [as 別名]
def save_to_file(df, filename):
    import matplotlib.pyplot as plt
    from matplotlib.finance import candlestick2_ohlc
    fig, ax = plt.subplots()
    candlestick2_ohlc(ax,
                      df['price_open'].values,
                      df['price_high'].values,
                      df['price_low'].values,
                      df['price_close'].values,
                      width=0.6,
                      colorup='g',
                      colordown='r',
                      alpha=1)
    plt.savefig(filename)
    plt.close(fig) 
開發者ID:philipperemy,項目名稱:deep-learning-bitcoin,代碼行數:17,代碼來源:utils.py


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