Ejemplo n.º 1
0
    def refreshHotSecurities(self):

        result: Dict[str, List[CodeInfo]] = dict()

        blockList = SecuritiesMgr.instance().blockList

        for block in blockList:

            for codeInfo in block.codeList:

                securities = SecuritiesMgr.instance().getSecurities(codeInfo)

                if securities is None or len(securities.klines) < 200:

                    continue

                count = securities.getCountOfGreatIncrease(self.day)

                if count < self.limitCount:

                    continue

                if result.get(block.name) is None:

                    result[block.name] = []

                result[block.name].append(codeInfo)

        self.storeToExcel(result)
Ejemplo n.º 2
0
def findTouchHigh():

    result: list[CodeInfo] = list()

    for securities in SecuritiesMgr.instance().securitiesList:

        lastIndex = len(securities.klines) - 1

        if lastIndex < 0:

            continue

        if securities.isST() or securities.isSTIB():

            continue

        if securities.toatlCapital() > 100 or securities.toatlCapital() < 30:

            continue

        if securities.isDecrease():

            result.append(securities.codeInfo)

    return result
Ejemplo n.º 3
0
    def getGreatIncreaseInDay(self, klineCount: int,
                              increase: float) -> List[CodeInfo]:

        result: List[CodeInfo] = list()

        for securities in SecuritiesMgr.instance().securitiesList:

            if securities.isSTIB() or securities.isST():

                continue

            kLines = self.findKLines(securities.klines)

            if len(kLines) < 200:

                continue

            if kLines[len(kLines) - 1].close < 4:

                continue

            if kLines[len(kLines) - 1].greateChangeRatio():

                continue

            for i in range(len(kLines) - klineCount, len(kLines) - 3):

                if (kLines[i + 3].close -
                        kLines[i].preClose) / kLines[i].preClose > increase:

                    result.append(securities.codeInfo)

                    break

        return result
Ejemplo n.º 4
0
def getInIncreaase():

    result: List[CodeInfo] = []

    securitiesList: List[Securities] = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        if len(securities.klines) < 200:

            continue

        if securities.isSTIB() or securities.isST():

            continue

        billion = 1000000000

        lastIndex = len(securities.klines) - 1

        if securities.capital * securities.klines[lastIndex].close < 2 * billion or securities.capital * securities.klines[lastIndex].close > 20 * billion:

            continue

        if len(securities.crest) > 1 and len(securities.trough) > 0:

            if securities.crest[len(securities.crest) - 1].date > securities.trough[len(securities.trough) - 1].date:

                if securities.crest[len(securities.crest) - 1].high > securities.crest[len(securities.crest) - 2].high:

                    result.append(securities.codeInfo)

    return result
Ejemplo n.º 5
0
def getWWave():

    result: List[Securities] = []

    securitiesList: List[Securities] = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        klineOfDate = None

        if len(securities.klines) < 200:

            continue

        billion = 1000000000

        lastIndex = len(securities.klines) - 1

        if securities.capital * securities.klines[lastIndex].close < 2 * billion or securities.capital * securities.klines[lastIndex].close > 50 * billion:

            continue

        if securities.isSTIB() or securities.isST() or securities.pe == '--':

            continue

        if securities.isWShape():

            result.append(securities)

    return result
Ejemplo n.º 6
0
def testFun():

    allSecurities = SecuritiesMgr.instance().securitiesList

    result = []

    for securities in allSecurities:

        close = [x.close for x in securities.klines]

        dates = [x.date for x in securities.klines]

        data = numpy.array([dates, close])

        data = numpy.transpose(data)

        df = pandas.DataFrame(data=data[0:, 1:],
                              index=data[0:, 0],
                              columns=[securities.codeInfo.name])

        result.append(df)

    df = pandas.concat(result, axis=1)

    corr = df.corr(method="pearson", min_periods=1)

    corr.to_excel("total.xlsx")
