def vote(self, code, day): features = [] values = db_helper.select(query_kdj_fn, (code, day, 30)) if len(values) < 30: return features values = np.array(values)[::-1] k_values = values[:, 1].astype(float) d_values = values[:, 2].astype(float) j_values = values[:, 3].astype(float) if k_values[-1] <= 20 and d_values[-1] <= 20 and j_values[-1] <= 20: features.append(self.OVER_SOLD) if ins.match(k_values[-3:], d_values[-3:]) == 1 and ins.match( j_values[-3:], d_values[-3:]): features.append(self.GOOD_CROSS) s = 0 if trend.is_uptrend(k_values[-10:]): s = s + 1 if trend.is_uptrend(d_values[-10:]): s = s + 1 if trend.is_uptrend(j_values[-10:]): s = s + 1 if s >= 2: k_values = db_helper.select(query_k_fn, (code, day, 10)) k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) return features
def vote(self, code, day): features = [] values = db_helper.select(query_kpi_fn, (code, day, 30)) if len(values) < 30: return features values = np.array(values)[::-1] rsi_6_lines = values[:, 1].astype(float) rsi_12_lines = values[:, 2].astype(float) rsi_24_lines = values[:, 3].astype(float) if rsi_6_lines[-1] <= 20: features.append(self.OVER_SOLD) if rsi_6_lines[-1] < 50 and rsi_12_lines[-1] < 50 and rsi_24_lines[ -1] < 50: if ins.match(rsi_6_lines[-3:], rsi_12_lines[-3:]) == 1 and ins.match( rsi_6_lines[-3:], rsi_24_lines[-3:]): features.append(self.GOOD_CROSS) if trend.is_uptrend(rsi_6_lines[-10:]): k_values = db_helper.select(query_k_fn, (code, day, 10)) if len(k_values) == 10: k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) return features
def vote(self, code, day): features = [] arbr_values = db_helper.select(query_arbr_fn, (code, day, 14)) if len(arbr_values) < 14: return features arbr_values = np.array(arbr_values)[::-1] ar_values = arbr_values[:, 1].astype(float) br_values = arbr_values[:, 2].astype(float) if ins.match(br_values[-3:], ar_values[-3:]) == 1: features.append(self.GOOD_CROSS) if trend.is_uptrend(ar_values) and trend.is_uptrend(br_values): k_values = db_helper.select(query_k_fn, (code, day, 14)) if len(k_values) == 14: k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) return features
def positive(data): size = len(data) if size < 4: print('数据必须多余4个') return False min_idx = 0 min_v = np.max(data) for i in range(size): if data[i] <= min_v: min_idx = i min_v = data[i] if min_idx == 0: return False, 0 if min_idx == size - 1: return False, size - 1 left_data = data[0:min_idx + 1] right_data = data[min_idx:] return trend.is_downtrend(left_data) and trend.is_uptrend( right_data), min_idx
def vote(self, code, day): features = [] values = db_helper.select(query_wr_fn, (code, day, 30)) if len(values) < 30: return features values = np.array(values)[::-1] wr_6_values = values[:, 1].astype(float) if trend.is_uptrend(wr_6_values[-10:]): k_values = db_helper.select(query_k_fn, (code, day, 10)) if len(k_values) == 10: k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) if wr_6_values[-1] > 80: features.append(self.OVER_SOLD) return features
def vote(self, code, day): features = [] values = db_helper.select(self.query_kpi_fn, (code, day, 30, EMV)) if len(values) < 30: return features values = np.array(values)[::-1] emv_values = np.array(list(map(lambda x: np.float(x.emv), values))) if trend.is_uptrend(emv_values[-10:]): k_values = db_helper.select(self.query_kpi_fn, (code, day, 10, TradingDataDaily)) if len(k_values) == 10: k_values = np.array(k_values)[::-1] close_values = np.array( list(map(lambda x: np.float(x.close), k_values))) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) bt, l = zero_line.breakthrough(emv_values[-10:]) if bt and l <= 3: features.append(self.BREAK_ZERO) return features
def vote(self, code, day): features = [] values = db_helper.select(query_roc_fn, (code, day, 30)) if len(values) < 30: return features values = np.array(values)[::-1] roc_values = values[:, 1].astype(float) rocma_values = values[:, 2].astype(float) if ins.match(roc_values[-3:], rocma_values[-3:]) == 1: features.append(self.GOOD_CROSS) if trend.is_uptrend(roc_values): k_values = db_helper.select(query_k_fn, (code, day, 30)) if len(k_values) == 30: k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) bt, l = zero_line.breakthrough(roc_values, 0) if bt and l <= 3: features.append(self.BREAK_ZERO) return features
def vote(self, code, day): features = [] values = db_helper.select(query_kpi_fn, (code, day, 30)) if len(values) < 30: return features values = np.array(values)[::-1] b6_lines = values[:, 1].astype(float) b12_lines = values[:, 1].astype(float) b24_lines = values[:, 1].astype(float) if b6_lines[-1] <= -4 and b12_lines[-1] <= -5.5 and b24_lines[-1] <= -8: features.append(self.OVER_SOLD) if ins.match(b6_lines[-3:], b12_lines[-3:]) == 1 and ins.match( b6_lines[-3:], b24_lines[-3:]): features.append(self.GOOD_CROSS) if trend.is_uptrend(b6_lines[-10:]): k_values = db_helper.select(query_k_fn, (code, day, 10)) k_values = np.array(k_values)[::-1] close_values = k_values[:, 0].astype(float) if trend.is_downtrend(close_values): features.append(self.BOTTOM_DEVIATION) return features