예제 #1
0
def rowToORM(row, year, quarter):
    obj = Model()

    obj.code = toStr(row.loc['code'])  # 股票代码
    obj.name = toStr(row.loc['name'])  # 股票名称

    obj.year = int(year)  # 分配年份
    obj.quarter = int(quarter)

    tsString = str(row.loc['date'])
    obj.report_date = None
    try:
        obj.report_date = parse(tsString)
    except:
        logging.warning(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.report_date))

    obj.nums = toInt(row.loc['nums'])  # 基金家数
    obj.nlast = toInt(row.loc['nlast'])  # 与上期相比(增加或减少了)
    obj.count = toFloat(row.loc['count'])  # 基金持股数(万股)
    obj.clast = toFloat(row.loc['clast'])  # 与上期相比
    obj.amount = toFloat(row.loc['amount'])  # 基金持股市值
    obj.ratio = toFloat(row.loc['ratio'])  # 占流通盘比率
    return obj
예제 #2
0
def rowToORM(row, year, month):
    obj = Model()

    obj.year = year
    obj.month = month
    obj.avgPrice = toInt(row.loc['avgboxoffice'])  # 平均票价
    obj.avpPeoPle = toInt(row.loc['avgshowcount'])  # 场均人次
    obj.boxOffice = toFloat(row.loc['boxoffice'])  # 单日票房(万)
    obj.box_pro = toFloat(row.loc['box_pro'])  # 月度占比
    obj.iRank = toInt(row.loc['Irank'])  # 排名
    obj.movieName = toStr(row.loc['MovieName'])[0:Model.TEXT_MAX_LENGTH]  # 影片名

    if obj.movieName == "其他" or obj.movieName == "其它":
        return None

    obj.womIndex = toFloat(row.loc['WomIndex'])  # 口碑指数
    obj.days = toInt(row.loc['days'])
    tsString = str(row.loc['releaseTime'])
    obj.time = None
    try:
        obj.releaseTime = parse(tsString)
    except:
        logging.warning(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.releaseTime))

    if obj.releaseTime is None:
        return None

    return obj
예제 #3
0
def rowToORM(row):
    obj = Model()

    obj.boxOffice = toFloat(row.loc['BoxOffice'])  # 实时票房(万)
    obj.irank = toInt(row.loc['Irank'])  # 排名
    obj.movieName = toStr(row.loc['MovieName'])  # 影片名
    obj.boxPer = toFloat(row.loc['boxPer'])  # 票房占比 ( % )
    obj.movieDay = toInt(row.loc['movieDay'])  # 上映天数
    obj.sumBoxOffice = toFloat(row.loc['sumBoxOffice'])  # 累计票房(万)

    tsString = str(row.loc['time'])
    obj.time = None
    try:
        obj.time = parse(tsString)
        minute = obj.time.minute
        if minute >= 30:
            minute = 30
        else:
            minute = 0
        tsString = obj.time.strftime("%Y-%m-%d %H")
        tsString = "{pre}:{min:02d}:00".format(pre=tsString, min=minute)
        obj.time = parse(tsString)
    except:
        logging.warning(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.time))

    if obj.movieName == "其它":
        return None

    return obj
예제 #4
0
def rowToORM(row, date: datetime):
    obj = Model()

    obj.date = date
    obj.timestamp = date
    obj.avgPrice = toInt(row.loc['AvgPrice'])  # 平均票价
    obj.avpPeoPle = toInt(row.loc['AvpPeoPle'])  # 场均人次
    obj.boxOffice = toFloat(row.loc['BoxOffice'])  # 单日票房(万)
    obj.boxOffice_Up = toFloat(row.loc['BoxOffice_Up'])  # 环比变化 ( % )
    obj.iRank = toInt(row.loc['IRank'])  # 排名
    obj.movieDay = toInt(row.loc['MovieDay'])  # 上映天数
    obj.movieName = str(row.loc['MovieName'])[0:Model.TEXT_MAX_LENGTH]  # 影片名
    obj.sumBoxOffice = toFloat(row.loc['SumBoxOffice'])  # 累计票房(万)
    obj.womIndex = toFloat(row.loc['WomIndex'])  # 口碑指数
    obj.pk = "{name}_{date}".format(name=obj.movieName,
                                    date=dateTimeToTsStr(date))

    return obj
