diff --git a/pandas_eval.py b/pandas_eval.py index 16a8b86..394810c 100644 --- a/pandas_eval.py +++ b/pandas_eval.py @@ -23,89 +23,90 @@ import os key = '0UO7Z2MVZ2YSQSVE' thresh_macd = 1.5 show_range_days = 20 -show_title = ['QCOM', 'VAR1.DE', 'MOR.DE', 'QIA.DE', 'MDG1.DE'] +show_title = ['WDI.DE', 'QCOM', 'VAR1.DE', 'MOR.DE', 'CSCO', 'OHB.DE'] k_euro = 1 / 1.11 N_poly = 7 ema_alpha = 0.75 sma_days = 10 -titles = [ - 'AAPL', - 'XLNX', - 'QCOM', - 'DPW.DE', - 'CSCO', - 'AIR', - 'BA', - 'NVDA', - 'MSFT', - 'DIS', - 'NFLX', - 'OHB.DE', - 'ERCA.DE', - 'VAR1.DE', - 'HD', - 'AMZN', - 'GOOGL', - 'FB2A.DE', - 'ZIL2.DE', - 'SIS.DE', - 'SIE.DE', - 'GFT.DE', - 'AMD.DE', - 'CAP.DE', - 'ADBE', - 'PANW', - 'AMAT', - 'RIB.DE', - 'WAF.DE', - 'EVT.DE', - 'VOW.DE', - 'BMW.DE', - 'NSU.DE', - 'DAI.DE', - 'SHA.DE', - 'CON.DE', - 'DHER.DE', - 'BSL.DE', - 'D6H.DE', - 'TC1.DE', - 'VODI.DE', - 'ATVI', - 'GME', - 'NTO.F', - 'UBSFF', - 'NXPRF', - 'IMPUF', - 'NMPNF', - 'ALSMY', - 'ARRD.F', - 'PHG', - 'KEYS', - 'ORCL', - 'UBER', - 'VMW', - 'AVGO', - 'CY', - 'QABSY', - 'BLDP', - 'D7G.F', - 'ITMPF', - 'PLUG', - 'PCELF', - 'SU.PA', -# 'SON1.DE', - 'STM.DE', - 'BC8.DE', - 'MOR.DE', - 'BAYN.DE', - 'BEI.DE', - 'EUZ.DE', - 'SLAB', - 'SPLK', - 'IAG', - 'INTC', - 'I'] +titles = { + 'WDI.DE' : {'currency' : '€'}, + 'AAPL' : {'currency' : '$'}, + 'XLNX' : {'currency' : '$'}, + 'QCOM' : {'currency' : '$'}, + 'DPW.DE' : {'currency' : '€'}, + 'CSCO' : {'currency' : '$'}, + 'AIR' : {'currency' : '$'}, + 'BA' : {'currency' : '$'}, + 'NVDA' : {'currency' : '$'}, + 'MSFT' : {'currency' : '$'}, + 'DIS' : {'currency' : '$'}, + 'NFLX' : {'currency' : '$'}, + 'OHB.DE' : {'currency' : '€'}, + 'ERCA.DE' : {'currency' : '€'}, + 'VAR1.DE' : {'currency' : '€'}, + 'HD' : {'currency' : '$'}, + 'AMZN' : {'currency' : '$'}, + 'GOOGL' : {'currency' : '$'}, + 'FB2A.DE' : {'currency' : '€'}, + 'ZIL2.DE' : {'currency' : '€'}, + 'SIS.DE' : {'currency' : '€'}, + 'SIE.DE' : {'currency' : '€'}, + 'GFT.DE' : {'currency' : '€'}, + 'AMD.DE' : {'currency' : '€'}, + 'CAP.DE' : {'currency' : '€'}, + 'ADBE' : {'currency' : '$'}, + 'PANW' : {'currency' : '$'}, + 'AMAT' : {'currency' : '$'}, + 'RIB.DE' : {'currency' : '€'}, + 'WAF.DE' : {'currency' : '€'}, + 'EVT.DE' : {'currency' : '€'}, + 'VOW.DE' : {'currency' : '€'}, + 'BMW.DE' : {'currency' : '€'}, + 'NSU.DE' : {'currency' : '€'}, + 'DAI.DE' : {'currency' : '€'}, + 'SHA.DE' : {'currency' : '€'}, + 'CON.DE' : {'currency' : '€'}, + 'DHER.DE' : {'currency' : '€'}, + 'BSL.DE' : {'currency' : '€'}, + 'D6H.DE' : {'currency' : '€'}, + 'TC1.DE' : {'currency' : '€'}, + 'VODI.DE' : {'currency' : '€'}, + 'ATVI' : {'currency' : '$'}, + 'GME' : {'currency' : '$'}, + 'NTO.F' : {'currency' : '$'}, + 'UBSFF' : {'currency' : '$'}, + 'NXPRF' : {'currency' : '$'}, + 'IMPUF' : {'currency' : '$'}, + 'NMPNF' : {'currency' : '$'}, + 'ALSMY' : {'currency' : '$'}, + 'ARRD.F' : {'currency' : '$'}, + 'PHG' : {'currency' : '$'}, + 'KEYS' : {'currency' : '$'}, + 'ORCL' : {'currency' : '$'}, + 'UBER' : {'currency' : '$'}, + 'VMW' : {'currency' : '$'}, + 'AVGO' : {'currency' : '$'}, + 'CY' : {'currency' : '$'}, + 'QABSY' : {'currency' : '$'}, + 'BLDP' : {'currency' : '$'}, + 'D7G.F' : {'currency' : '$'}, + 'ITMPF' : {'currency' : '$'}, + 'PLUG' : {'currency' : '$'}, + 'PCELF' : {'currency' : '$'}, + 'SU.PA' : {'currency' : '$'}, +# 'SON1.DE' : {'currency' : '€'}, + 'STM.DE' : {'currency' : '€'}, + 'BC8.DE' : {'currency' : '€'}, + 'MOR.DE' : {'currency' : '€'}, + 'BAYN.DE' : {'currency' : '€'}, + 'BEI.DE' : {'currency' : '€'}, + 'EUZ.DE' : {'currency' : '€'}, + 'SLAB' : {'currency' : '$'}, + 'SPLK' : {'currency' : '$'}, + 'IAG' : {'currency' : '$'}, + 'INTC' : {'currency' : '$'}, + 'I' : {'currency' : '$'}} def ema(data, key, alpha=0.5, ic=None): result = [] @@ -182,10 +183,16 @@ def bollinger(data, window_days, f=2): return result class Symbol(object): - def __init__(self, name): - self.name = name + def __init__(self, title, params): + self.name = title + self.params = params self.ax = None self.fig = None + self.currency = params['currency'] + self.currency_corr = 1 + if '$' in self.currency : + self.currency_corr = 1/1.11 + def fetch(self): filename = self.name.replace('.','_') + '.h5' @@ -215,7 +222,7 @@ class Symbol(object): else: hdf = pd.HDFStore(filename, 'r') - self.data_full = hdf[self.name]*k_euro + self.data_full = hdf[self.name]*self.currency_corr hdf.close() def __plot(self, d, keys): @@ -229,7 +236,7 @@ class Symbol(object): if event.inaxes == self.ax: x_idx = int(event.xdata) self.ax.format_xdata = lambda x: dates[x_idx] - self.ax.format_ydata = lambda y: '€{:.2f}'.format(data[x_idx]) + self.ax.format_ydata = lambda y: '{}{:.2f}'.format(self.currency, data[x_idx]) self.fig.canvas.mpl_connect("motion_notify_event", hover) @@ -283,23 +290,27 @@ class Symbol(object): plt.legend() plt.grid() + + figNum = 1 if len(show_title) > 0: for title in show_title: - sym = Symbol(title) - sym.fetch() - print(sym.analyze()) - sym.show(figNum) - figNum += 1 -else: - for title in titles: - sym = Symbol(title) - sym.fetch() - result = sym.analyze() - if result['macd_f'] > thresh_macd and result['macd_fd'] > 0: + if title in titles: + sym = Symbol(title, titles[title]) + sym.fetch() + print(sym.analyze()) sym.show(figNum) figNum += 1 +else: + for title in show_title: + if title in titles: + sym = Symbol(title, titles[title]) + sym.fetch() + result = sym.analyze() + if result['macd_f'] > thresh_macd and result['macd_fd'] > 0: + sym.show(figNum) + figNum += 1 plt.show()