美文网首页股票小工具系列
股票小工具-七伤拳战法

股票小工具-七伤拳战法

作者: 平凡啊菜 | 来源:发表于2018-09-19 19:28 被阅读46次

    七伤拳战法自己百度,关键点为:
    7~9天内,有连续两个实体涨停,当前价格在第一个开始涨停之上
    战法威力:可以获得资金潜伏的个股,埋伏涨停板

    # 七伤拳战法
    # 逻辑:连续2天实体涨停的,就发邮件
    # 7~9天内,有连续两个实体涨停,当前价格在第一个开始涨停之上,这是抓第一天之后的
    
    import easyutils as eu
    import tushare as ts
    import datetime
    from retrying import retry
    # from tushare.stock import cons as ct
    import numpy as np
    
    cons = ts.get_apis()
    
    
    # 获取个股数据,获取最近N个交易日的数据
    
    
    @retry
    def getstockdataofday(stockcode, timeperiod=180, rangeperiod=9):
        datedelay = datetime.date.today() - datetime.timedelta(days=timeperiod)
        startdate = str(datedelay.isoformat())
        enddate = str(datetime.date.today().isoformat())
        # print('start:%s,end:%s' % (startdate, enddate))
        stockdata = ts.bar(stockcode, conn=cons, freq='D',
                           start_date=startdate, end_date=enddate)
        if stockdata['close'] is not None:
            stockdata['preclose'] = stockdata['close'].shift(1)
        stockdata['pchange'] = np.round((
            (stockdata['close'] / stockdata['preclose'] - 1) * 100), 2)
        stockdata['maxpercent'] = np.round((
            (stockdata['high'] / stockdata['low'] - 1) * 100), 2)
        return stockdata.head(rangeperiod)
    
    # 获取股票列表
    
    
    @retry
    def getbasic():
        basic = ts.get_stock_basics()
        return basic
    
    
    def isconsecutivedays(stockcode):
        stockdata = getstockdataofday(stockcode, 180, 9)
        # print(stockdata)
        alist = []
        istarget = False
        for i in range(len(stockdata)):
            if (stockdata.iloc[i]['pchange'] >= 9.9) and (stockdata.iloc[i]['maxpercent'] >= 1):
                alist.append(i)
    
            for i in range(0, len(alist) - 1):
                if(alist[i + 1] - alist[i]) == 1:
                    istarget = True
        return istarget
    
    
    def main():
        print('main doc.')
        is_holiday = eu.is_holiday_today()
        if not is_holiday:
            print('交易时间')
        basic = getbasic()
        print('get basic finish.')
        total = len(basic)
        index = 1
        preylist = []
        for stockcodeitem in basic.index.values:
            if isconsecutivedays(stockcodeitem):
                print('found one:%s' % stockcodeitem)
                preylist.append(stockcodeitem)
            print('%s/%s code:%s' % (index, total, stockcodeitem))
            index = index + 1
        print('符合的有:')
        print(preylist)
    
    
    if __name__ == '__main__':
        print('seven sided strike on stock.')
        main()
    
    
    赞赏是最真诚的认可

    相关文章

      网友评论

        本文标题:股票小工具-七伤拳战法

        本文链接:https://www.haomeiwen.com/subject/itcwnftx.html