Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- m_to_int = dict((x, i+1) for i, x in enumerate(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec "]))
- def load():
- data = []
- for l in open('rub-brent-clear.txt'):
- date1str, rusd, date2str, brent = l.rstrip('\r\n').split('\t')
- d,m,y = date1str.replace(',', '').split('-')
- if brent == '-':
- continue
- date2str = date2str.replace(',', '')
- m2,d2,y2 = date2str.replace(',', '').split()
- m2int = m_to_int[m2]
- date1 = datetime.datetime(int(y), int(m), int(d))
- date2 = datetime.datetime(int(y2), int(m2int), int(d2))
- #frequent 2 days delay due holidays
- #print date1 - date2
- data.append((date1, float(rusd.replace(',', '')), float(brent.replace(',', ''))))
- return data
- import pylab, numpy
- def plot(data):
- x, y1, y2 = [],[],[]
- for date, rusd, brent in data:
- x.append(date)
- y1.append(rusd)
- y2.append(20 + 1000.0 / brent)
- A1 = pylab.plot(x, y1)[0]
- A2 = pylab.plot(x, y2)[0]
- pylab.legend([A1, A2], ["USD/RUB", "20 + 1000.0/BRENT"])
- pylab.grid()
- pylab.show()
- data = load()
- plot(data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement