|
1 | | -## Plot the stock price with some technical indicators |
2 | | -## Example usage:: |
3 | | -## python stocks2.py --ticker=GE --startdate=2003 |
4 | | -## |
5 | | -import datetime, os, urllib, optparse |
| 1 | +import datetime |
6 | 2 | import numpy as np |
7 | | -import dateutil.parser |
8 | 3 | import matplotlib.colors as colors |
9 | 4 | import matplotlib.finance as finance |
10 | 5 | import matplotlib.dates as mdates |
|
13 | 8 | import matplotlib.pyplot as plt |
14 | 9 | import matplotlib.font_manager as font_manager |
15 | 10 |
|
16 | | -today = datetime.date.today() |
17 | 11 |
|
18 | | -optionparser = optparse.OptionParser() |
19 | | - |
20 | | -optionparser.add_option('-t', '--ticker', |
21 | | - dest='ticker', |
22 | | - help='a stock market ticker', |
23 | | - default='SPY') |
24 | | - |
25 | | -optionparser.add_option('-s', '--startdate', |
26 | | - dest='startdate', |
27 | | - help='the start date', |
28 | | - default=(today-datetime.timedelta(days=365*2)).strftime('%Y-%m-%d')) |
29 | | - |
30 | | -optionparser.add_option('-e', '--enddate', |
31 | | - dest='enddate', |
32 | | - help='the end date', |
33 | | - default=today.strftime('%Y-%m-%d')) |
34 | | - |
35 | | - |
36 | | -(commandoptions, commandargs) = optionparser.parse_args() |
37 | | - |
38 | | - |
39 | | -startdate = dateutil.parser.parse(commandoptions.startdate) |
40 | | -enddate = dateutil.parser.parse(commandoptions.enddate) |
41 | | -ticker = commandoptions.ticker |
| 12 | +startdate = datetime.date(2006,1,1) |
| 13 | +today = enddate = datetime.date.today() |
| 14 | +ticker = 'SPY' |
42 | 15 |
|
43 | 16 |
|
44 | 17 | fh = finance.fetch_historical_yahoo(ticker, startdate, enddate) |
|
0 commit comments