Example #1
0
def test_1d_kdata_recorder():
    recorder = JqChinaStockKdataRecorder(codes=SAMPLE_STOCK_CODES,
                                         sleeping_time=0,
                                         level=IntervalLevel.LEVEL_1DAY,
                                         real_time=False)
    try:
        recorder.run()
    except:
        assert False
Example #2
0
def test_5m_kdata_recorder():
    recorder = JqChinaStockKdataRecorder(codes=['000338'],
                                         sleeping_time=0,
                                         level=IntervalLevel.LEVEL_5MIN,
                                         real_time=False,
                                         start_timestamp='2019-01-01')
    try:
        recorder.run()
    except:
        assert False
Example #3
0
def test_1d_hfq_kdata_recorder():
    recorder = JqChinaStockKdataRecorder(codes=['000338'],
                                         sleeping_time=0,
                                         level=IntervalLevel.LEVEL_1DAY,
                                         real_time=False,
                                         adjust_type='hfq')
    try:
        recorder.run()
    except:
        assert False
Example #4
0
def record_wk_kdata():
    while True:
        try:
            JqChinaStockKdataRecorder(level=IntervalLevel.LEVEL_1WEEK).run()
            JqChinaStockKdataRecorder(level=IntervalLevel.LEVEL_1MON).run()

            break
        except Exception as e:
            logger.exception('joinquant kdata runner error:{}'.format(e))
            time.sleep(60)
Example #5
0
def test_1h_kdata_recorder():
    recorder = JqChinaStockKdataRecorder(
        codes=["000338"],
        sleeping_time=0,
        level=IntervalLevel.LEVEL_1HOUR,
        real_time=False,
        start_timestamp="2019-01-01",
    )
    try:
        recorder.run()
    except:
        assert False
Example #6
0
def every_day_report():
    while True:
        try:
            t = now_pd_timestamp()
            if t.dayofweek in (5, 6):
                logger.info(f'today:{t} is {t.day_name()},just ignore')

            today = to_time_str(t)

            # 抓取k线数据
            JqChinaStockKdataRecorder(level=IntervalLevel.LEVEL_1DAY).run()
            JqChinaStockKdataRecorder(level=IntervalLevel.LEVEL_1WEEK).run()
            JqChinaStockKdataRecorder(level=IntervalLevel.LEVEL_1MON).run()

            # 计算均线
            my_selector = TargetSelector(start_timestamp='2016-01-01',
                                         end_timestamp=today)
            # add the factors
            # 设置dry_run为True,因为我们只需要最近的数据,不需要加载全量数据进行回测
            ma_factor = CrossMaFactor(start_timestamp='2016-01-01',
                                      end_timestamp=today,
                                      dry_run=True)

            my_selector.add_filter_factor(ma_factor)

            my_selector.run()

            long_targets = my_selector.get_open_long_targets(timestamp=today)
            if long_targets:
                df = get_entities(provider='eastmoney',
                                  entity_schema=Stock,
                                  entity_ids=long_targets,
                                  columns=['code', 'name'])
                info = [
                    df.loc[i, 'code'] + ' ' + df.loc[i, 'name']
                    for i in df.index
                ]
                msg = ' '.join(info)
            else:
                msg = 'no targets'

            logger.info(msg)

            email_action = EmailInformer()
            email_action.send_message("*****@*****.**", f'{today} 均线选股结果', msg)

            break
        except Exception as e:
            logger.exception('report1 sched error:{}'.format(e))
            time.sleep(60 * 3)