Exemplo n.º 1
0
def sync_cb_data_job(app):
    print("begin to sync data job...")
    try:

        with app.app_context():
            # 检查是否交易日
            if trade_utils.is_trade_date() is False:
                return 'OK'

            # 先同步一下可转债数据
            cb_ninwen.fetch_data()
    except Exception as e:
        print('sync_cb_data_job is failure. ', e)
Exemplo n.º 2
0
def do_update_data_after_trade_is_end():
    # 检查是否交易日
    if trade_utils.is_trade_date() is False:
        return 'OK'

    do_update_data_exclude_group_after_trade_is_end(False)

    # # 爬每日交易数据
    # cb_jsl_daily.do_fetch_data()
    #
    # # 更新轮动组合数据
    # update_groups()

    return 'OK'
Exemplo n.º 3
0
def do_update_data_exclude_group_after_trade_is_end(need_check_trade_day):
    if need_check_trade_day:
        # 检查是否交易日
        if trade_utils.is_trade_date() is False:
            return 'OK'

    # 更新当天的可转债数据
    cb_ninwen.fetch_data()

    ymd = get_ymd()

    # 将已全部卖掉(持有数量为0)的可转债归档
    archive_bond(ymd)

    # 更新当天的收益
    update_yield(ymd)

    # 更新可转债价格中位数
    update_cb_index()
Exemplo n.º 4
0
def do_update_data_before_trade_is_start():
    # 检查是否交易日
    if trade_utils.is_trade_date() is False:
        return 'OK'

    # 初始化today_sum_buy, 将昨天收盘市值作为今天的开盘市值
    rowcount = db_utils.execute_sql_with_rowcount(
        """
        update hold_bond set modify_date = :modify_date, today_sum_sell = 0,
            today_sum_buy = (select round(c.cb_price2_id*hold_bond.hold_amount,2) 
                            from changed_bond c where c.bond_code = hold_bond.bond_code)
    """, {"modify_date": datetime.now()})
    if rowcount > 0:
        print('init today_sum_buy is successful. count:' + str(rowcount))

    # 更新一下正股诊断信息
    stock_10jqka.fetch_data()

    return 'OK'