Python matplotlib.finance() Examples
The following are 3 code examples for showing how to use matplotlib.finance(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example 1
Project: OpenTrader Author: OpenTrading File: OTPpnAmgc.py License: GNU Lesser General Public License v3.0 | 6 votes |
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'
Example 2
Project: deep-learning-bitcoin Author: philipperemy File: utils.py License: Apache License 2.0 | 5 votes |
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.')
Example 3
Project: deep-learning-bitcoin Author: philipperemy File: utils.py License: Apache License 2.0 | 5 votes |
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)