示例#1
0
def showStockChart(stockcode):

    stockcode = stock.normalizeStockCode(stockcode)
    kdata = stock.getStockDayDataQianFuQuan(stockcode)
    if (not kdata):
        utils.output('股票数据不存在', 'red')
        return False

    if (stockcode[:3] != 'sh0'):
        weightdata = stock.getStockWeightData(stockcode)
        if (not weightdata):
            utils.output('复权数据不存在', 'red')
            return False
        #print(weightdata)

    #set data
    globals.mainwin.chart.kdata = kdata
    globals.mainwin.chart.stockcode = stockcode
    globals.mainwin.scrollbar.setMinimum(0)
    ktotalcount = len(kdata)
    globals.mainwin.scrollbar.setMaximum(ktotalcount)
    globals.mainwin.scrollbar.setValue(ktotalcount)
    globals.mainwin.scrollbar.setSingleStep(1)
    if (stockcode[:3] != 'sh0'):
        globals.mainwin.chart.weightdata = weightdata

    #draw
    globals.viewportclear = False
    utils.update()
示例#2
0
def showStockChart(stockcode):
    
    stockcode = stock.normalizeStockCode(stockcode)
    kdata = stock.getStockDayDataQianFuQuan(stockcode)
    if(not kdata):
        utils.output('股票数据不存在', 'red')
        return False

    if(stockcode[:3] != 'sh0'):
        weightdata = stock.getStockWeightData(stockcode)
        if(not weightdata):
            utils.output('复权数据不存在', 'red')
            return False
        #print(weightdata)

    #set data
    globals.mainwin.chart.kdata = kdata
    globals.mainwin.chart.stockcode = stockcode
    globals.mainwin.scrollbar.setMinimum(0)
    ktotalcount = len(kdata)
    globals.mainwin.scrollbar.setMaximum(ktotalcount)
    globals.mainwin.scrollbar.setValue(ktotalcount)
    globals.mainwin.scrollbar.setSingleStep(1)
    if(stockcode[:3] != 'sh0'):
        globals.mainwin.chart.weightdata = weightdata

    #draw
    globals.viewportclear = False
    utils.update()
示例#3
0
def run(subcmd, params):
    chart = globals.mainwin.chart
    stocklist = stock.getStockList()

    if(subcmd == 'di'):
        filterResults = []
        di = indicators.di.Di()

        utils.output('开始di条件过滤')
        prefixstr = 'filter di条件过滤:'
        totalstock = len(stocklist)
        cnt = 0
        start_time = datetime.datetime.now()
        for stockcode in stocklist:
            cnt +=1
            stockcode = stock.normalizeStockCode(stockcode)
            end_time = datetime.datetime.now()
            diffStr = '{}'.format(end_time - start_time)
            outstr = '{} {}/{} 当前代码:{} 符合条件:{} ({})'.format(prefixstr, cnt, totalstock, stockcode, len(filterResults), diffStr)
            utils.overwrite(outstr, prefixstr)
            stockdata = stock.getStockDayDataQianFuQuan(stockcode)
            stockdata = stockdata[-500:]
            didata = di.calculateData(stockdata)
            QCoreApplication.processEvents()
            if(didata[-1] and didata[-1].get('tip')):
                filterResults.append({'code':stockcode, 'date':didata[-1]['date']})

        
        dataArr = []

        for row in filterResults:
            scode = row['code']
            sdate = row['date']
            row=[]
            row.append(scode)
            row.append(stock.getStockName(scode))
            row.append(sdate)
            dataArr.append(row)
    
        #write to file begin
        filename = globals.datapath + '/lastFilterResult.dat'
        try:
            f = open(filename, 'wb')
        except IOError:
            exc_type, exc_value = sys.exc_info()[:2]
            errmsg = '{}: {}'.format(exc_type.__name__, exc_value)
            output(errmsg, 'red')
            return False
        
        pickle.dump(dataArr, f)
        f.close() 
        #write to file end
        
        tablemodel = stockfilterresultdlg.FilterResultModel(dataArr, None)
        tbResults = globals.mainwin.stockfilterresultdlg.tbResults
        tbResults.setModel(tablemodel)
        globals.mainwin.windowStockFilterResult()
示例#4
0
def run(subcmd, params):
    chart = globals.mainwin.chart
    stocklist = stock.getStockList()

    if (subcmd == 'di'):
        filterResults = []
        di = indicators.di.Di()

        utils.output('开始di条件过滤')
        prefixstr = 'filter di条件过滤:'
        totalstock = len(stocklist)
        cnt = 0
        start_time = datetime.datetime.now()
        for stockcode in stocklist:
            cnt += 1
            stockcode = stock.normalizeStockCode(stockcode)
            end_time = datetime.datetime.now()
            diffStr = '{}'.format(end_time - start_time)
            outstr = '{} {}/{} 当前代码:{} 符合条件:{} ({})'.format(
                prefixstr, cnt, totalstock, stockcode, len(filterResults),
                diffStr)
            utils.overwrite(outstr, prefixstr)
            stockdata = stock.getStockDayDataQianFuQuan(stockcode)
            stockdata = stockdata[-500:]
            didata = di.calculateData(stockdata)
            QCoreApplication.processEvents()
            if (didata[-1] and didata[-1].get('tip')):
                filterResults.append({
                    'code': stockcode,
                    'date': didata[-1]['date']
                })

        dataArr = []

        for row in filterResults:
            scode = row['code']
            sdate = row['date']
            row = []
            row.append(scode)
            row.append(stock.getStockName(scode))
            row.append(sdate)
            dataArr.append(row)

        #write to file begin
        filename = globals.datapath + '/lastFilterResult.dat'
        try:
            f = open(filename, 'wb')
        except IOError:
            exc_type, exc_value = sys.exc_info()[:2]
            errmsg = '{}: {}'.format(exc_type.__name__, exc_value)
            output(errmsg, 'red')
            return False

        pickle.dump(dataArr, f)
        f.close()
        #write to file end

        tablemodel = stockfilterresultdlg.FilterResultModel(dataArr, None)
        tbResults = globals.mainwin.stockfilterresultdlg.tbResults
        tbResults.setModel(tablemodel)
        globals.mainwin.windowStockFilterResult()