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