Ejemplo n.º 7
0
    def getHotSecuritiesEx(self) -> List[CodeInfo]:

        result: List[CodeInfo] = list()

        for securities in SecuritiesMgr.instance().securitiesList:

            if securities.isSTIB() or securities.isST():

                continue

            kLines = self.findKLines(securities.klines)

            if len(kLines) < 200:

                continue

            if kLines[len(kLines) - 1].close < 4:

                continue

            count = self.getCountOfGreatIncrease(self.day, kLines)

            if count != self.limitCount:

                continue

            if kLines[len(kLines) - 1].greateChangeRatio():

                continue

            result.append(securities.codeInfo)

        return result
Ejemplo n.º 8
0
def findIncreaseCount():

    inHighRange: List[Securities] = []

    inLowRange: List[Securities] = []

    securitiesList = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        result = securities.isInEdgeRange()

        lastIndex = len(securities.klines) - 1

        if result[
                0] is True and 20000000000 < securities.capital * securities.klines[
                    lastIndex].close < 35000000000:

            inHighRange.append(securities)

        if result[
                1] is True and 5000000000 > securities.capital * securities.klines[
                    lastIndex].close > 2000000000:

            inLowRange.append(securities)

    print("在低位的股票数目为 " + str(len(inLowRange)))

    for item in inLowRange:

        print(item.codeInfo.name)
Ejemplo n.º 9
0
    def refreshHistoryIncrease(self):

        result: Dict[str, List[CodeInfo]] = dict()

        blockList = SecuritiesMgr.instance().blockList

        for block in blockList:

            for codeInfo in block.codeList:

                securities = SecuritiesMgr.instance().getSecurities(codeInfo)

                if securities is None:

                    continue

                today = self.endTime

                error = False

                for i in range(0, self.year):

                    temp = int(today / 10000) - i - 1

                    start = temp * 10000 + today % 10000

                    end = (temp + 1) * 10000 + today % 10000

                    count = securities.getCountOfLimitUp(start, end)

                    if count < self.limitCount:

                        error = True

                        break

                if error is True:

                    continue

                if result.get(block.name) is None:

                    result[block.name] = []

                result[block.name].append(codeInfo)

        self.storeToExcel(result)
Ejemplo n.º 10
0
def getReachLimitUp(count:int):

    result: List[Securities] = []

    securitiesList: List[Securities] = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        klineOfDate = None

        if len(securities.klines) < 200:

            continue

        billion = 1000000000

        lastIndex = len(securities.klines) - 1 - count

        # for kLine in reversed(securities.klines):
        #
        #     if kLine.date > lastDate:
        #
        #         lastIndex -= 1

        if securities.capital * securities.klines[lastIndex].close < 2 * billion or securities.capital * securities.klines[lastIndex].close > 50 * billion:

            continue

        if securities.isST() or securities.isSTIB():

            continue

        klineOfDate = securities.klines[lastIndex]

        if klineOfDate is not None:

            if securities.isSecondBoard():

                if (klineOfDate.close - klineOfDate.preClose)/klineOfDate.preClose > 0.19:

                    result.append(securities)

            else:

                if (klineOfDate.close - klineOfDate.preClose)/klineOfDate.preClose > 0.097:

                    result.append(securities)

    return result
Ejemplo n.º 11
0
    def getGreatIncreaseInThreeDay(self) -> List[CodeInfo]:

        result: List[CodeInfo] = list()

        for securities in SecuritiesMgr.instance().securitiesList:

            if len(securities.klines) < 200:

                continue

            lastkLine = securities.klines[len(securities.klines) - 1]

            if securities.checkGreatIncreaseInDay(10, 0.20):

                result.append(securities.codeInfo)

        return result
Ejemplo n.º 12
0
def getInNarrowVibrate():

    result: List[CodeInfo] = []

    securitiesList: List[Securities] = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        if len(securities.klines) < 200:
            continue

        billion = 1000000000

        lastIndex = len(securities.klines) - 1

        if securities.capital * securities.klines[lastIndex].close < 3 * billion or securities.capital * securities.klines[lastIndex].close > 50 * billion:

            continue

        high = -999

        low = 999

        i = 0

        for kLine in reversed(securities.klines):

            high = max(kLine.high, high)

            low = max(kLine.low, low)

            if high < 1.15 * low:

                i += 1

            else:

                break

        if i < 25:

            continue

        result.append(securities.codeInfo)

    return result