예제 #5
0
파일: tick.py 프로젝트: leegggg/shareInfo
def rowToORM(row, code: str, currentStr: str):
    tsStr = "{}T{}".format(currentStr, toStr(row.loc['time']))
    # timestamp = datetime.fromisoformat(tsStr)  # Only for py3.7+
    timestamp = parser.parse(tsStr)
    timestamp = timestamp - timedelta(seconds=TIME_ZONE_OFFSET_SECONDS)
    typeStr = toStr(row.loc['type'])
    influxPoint = {
        "measurement": "share_tick",
        "tags": {
            "code": code
        },
        "time": timestamp,
        "fields": {
            "price": toFloat(row.loc['price']),
            "change": toFloat(row.loc['change']),
            "volume": toInt(row.loc['volume']),
            "amount": toInt(row.loc['amount']),
            "type_buy": typeStr == '买盘',
            "type_sell": typeStr == '卖盘',
            "type_neutral": typeStr == '中性盘'
        }
    }
    return influxPoint
예제 #6
0
def rowToORM(row):
    obj = Model()

    obj.code = toStr(row.loc['code'])  # 股票代码
    obj.name = toStr(row.loc['name'])  # 股票名称

    obj.date = datetime.now()

    tsString = str(row.loc['ipo_date'])
    obj.ipo_date = None
    try:
        obj.ipo_date = parse(tsString)
    except:
        logging.info(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.ipo_date))

    tsString = str(row.loc['issue_date'])
    obj.issue_date = None
    try:
        obj.issue_date = parse(tsString)
    except:
        logging.info(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.issue_date))

    if obj.code is None or obj.ipo_date is None:
        return None

    obj.amount = toInt(row.loc['amount'])  # 发行数量(万股)
    obj.markets = toInt(row.loc['markets'])  # 上网发行数量(万股)
    obj.price = toFloat(row.loc['price'])  # 发行价格(元)
    obj.pe = toFloat(row.loc['pe'])  # 发行市盈率
    obj.limit = toFloat(row.loc['limit'])  # 个人申购上限(万股)
    obj.funds = toFloat(row.loc['funds'])  # 募集资金(亿元)
    obj.ballot = toFloat(row.loc['ballot'])  # 网上中签率( %)
    return obj
예제 #7
0
def rowToORM(row):
    obj = Model()

    tsString = toStr(row.loc['opDate'])
    obj.opDate = None
    try:
        obj.opDate = parse(tsString)
    except:
        logging.warning(
            "Fail to get date from {} from {}. Using {} as Fallback".format(
                __name__, tsString, obj.opDate))

    obj.rzye = toInt(row.loc['rzye'])  # 本日融资余额(元)
    obj.rzmre = toInt(row.loc['rzmre'])  # 本日融资买入额(元)
    obj.rqyl = toInt(row.loc['rqyl'])  # 本日融券余量
    obj.rqylje = toInt(row.loc['rqylje'])  # 本日融券余量金额(元)
    obj.rqmcl = toInt(row.loc['rqmcl'])  # 本日融券卖出量
    obj.rzrqjyzl = toInt(row.loc['rzrqjyzl'])  # 本日融资融券余额(元)
    return obj
예제 #8
0
def rowToORM(row):
    obj = Model()

    obj.code = toStr(row.loc['stockCode'])  # 标的证券代码
    obj.name = toStr(row.loc['securityAbbr'])  # 标的证券简称

    tsString = toStr(row.loc['opDate'])
    obj.opDate = None
    try:
        obj.opDate = parse(tsString)
    except:
        logging.warning("Fail to get date from {} from {}. Using {} as Fallback".
                        format(__name__, tsString, obj.opDate))

    obj.rzmre = toInt(row.loc['rzmre'])  # 融资买入额(元)
    obj.rzye = toInt(row.loc['rzye'])  # 融资余额(元)
    obj.rqmcl = toInt(row.loc['rqmcl'])  # 融券卖出量
    obj.rqyl = toInt(row.loc['rqyl'])  # 融券余量
    obj.rqye = toInt(row.loc['rqye'])  # 融券余量(元)
    obj.rzrqye = toInt(row.loc['rzrqye'])  # 融资融券余额(元)

    return obj