- fixed crash on open file

git-svn-id: http://moon:8086/svn/projects/Stock@311 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-12-13 23:06:48 +00:00
parent b44c85746c
commit f16458d797
+6 -3
View File
@@ -20,10 +20,11 @@ import os
# https://ntguardian.wordpress.com/2016/09/19/introduction-stock-market-data-python-1 # https://ntguardian.wordpress.com/2016/09/19/introduction-stock-market-data-python-1
key = '0UO7Z2MVZ2YSQSVE' key = '0UO7Z2MVZ2YSQSVE'
thresh_macd = 2.0 thresh_macd = 1.0
show_range_days = 20 show_range_days = 20
show_title = ['QCOM', 'CSCO'] show_title = ['SIE.DE']
k_euro = 1 / 1.11 k_euro = 1 / 1.11
N_poly = 7
titles = [ titles = [
'AAPL', 'AAPL',
@@ -188,6 +189,7 @@ class Symbol(object):
today = dt.date.today() today = dt.date.today()
try: try:
hdf = pd.HDFStore(filename, 'r') hdf = pd.HDFStore(filename, 'r')
hdf.close()
except: except:
fetch = True fetch = True
@@ -207,6 +209,7 @@ class Symbol(object):
hdf = pd.HDFStore(filename) hdf = pd.HDFStore(filename)
hdf[self.name] = data hdf[self.name] = data
self.data_full = hdf[self.name]*k_euro self.data_full = hdf[self.name]*k_euro
hdf.close() hdf.close()
@@ -236,7 +239,7 @@ class Symbol(object):
self._macd_data = self.data_full['macd'][len(self.data_full) - show_range_days:] self._macd_data = self.data_full['macd'][len(self.data_full) - show_range_days:]
x_r = list(range(0, len(self._macd_data))) x_r = list(range(0, len(self._macd_data)))
y_r = self._macd_data.to_numpy() y_r = self._macd_data.to_numpy()
poly = np.polyfit(x_r, y_r, 5) poly = np.polyfit(x_r, y_r, N_poly)
poly_d = np.polyder(poly) poly_d = np.polyder(poly)
yf = np.polyval(poly, x_r) yf = np.polyval(poly, x_r)