Python matplotlib.finance() Examples
The following are 3
code examples of matplotlib.finance().
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 also want to check out all available functions/classes of the module
matplotlib
, or try the search function
.
Example #1
Source File: OTPpnAmgc.py From OpenTrader with 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
Source File: utils.py From deep-learning-bitcoin with 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
Source File: utils.py From deep-learning-bitcoin with 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)