Ejemplo n.º 13
0
    def post(self, *args, **kwargs):

        data = json.loads(self.request.body.decode('utf-8'))

        result = list()

        count = int(data["count"])

        startIndex = int(data["startIndex"])

        print(startIndex, count)

        for securities in SecuritiesMgr.instance(
        ).securitiesList[startIndex:startIndex + count]:

            result.append(securities.toJson())

        self.write({'success': 1, "data": {"securities": result}})
Ejemplo n.º 14
0
def test():

    result:list[CodeInfo] = list()

    for securities in SecuritiesMgr.instance().securitiesList:

        lastIndex = len(securities.klines) - 1

        if lastIndex < 0:

            continue;

        if securities.toatlCapital() > 500 or securities.toatlCapital() < 50:

            continue

        if securities.touchHighServeralTimes():

            pass

        result.append(securities.codeInfo)
Ejemplo n.º 15
0
def getHotSecurities():

    result: List[CodeInfo] = []

    securitiesList: List[Securities] = SecuritiesMgr.instance().securitiesList

    for securities in securitiesList:

        if len(securities.klines) < 200:

            continue

        billion = 1000000000

        lastIndex = len(securities.klines) - 1

        if securities.capital * securities.klines[lastIndex].close < 3 * billion or securities.capital * securities.klines[lastIndex].close > 50 * billion:

            continue

        if securities.getGreatIncreaseCountOf(20) >= 3:

            result.append(securities.codeInfo)

            continue

        if securities.getGreatIncreaseCountOf(10) == 2:

            result.append(securities.codeInfo)

            continue

        if securities.isGreatIncreaseInPast(day = 12, increase = 0.2):

            result.append(securities.codeInfo)

            continue

    return result
Ejemplo n.º 16
0
        securitiesList.append(stock)

        stocks.append(stock.toJson())

    DatabaseMgr.instance().stocks.remove({})

    DatabaseMgr.instance().stocks.insert_many(stocks)

    result = []

    for stock in stocks:

        codeInfo = CodeInfo()

        codeInfo.code = stock['code']

        codeInfo.name = stock['name']

        result.append(codeInfo.toJson())

    DatabaseMgr.instance().stockInfos.remove({})

    DatabaseMgr.instance().stockInfos.insert_many(result)


SecuritiesMgr.instance()

refreshWWave()

refreshReachLimitUp()
Ejemplo n.º 17
0
import numpy
import pandas
from data.securities import Securities
from storemgr.storemgr import SecuritiesMgr
from data.codeInfo import CodeInfo
from data.klineModel import KLineModel
import matplotlib.pyplot as plt

cdkj = SecuritiesMgr.instance().getSecurities(
    codeInfo=CodeInfo(code="600584", name="长电科技"))

jfkj = SecuritiesMgr.instance().getSecurities(
    codeInfo=CodeInfo(code="600519", name="贵州茅台"))

print(cdkj)

cdkjClose = [x.close for x in cdkj.klines]

jfkjClose = [x.close for x in jfkj.klines]

df1 = pandas.DataFrame(numpy.array(cdkjClose), columns=[cdkj.codeInfo.name])

df2 = pandas.DataFrame(numpy.array(jfkjClose), columns=[jfkj.codeInfo.name])

df = pandas.concat([df1, df2], axis=1)

corr = df.corr(method="pearson", min_periods=1)

df1.to_csv("cdkj_jfkj.csv")

df.plot(figsize=(20, 12))
Ejemplo n.º 18
0
        values += ";"

    return values


def securitiesValue(securitiesInfo: Securities):

    value = "('%s', '%s', %f)" % (securitiesInfo.codeInfo.code,
                                  securitiesInfo.codeInfo.name,
                                  securitiesInfo.capital)

    return value


for securities in SecuritiesMgr.instance().securitiesList:

    if securities.isST() or securities.isSTIB():

        continue

    sql = "insert into securities (code, name, capital) values %s" % securitiesValue(
        securities)

    cur.execute(sql)

    cur.execute(
        "CREATE TABLE if not exists kline_day_%s (id serial PRIMARY key, date integer, high real, low real, open real, close real, preClose real)"
        % securities.codeInfo.code)

    cur.execute("delete from kline_day_%s" % securities.codeInfo.code)