예제 #1
0
def check(code_name, data, end_date=None, threshold=15):
    origin_data = data
    if data.size < 250:
        logging.info("{0}:样本小于250天...\n".format(code_name))
        return
    data['ma250'] = pd.Series(tl.MA(data['close'].values, 250),
                              index=data.index.values)

    begin_date = data.iloc[0].date
    if end_date is not None:
        if end_date < begin_date:  # 该股票在end_date时还未上市
            logging.info("{}在{}时还未上市".format(code_name, end_date))
            return False

    if end_date is not None:
        mask = (data['date'] <= end_date)
        data = data.loc[mask]

    data = data.tail(n=threshold)

    flag = False

    # 找出涨停日
    for index, row in data.iterrows():
        try:
            if float(row['p_change']) > 9.5:
                if turtle_trade.check_enter(code_name, origin_data,
                                            row['date'], threshold):
                    if check_internal(code_name, data, row):
                        flag = True
        except KeyError as error:
            logging.info("{}处理异常:{}".format(code_name, error))

    return flag
예제 #2
0
def check(code_name, data, end_date=None, threshold=15):
    origin_data = data

    begin_date = data.iloc[0].date
    if end_date is not None:
        if end_date < begin_date:  # 该股票在end_date时还未上市
            logging.info("{}在{}时还未上市".format(code_name, end_date))
            return False

    if end_date is not None:
        mask = (data['date'] <= end_date)
        data = data.loc[mask]

    if len(data) < threshold:
        logging.info("{0}:样本小于{1}天...\n".format(code_name, threshold))
        return

    data = data.tail(n=threshold)

    flag = False

    # 找出涨停日
    for index, row in data.iterrows():
        try:
            if float(row['p_change']) > 9.5:
                if turtle_trade.check_enter(code_name, origin_data,
                                            row['date'], threshold):
                    if check_internal(code_name, data, row):
                        flag = True
        except KeyError as error:
            logging.info("{}处理异常:{}".format(code_name, error))

    return flag
예제 #3
0
 def end_date_filter(code_name):
     stock = code_name[0]
     data = utils.read_data(code_name)
     result = enter.check_ma(stock, data, end_date=end_date) \
         and turtle_trade.check_enter(stock, data, end_date=end_date) \
         and enter.check_volume(stock, data, end_date=end_date)
     # and enter.check_volume(code_name, data, end_date=end_date)
     if result:
         message = turtle_trade.calculate(code_name, data)
         logging.info("{0} {1}".format(code_name, message))
         notify.notify("{0} {1}".format(code_name, message))
     return result