def analysis_daily(position): # code_list = get_stock('sha') + get_stock('sza') code_list = filter_stk1() result = [] for code in code_list: kline = np.load('data/daily/{}'.format(code + '.npy')) if kline.shape[0] < 120: continue s_open = kline[:, 2].astype(np.float)[:100] s_high = kline[:, 3].astype(np.float)[:100] s_low = kline[:, 4].astype(np.float)[:100] s_close = kline[:, 5].astype(np.float)[:100] s_pre_close = kline[:, 6].astype(np.float)[:100] s_vol = kline[:, 9].astype(np.float)[:100] s_amount = (kline[:, 10].astype(np.float) * 1000)[:100] sma_close_5, sma_close_10, sma_close_20 = indicator.sma( kline, 5, 10, 20) if s_close[position] > s_open[position] > 0 and s_amount[ position] > 10000 * 10000: s_zf = (s_high - s_low) / s_low * 100 s_entity = (s_close - s_open) / s_open * 100 s_max = (s_close - s_low) / s_low * 100 s_down = (s_pre_close - s_low) / s_pre_close * 100 if s_zf[position] > 5 and s_max[position] > 3: if s_low[position] <= sma_close_5[position] <= s_high[ position] or s_low[position] <= sma_close_10[ position] <= s_high[position] or s_low[ position] <= sma_close_20[position] <= s_high[ position]: print(code) result.append(code) return result
def t_all(kline, position): # 日线条数要大于120条, 6个月 if kline.shape[0] < 30: return False s_open = kline[:, 2].astype(np.float)[:100] s_high = kline[:, 3].astype(np.float)[:100] s_low = kline[:, 4].astype(np.float)[:100] s_close = kline[:, 5].astype(np.float)[:100] s_pre_close = kline[:, 6].astype(np.float)[:100] s_vol = kline[:, 9].astype(np.float)[:100] s_amount = (kline[:, 10].astype(np.float) * 1000)[:100] sma_vol_5, sma_vol_10, sma_vol_20 = indicator.sma_vol(kline, 5, 10, 20) sma_close_5, sma_close_10, sma_close_20 = indicator.sma(kline, 5, 10, 20) # 成交额要大于1.5亿 if s_amount[position] < 0.8 * 100000000: return False # 开盘价要小于于收盘价 if s_open[position] > s_close[position]: return False s_zf = (s_high - s_low) / s_low * 100 s_entity = (s_close - s_open) / s_open * 100 s_max = (s_close - s_low) / s_low * 100 s_down = (s_pre_close - s_low) / s_pre_close * 100 # 不考虑40元以上的股票 if sma_close_5[position] > 40: return False # 不考虑没有波动的股票 if s_zf[position] < 4 or s_max[position] < 3 or s_entity[position] < 2.5: return False # 若上涨幅度没有超过前面两个k线的高度, 不考虑 # if s_high[position] < np.max(s_open[position + 1: position + 3]): # return False # if s_high[position] < np.max(s_close[position + 1: position + 3]): # return False # 突然爆量的涨幅不要 if s_vol[position] / s_vol[position + 1] > 2.5: return False if s_vol[position] >= np.max(s_vol[position:position + 15]): return False # 没有穿过均线的不要 if s_low[position] > max(sma_close_10[position], sma_close_20[position]): return False if s_high[position] < min(sma_close_10[position], sma_close_20[position]): return False for amount in s_amount[0:30]: if amount < 3000 * 10000: return False return True
def analysis_week(position): code_list = get_stock('sha') for code in code_list: kline = np.load('data/week/{}'.format(code + '.npy')) if kline.shape[0] < 120: continue close = kline[:2].astype(np.float)[:100] _open = kline[:3].astype(np.float)[:100] high = kline[:4].astype(np.float)[:100] low = kline[:5].astype(np.float)[:100] pre_close = kline[:6].astype(np.float)[:100] vol = kline[:9].astype(np.float)[:100] amount = kline[:10].astype(np.float) * 1000 [:100] sma_close_5, sma_close_10, sma_close_20 = indicator.sma( kline, 5, 10, 20) if amount[position] > 1 * 100000000: pass
def good_d_line(code, position_range): kline = np.load('data/daily/{}'.format(code + '.npy')) if kline.shape[0] < 120: return None s_open = kline[:, 2].astype(np.float)[:100] s_high = kline[:, 3].astype(np.float)[:100] s_low = kline[:, 4].astype(np.float)[:100] s_close = kline[:, 5].astype(np.float)[:100] s_pre_close = kline[:, 6].astype(np.float)[:100] s_vol = kline[:, 9].astype(np.float)[:100] s_amount = (kline[:, 10].astype(np.float) * 1000)[:100] s_zf = (s_high - s_low) / s_low * 100 s_entity = (s_close - s_open) / s_open * 100 s_max = (s_close - s_low) / s_low * 100 s_down = (s_pre_close - s_low) / s_pre_close * 100 sma_close_5, sma_close_10, sma_close_20 = indicator.sma(kline, 5, 10, 20) result = [] for position in range(position_range[0], position_range[1]): score = 0 if s_close[position] > s_open[position] and s_amount[ position] > 10000 * 10000: score = 0.5 if s_low[position] < sma_close_5[position] < s_high[position]: score += 2 if s_low[position] < sma_close_10[position] < s_high[position]: score += 2 if s_low[position] < sma_close_20[position] < s_high[position]: score += 10 if score >= 2: if s_zf[position] > 5 or s_entity[position] > 3: score += 2 else: score = 0 if score < 0: score = 0 if s_close[position_range[0]] > sma_close_5[position_range[0]]: score = 0 result.append(score) return result
def buy_point(): result = [] code_list = get_stock('2020-11-05.txt') + get_stock( '2020-11-04.txt') + get_stock('2020-11-03.txt') + get_stock( '2020-11-02.txt') code_list = [code for code in code_list if hasDayFile(code)] for code in code_list: kline = np.load('data/daily/{}'.format(code + '.npy'), allow_pickle=True) s_open = kline[:, 2].astype(np.float)[:100] s_high = kline[:, 3].astype(np.float)[:100] s_low = kline[:, 4].astype(np.float)[:100] s_close = kline[:, 5].astype(np.float)[:100] s_pre_close = kline[:, 6].astype(np.float)[:100] s_vol = kline[:, 9].astype(np.float)[:100] s_amount = (kline[:, 10].astype(np.float) * 1000)[:100] sma_vol_5, sma_vol_10, sma_vol_20 = indicator.sma_vol(kline, 5, 10, 20) sma_close_5, sma_close_10, sma_close_20 = indicator.sma( kline, 5, 10, 20) if s_close[0] < sma_close_10[0] or s_close[0] < sma_close_20[0]: result.append(code) return result
def t2(kline, position): # 日线条数要大于120条, 6个月 if kline.shape[0] < 120: return False s_open = kline[:, 2].astype(np.float)[:100] s_high = kline[:, 3].astype(np.float)[:100] s_low = kline[:, 4].astype(np.float)[:100] s_close = kline[:, 5].astype(np.float)[:100] s_pre_close = kline[:, 6].astype(np.float)[:100] s_vol = kline[:, 9].astype(np.float)[:100] s_amount = (kline[:, 10].astype(np.float) * 1000)[:100] sma_vol_5, sma_vol_10, sma_vol_20 = indicator.sma_vol(kline, 5, 10, 20) sma_close_5, sma_close_10, sma_close_20 = indicator.sma(kline, 5, 10, 20) if s_close[position] > 40: return False if s_amount[position] < 1 * 100000000: return False s_entity = (s_close - s_open) / s_open * 100 if s_entity[position] < 3: return False if s_close[position] < s_pre_close[position]: return False return True
def test2(): kline = np.load('data/daily/600000.npy') sma_close_5 = indicator.sma(kline, 5)[0] print(sma_close_5)