Example #1
0
def main():
    getstocklist()
    print('[+]更新股票代码完成')
    print('[+]开始更新股票日线数据... ...')

    getstockdayline(depickle_stock_list())
    print('[+]股票日线数据更新完毕')
Example #2
0
def minchoice(logfile):
    print('minchoice output' + ':\n')
    logfile.write('minchoice output' + ':\n')
    for code in depickle_stock_list():
        #print(code)
        market = get_stock_market(code)
        if market in ['sh', 'sz']:
            try:
                if market == 'sh':
                    choosedir = Sse_lday
                else:
                    choosedir = Sze_lday

                stk = Stock(code)
                stk.readldaysim(choosedir, 20)
                #print(stk.ldayvalue)
                upcount = 0
                for n in range(15):
                    if stk.limitup(n): upcount += 1
                #print(upcount)
                if upcount >= 3:

                    gd = stk.gaodian(0, 14)
                    #print(stk.ldayvalue[0]["Close"] / gd)
                    if stk.ldayvalue[0]["Close"] / gd < 0.85:

                        print(code)
                        logfile.write(code + '\n')

            except Exception as e:
                pass  #print(e)
Example #3
0
def runmastd(logfile):
    #file = open('mastd.log','w')
    print('Mastd output' + ':\n')
    logfile.write('\n\nMastd output' + ':\n')
    fig, ax1 = plt.subplots()
    ax2 = ax1.twinx()
    for code in depickle_stock_list():
        try:
            a = mastd(code)
            a.std()
            rate = a.stockdayline['mastdyz'][-20:].min()
            if a.stockdayline['close'].count() > 5 * 250:
                if rate < 1.05:
                    #plt绘图
                    ax1.plot(a.stockdayline.index,
                             a.stockdayline['close'],
                             color="red")
                    ax2.plot(a.stockdayline.index,
                             a.stockdayline['13dmastdma'],
                             color="blue")
                    ax2.set_ylim([0, 3 * a.stockdayline['13dmastdma'].min()])
                    plt.savefig('.\png\{}.png'.format(code), dpi=120)
                    ax1.cla()
                    ax2.cla()
                    print(str(code) + ',' + '{:.5f}'.format(rate) + '\n')
                    logfile.write(
                        str(code) + ',' + '{:.5f}'.format(rate) + '\n')
        except:
            pass
Example #4
0
File: mamain.py Project: z0n3/stock
def main2():
    file2 = open('allcodedays2.log', 'w')
    for code in depickle_stock_list():
        try:
            a = marun(code)
            a.yycsy()
            b = a.stockdayline[a.stockdayline['yycsy'] == True]['yz']
            file2.write(code + '\n' + str(b) + '\n\n')
        except:
            pass
    file2.close()
Example #5
0
File: mamain.py Project: z0n3/stock
def main3():
    file2 = open('out.log', 'w')
    today = '2016-10-31 00:00:00'  #2016-10-25'
    for code in depickle_stock_list():
        try:
            a = marun(code)
            a.yycsy()
            b = a.stockdayline[a.stockdayline['yycsy'] == True]['yz']
            if (str(b[-1:].index[0])) == today:
                file2.write(code + '\n')
        except:
            pass
    file2.close()
Example #6
0
def runchzhshch(logfile):
    #strtoday = datetime.datetime.now().strftime('%Y%m%d')
    #today = pd.Timestamp(strtoday)
    print('chzhshch_day_B1 output' + ':\n')
    logfile.write('chzhshch_day_B1 output' + ':\n')
    for code in depickle_stock_list():
        if get_stock_market(code) in ['sh', 'sz']:
            try:
                a = chzhshch(code)
                out = a.test()
                if out:
                    print(code)
                    logfile.write(code + '\n')

            except Exception as e:
                pass
Example #7
0
def runjasonshort(logfile, trading):
    #strtoday = datetime.datetime.now().strftime('%Y%m%d')
    #today = pd.Timestamp(strtoday)

    print('chzhshch_30m_jasonshort output' + ':\n')
    logfile.write('chzhshch_30m_jasonshort output' + ':\n')
    for code in depickle_stock_list():
        if get_stock_market(code) in ['sh', 'sz']:
            try:
                a = jasonshort(code, trading)
                out = a.test()
                if out:
                    print(code)
                    logfile.write(code + '\n')

            except Exception as e:
                print(e)
