first working commit
This commit is contained in:
parent
c2d00ff69a
commit
e34780c1fe
@ -661,24 +661,24 @@ def intelligent_loop_plots():
|
||||
|
||||
# init
|
||||
plot_indicator = "["
|
||||
print('{:5}: '.format(sym), end = '')
|
||||
# print('{:5}: '.format(sym), end = '')
|
||||
|
||||
# RSI outside window (over bought / over sold)
|
||||
rsi_tail = rsi.tail(lb_trigger)
|
||||
if (rsi_tail[sym] >= 70).any() or (rsi_tail[sym] <= 30).any():
|
||||
print('--RSI', end = '')
|
||||
# print('--RSI', end = '')
|
||||
plot_indicator += 'RSI, '
|
||||
|
||||
# VoRSI outside window (over bought / over sold)
|
||||
vorsi_tail = vorsi.tail(lb_trigger)
|
||||
if (vorsi_tail[sym] >= 70).any() or (vorsi_tail[sym] <= 30).any():
|
||||
print('--VoRSI', end = '')
|
||||
# print('--VoRSI', end = '')
|
||||
plot_indicator += 'VoRSI, '
|
||||
|
||||
# Normalized MACD histogram out of 3% range
|
||||
norm_hist_tail = abs(norm_hist.tail(lb_trigger))
|
||||
if (abs(norm_hist_tail[sym]) >= 0.02).any():
|
||||
print('--MACD/R', end = '') # outside normal range
|
||||
# print('--MACD/R', end = '') # outside normal range
|
||||
plot_indicator += 'MACD/R, '
|
||||
|
||||
# MACD histogram zero crossing
|
||||
@ -686,7 +686,7 @@ def intelligent_loop_plots():
|
||||
macd_hist_sign = np.sign(macd_hist_tail)
|
||||
macd_hist_diff = macd_hist_sign.diff()
|
||||
if (abs(macd_hist_diff[sym]) > 1).any():
|
||||
print('--MACD', end = '') # zero crossing
|
||||
# print('--MACD', end = '') # zero crossing
|
||||
plot_indicator += 'MACD, '
|
||||
|
||||
# Stock price crosses SMA50
|
||||
@ -694,7 +694,7 @@ def intelligent_loop_plots():
|
||||
sma50_cross_sign = np.sign(sma50_cross_tail)
|
||||
sma50_cross_diff = sma50_cross_sign.diff()
|
||||
if (abs(sma50_cross_diff[sym]) > 1).any():
|
||||
print('--SMA50', end = '')
|
||||
# print('--SMA50', end = '')
|
||||
plot_indicator += 'SMA50, '
|
||||
|
||||
# Death cross or golden cross - SMA50 vs SMA200
|
||||
@ -702,7 +702,7 @@ def intelligent_loop_plots():
|
||||
sma_cross_sign = np.sign(sma_cross_tail)
|
||||
sma_cross_diff = sma_cross_sign.diff()
|
||||
if (abs(sma_cross_diff[sym]) > 1).any():
|
||||
print('--Golden/Death', end = '')
|
||||
# print('--Golden/Death', end = '')
|
||||
plot_indicator += 'Golden/Death, '
|
||||
|
||||
# Price outside bollinger band or crossing
|
||||
@ -712,7 +712,7 @@ def intelligent_loop_plots():
|
||||
price_high = price_tail - bol_up_tail.values
|
||||
price_low = price_tail - bol_low_tail.values
|
||||
if (price_high[sym] >= 0).any() or (price_low[sym] <= 0).any():
|
||||
print('--Bollinger', end ='')
|
||||
# print('--Bollinger', end ='')
|
||||
plot_indicator += 'Bollinger, '
|
||||
|
||||
# Price cross 200 day moving average
|
||||
@ -721,7 +721,7 @@ def intelligent_loop_plots():
|
||||
sma200_cross_sign = np.sign(sma200_cross)
|
||||
sma200_cross_diff = sma200_cross_sign.diff()
|
||||
if (abs(sma200_cross_diff[sym]) > 1).any():
|
||||
print('--SMA200', end = '')
|
||||
# print('--SMA200', end = '')
|
||||
plot_indicator += 'SMA200, '
|
||||
|
||||
# Large trading volume trigger
|
||||
@ -729,10 +729,10 @@ def intelligent_loop_plots():
|
||||
vol_mean = vol.tail(50).mean()
|
||||
vol_std = vol.tail(50).std()
|
||||
if ((volume_tail[sym] - vol_mean[sym] - 2*vol_std[sym]) > 0).any():
|
||||
print('--HiVol', end = '')
|
||||
# print('--HiVol', end = '')
|
||||
plot_indicator += "HiVol, "
|
||||
|
||||
print(f"-- {watchlist.loc[sym, 'Notes']}") # carriage return
|
||||
# print(f"-- {watchlist.loc[sym, 'Notes']}") # carriage return
|
||||
plot_indicator += ']'
|
||||
note_field = watchlist.loc[sym, 'Notes'].strip().lower()
|
||||
if note_field != "watch" and ( note_field == "skip" or \
|
||||
|
8
util.py
8
util.py
@ -82,13 +82,13 @@ def get_data_range(df, dates):
|
||||
return df_range
|
||||
|
||||
def yf_download(symbols, start, end):
|
||||
df = pd.DataFrame(columns = pd.MultiIndex(levels=[["Adj Close", "Volume"],[]], codes=[[],[]], names=["adjclose", "volume"]))
|
||||
df = pd.DataFrame(columns = pd.MultiIndex(levels=[["Adj Close", "Volume"],[]], codes=[[],[]], names=["param", "tick"]))
|
||||
for sym in symbols:
|
||||
# tmp = si.get_data(sym, start_date=start)
|
||||
tmp = si.get_data(sym, start_date=start)[["adjclose", "volume"]]
|
||||
tuples = list(zip(tmp.columns.values.tolist(), \
|
||||
[symbols[0]]*len(tmp.columns.values)))
|
||||
tmp.columns = pd.MultiIndex.from_tuples(tuples, names=[None, None])
|
||||
tmp.rename(columns={"adjclose": "Adj Close", "volume": "Volume"}, inplace=True)
|
||||
tmp.columns = pd.MultiIndex.from_product([list(tmp.columns)] + [[sym]], names=["param", "tick"])
|
||||
|
||||
df = df.join(tmp, how='outer')
|
||||
|
||||
return df
|
||||
|
Loading…
x
Reference in New Issue
Block a user