git-svn-id: http://moon:8086/svn/projects/Stock@304 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-12-13 19:10:05 +00:00
parent 8bbcc93065
commit a5ce8ff53f
+16 -15
View File
@@ -103,8 +103,9 @@ titles.append('QCOM')
titles.append('DPW.DE') titles.append('DPW.DE')
titles.append('CSCO') titles.append('CSCO')
titles.append('AIR') titles.append('AIR')
titles.append('NVDA')
show_title = 'QCOM' show_title = 'XLNX'
show_range_days = 20 show_range_days = 20
pd.DatetimeIndex pd.DatetimeIndex
@@ -139,6 +140,17 @@ def fetch(title):
data = hdf[title] data = hdf[title]
hdf.close() 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): def show(title):
k_euro = 1/1.11 k_euro = 1/1.11
@@ -156,23 +168,12 @@ def show(title):
data = data_full[len(data_full)-1 - show_range_days:] data = data_full[len(data_full)-1 - show_range_days:]
boll = boll_full[len(boll_full)-1 - show_range_days:] boll = boll_full[len(boll_full)-1 - show_range_days:]
dates = data.index
fig = plt.figure(1) fig = plt.figure(1)
ax = plt.subplot(311) ax = plt.subplot(311)
plot(ax, fig, data['close'])
def hover(event): plot(ax, fig, data['ema'])
if event.inaxes == ax: plot(ax, fig, data['sma'])
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()
plt.title(title) plt.title(title)
plt.legend() plt.legend()
plt.grid() plt.grid()