def select_x003(cls, st_df): """ k30 """ name = "selected" mdi_df = ZB.mdi(st_df) ma_df = ZB.ma(st_df) close = st_df['close'] x1 = ZB.cross(mdi_df['ADX'], mdi_df['ADXR']) & (mdi_df['ADXR'] < 30) x2 = mdi_df['DIFF'] > mdi_df['DIFF'].shift(1) x21 = (mdi_df['PDI'] > mdi_df['ADXR']) & (mdi_df['PDI'] > mdi_df['MDI']) x3 = (ma_df['ma50'] <= close + (close * 0.02)) & (ma_df['ma50'] <= close - (close * 0.02)) t1 = (mdi_df.index.hour > 10) & (mdi_df.index.hour <= 14) mdi_df[name] = False mdi_df.ix[t1 & x1 & x2 & x21 & x3, name] = True return mdi_df.ix[:, [name]]
def select_x004(cls, st_df): """ k60 """ name = "selected" mdi_df = ZB.mdi(st_df) ma_df = ZB.ma(st_df) x1 = mdi_df["DIFF"] > mdi_df["DIFF"].shift(1) close = st_df['close'] mdi_df['MAX_ADXR'] = mdi_df['ADXR'].rolling(center=False, min_periods=1, window=10).max() # # x2 = (mdi_df['ADXR'] < 24) & (mdi_df['DIFF'] > -30) x3 = (ma_df['ma50'] <= close + (close * 0.02)) & (ma_df['ma50'] <= close - (close * 0.02)) # x4 = mdi_df['MAX_ADXR'] < 30 mdi_df[name] = False # mdi_df.ix[x1 & x2 & x3 & kk, name] = True mdi_df.ix[x1 & x3, name] = True return mdi_df.ix[:, [name]]
def get_ma_values(cls, base_df, dt, ktype="60"): """ 描述了均线的分布情况 :param base_df: :param dt: :param ktype: :return: """ base_df = base_df[base_df.index <= dt].tail(cls.get_max_30k(ktype)) data_df = gkd.Generator.generate_k_data(base_df, ktype=ktype) ma_df = ZB.ma(data_df) ma_df['close'] = data_df['close'] ma_df['m_1_5'] = (ma_df['close'] - ma_df['ma5']) / ma_df['ma5'] * 100 ma_df['m_1_10'] = (ma_df['close'] - ma_df['ma10']) / ma_df['ma10'] * 100 ma_df['m_5_10'] = (ma_df['ma5'] - ma_df['ma10']) / ma_df['ma10'] * 100 ma_df['m_5_20'] = (ma_df['ma5'] - ma_df['ma20']) / ma_df['ma20'] * 100 ma_df['m_10_20'] = (ma_df['ma10'] - ma_df['ma20']) / ma_df['ma20'] * 100 ma_df['m_10_50'] = (ma_df['ma10'] - ma_df['ma50']) / ma_df['ma50'] * 100 ma_df['avg'] = (ma_df['m_1_5'] + ma_df['m_1_10'] + ma_df['m_5_10'] + ma_df['m_5_20'] + ma_df['m_10_20'] + ma_df['m_10_50']) / 6 ma_df['abs'] = (ma_df['m_1_5'].abs() + ma_df['m_1_10'].abs() + ma_df['m_5_10'].abs() + ma_df['m_5_20'].abs() + ma_df['m_10_20'].abs() + ma_df['m_10_50'].abs()) / 6 cns = [ 'm_1_5', 'm_1_10', 'm_5_10', 'm_5_20', 'm_10_20', 'm_10_50', 'avg', 'abs' ] return cls._extract(ma_df, cns)