J'ai fait un petit utilitaire en python pour combler ce manque. Il télécharge les quotation à partir de google finance.
Code : #
import urllib
import datetime
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter, WeekdayLocator, HourLocator, MinuteLocator, \
DayLocator, MONDAY
from matplotlib.finance import quotes_historical_yahoo, candlestick,\
plot_day_summary, candlestick2
import matplotlib.dates as mdates
import matplotlib.pyplot as PLT
from matplotlib.offsetbox import AnnotationBbox, OffsetImage
from matplotlib._png import read_png
class GoogleIntradayQuote:
''' Intraday quotes from Google. Specify interval seconds and number of days '''
def __init__(self,symbol,interval_seconds=1,num_days=1, exchange=''):
self.quote = []
self.symbol = symbol.upper()
url_string = "http://www.google.com/finance/getprices?q={0}".format(self.symbol)
url_string += "&i={0}&x={2}&p={1}d&f=d,c,h,l,o,v".format(interval_seconds,num_days, exchange)
print 'url ', url_string
csv = urllib.urlopen(url_string).readlines()
for bar in xrange(7,len(csv)):
if csv[bar].count(',')!=5: continue
offset,close,high,low,open_,volume = csv[bar].split(',')
if offset[0]=='a':
day = float(offset[1:])
offset = 0
else:
offset = float(offset)
open_,high,low,close = [float(x) for x in [open_,high,low,close]]
dt = datetime.datetime.fromtimestamp(day+(interval_seconds*offset))
dt = matplotlib.dates.date2num(dt)
# (time, open, close, high, low, ...)
self.quote.append( (dt,open_,close, high,low,volume) )
def arrow(dt, color, level):
x, y = matplotlib.dates.date2num(dt), level
ax.plot(x, y, ".g" if color > 0 else ".b", markersize=15)
def line(x1, y1, x2, y2, buy):
ax.plot( [x1, x2], [y1, y2], "-g" if (y1 < y2) == buy else "-r")
g = GoogleIntradayQuote('DAX', exchange='INDEXDB')
mondays = WeekdayLocator(MONDAY) # major ticks on the mondays
alldays = DayLocator() # minor ticks on the days
allminutes = MinuteLocator()
allhours = HourLocator()
hourFormatter = DateFormatter('%Hh:%M') # e.g., Jan 12
dayFormatter = DateFormatter('%d') # e.g., 12
quotes = g.quote[:]
fig, ax = plt.subplots()
fig.subplots_adjust(bottom=0.05, top=1, left=0.04, right=1)
ax.xaxis.set_major_locator(allhours)
ax.xaxis.set_minor_locator(allminutes)
ax.xaxis.set_major_formatter(hourFormatter)
#ax.xaxis.set_minor_formatter(dayFormatter)
#plot_day_summary(ax, quotes, ticksize=3)
candlestick(ax, quotes, width=0.0003)
ax.xaxis_date()
ax.autoscale_view()
plt.setp( plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
# get orders
orders = np.loadtxt(open("transactions.csv","rb"), delimiter=";",skiprows=1,
dtype = {'names': ('date', 'time', 'sens', 'level', 'name'),
'formats': ('S10', 'S10', 'i4', 'f4', 'S10') }
)
close = False
old_order = None
for order in orders[1:]:
date = datetime.datetime.strptime(order[0] + ' ' + order[1], '%d/%m/%Y %H:%M')
# decalage horraire
date -= datetime.timedelta(hours=-3.5)
arrow(date, color=order[2], level=order[3])
if close:
line( old_order[0], old_order[1], date, order[3], buy=order[2] < 0)
print order, close
old_order = (date, order[3])
close = not close
plt.show()