improved
git-svn-id: http://moon:8086/svn/projects/Stock@304 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
+16
-15
@@ -103,8 +103,9 @@ titles.append('QCOM')
|
||||
titles.append('DPW.DE')
|
||||
titles.append('CSCO')
|
||||
titles.append('AIR')
|
||||
titles.append('NVDA')
|
||||
|
||||
show_title = 'QCOM'
|
||||
show_title = 'XLNX'
|
||||
show_range_days = 20
|
||||
|
||||
pd.DatetimeIndex
|
||||
@@ -139,6 +140,17 @@ def fetch(title):
|
||||
data = hdf[title]
|
||||
hdf.close()
|
||||
|
||||
def plot(ax, fig, data):
|
||||
dates = data.index
|
||||
data.plot()
|
||||
def hover(event):
|
||||
if event.inaxes == ax:
|
||||
x_idx = int(event.xdata)
|
||||
ax.format_xdata = lambda x: dates[x_idx]
|
||||
ax.format_ydata = lambda y: '{:.2f}'.format(data[x_idx])
|
||||
|
||||
fig.canvas.mpl_connect("motion_notify_event", hover)
|
||||
|
||||
def show(title):
|
||||
|
||||
k_euro = 1/1.11
|
||||
@@ -156,23 +168,12 @@ def show(title):
|
||||
|
||||
data = data_full[len(data_full)-1 - show_range_days:]
|
||||
boll = boll_full[len(boll_full)-1 - show_range_days:]
|
||||
dates = data.index
|
||||
|
||||
fig = plt.figure(1)
|
||||
|
||||
ax = plt.subplot(311)
|
||||
|
||||
def hover(event):
|
||||
if event.inaxes == ax:
|
||||
x_idx = int(event.xdata)
|
||||
ax.format_xdata = lambda x: dates[x_idx]
|
||||
ax.format_ydata = lambda y: '{:.2f}'.format(data['close'][x_idx])
|
||||
|
||||
fig.canvas.mpl_connect("motion_notify_event", hover)
|
||||
|
||||
data['close'].plot()
|
||||
data['ema'].plot()
|
||||
data['sma'].plot()
|
||||
plot(ax, fig, data['close'])
|
||||
plot(ax, fig, data['ema'])
|
||||
plot(ax, fig, data['sma'])
|
||||
plt.title(title)
|
||||
plt.legend()
|
||||
plt.grid()
|
||||
|
||||
Reference in New Issue
Block a user