Example #8
0
def runjasonshort(logfile):
    #file = open('runjasonshort.log','w')
    strtoday = datetime.datetime.now().strftime('%Y%m%d')
    today = pd.Timestamp(strtoday)
    print('Jasonshort output' + ':\n')
    logfile.write('Jasonshort output' + ':\n')
    for code in depickle_stock_list():
        if get_stock_market(code) in ['sh', 'sz']:
            try:
                a = jasonshort(code)
                a.test()
                b = a.stockdayline[a.stockdayline['yz'] == True]['yz']
                b = b.reset_index()
                b['span'] = (today - b['date']) < datetime.timedelta(days=2)
                c = b[b['span'] == True]['date']
                if (len(c) > 0):
                    print(code + ',' + str(c[0])[:11] + '\n')
                    logfile.write(code + ',' + str(c[0])[:11] + '\n')
            except Exception as e:
                pass
Example #9
0
File: mamain.py Project: z0n3/stock
def main():
    file = open('log.log', 'w')
    for code in depickle_stock_list():
        for stopgain in stopgains:
            for stoploss in stoplosses:
                for holdday in holddays:
                    try:
                        a = marun(code, stopgain, stoploss, holdday)
                        a.yycsy()
                        b = a.stockdayline[a.stockdayline['yycsy'] ==
                                           True]['yz']
                        c = b + 1
                        c = c.cumprod()
                        file.write(code + ',' + str(stopgain) + ',' +
                                   str(stoploss) + ',' + str(holdday) + ',' +
                                   '{:.5f}'.format(c[-1:][0]) + ',' +
                                   '{:.5f}'.format(b[b > 0].count() /
                                                   b.count()) + ',' +
                                   '{:.5f}'.format(b.std()) + '\n')
                    except Exception as e:
                        pass
    file.close()
Example #10
0
from core import depickle_stock_list

trade = input("Is it workday? (y/n):    ")
if trade != "n":
    trading = True
else:
    trading = False

print('[+]开始更新股票代码')
#getstocklist.getstocklist()
print('[+]更新股票代码完成')
time.sleep(3)

#更新股票数据
print('[+]开始更新全面股票数据... ...')
getstocktdxdayline.getstocktdxdayline(depickle_stock_list())
print('[+]开始计算策略... ...')

#log file句柄
strtoday = datetime.now().strftime('%Y%m%d')
logfile = open('{}_chzhshch_w_jasonlong.log'.format(strtoday), 'w')
#计算chzhshch策略
jasonlong.runjasonlong(logfile, trading)
logfile.close()

print('[+]完毕')
'''
#git部分
cwd = "D:\\Users\\zhouyu835\\Downloads\\git\\stock"
#cwd = "C:\\Users\\Jason\\Downloads\\git\\stock"
cmd = "git add -A"
Example #11
0
                count = 0
                while (file_o.seek(-(count + 1) * Daylength, 2)):
                    tmpfz = struct.unpack('hhfffffii', file_o.read(32))
                    tmpdata = []
                    tmpdata.append('{}-{}-{} {:0>2}:{:0>2}:00'.format(
                        tmpfz[0] // 2048 + 2004, tmpfz[0] % 2048 // 100,
                        tmpfz[0] % 2048 % 100, tmpfz[1] // 60, tmpfz[1] % 60))
                    tmpdata.append('{:.2f}'.format(tmpfz[2]))  #open
                    tmpdata.append('{:.2f}'.format(tmpfz[3]))  #high
                    tmpdata.append('{:.2f}'.format(tmpfz[4]))  #low
                    tmpdata.append('{:.2f}'.format(tmpfz[5]))  #close
                    tmpdata.append('{:.2f}'.format(tmpfz[6]))  #amount
                    tmpdata.append('{:.2f}'.format(tmpfz[7]))  #vol

                    for d in tmpdata:
                        file_w.write(d)
                        file_w.write(',')
                    file_w.write('\n')
                    #print(tmpdata)

                    count += 1
                    #if count > 187:break
                file_o.close()
                file_w.close()
            except:
                pass


if __name__ == "__main__":
    getstockfzline(depickle_stock_list())
Example #12
0
            & (self.stockdayline['close'].shift(2) >
               self.stockdayline['5dma'].shift(2)))


'''
#test
a=Short100('600080')
a.days3db7()
b=a.stockdayline[a.stockdayline['days3db7']==True]['openrev']
print(b.describe())
print(b.sum())
print(a.stockdayline[a.stockdayline['days3db7']==True])
'''
log_file = open('days3db7.log', 'w')
geshu = 0
for code in (depickle_stock_list()):
    prefix = get_stock_market(code)
    if prefix in ['sh', 'sz']:
        try:
            a = Short100(code)
            a.days3db7()
            del a.stockdayline['low']
            del a.stockdayline['high']
            del a.stockdayline['vol']
            del a.stockdayline['amount']
            b = a.stockdayline[a.stockdayline['days3db7'] == True]['openrev']
            log_file.write(code + '\t')
            log_file.write(
                str(a.stockdayline[a.stockdayline['days3db7'] == True]
                    ['openrev'].sum()))
            log_file.write('\t')