get_break_high_low.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:stock 作者: Rockyzsu 项目源码 文件源码
def is_break_low(stockID, days, fast_type=True):
    end_day = datetime.date(datetime.date.today().year, datetime.date.today().month, datetime.date.today().day-2)
    days = days * 7 / 5
    #?????????
    print stockID
    start_day = end_day - datetime.timedelta(days)

    start_day = start_day.strftime("%Y-%m-%d")
    end_day = end_day.strftime("%Y-%m-%d")
    if fast_type:
        df = ts.get_h_data(stockID, start=start_day, end=end_day, retry_count=10, pause=10)
    else:
        df = ts.get_hist_data(stockID, start=start_day, end=end_day, retry_count=10, pause=10)
    if df is None:
        print "None len==0"
        return False
    if df.empty:
        print "%s Trading halt" % info.ix[stockID]['name'].decode('utf-8')
        return False
    period_low = df['low'].max()
    #print period_high
    curr_day = df[:1]
    today_low = curr_day.iloc[0]['low']
    #??????? .values
    #????df??1? ????.values
    #print today_high
    if today_low <= period_low:
        stock_l= []
        day = curr_day.index.values[0]

        #print curr_day
        name = info.ix[stockID]['name'].decode('utf-8')
        if fast_type:
            turnover = 0
            p_change = 0
        else:
            turnover = curr_day.iloc[0]['turnover']
            p_change = curr_day.iloc[0]['p_change']

        print day
        print stockID
        print p_change
        print turnover
        #print day
        #date=curr_day['date']
        stock_l.append(day)
        stock_l.append(stockID)
        stock_l.append(name)
        stock_l.append(p_change)
        stock_l.append(turnover)

        #print name.decode('utf-8')
        #print date
        #all_high_stock.append(stock)
        sql_db_l.store_break(stock_l)
        return True
    else:
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号