def __init__(self, entity_type='stock', exchanges=['sh', 'sz'], entity_ids=None, codes=None, batch_size=10, force_update=False, sleeping_time=5, default_size=2000, one_shot=False, fix_duplicate_way='add', start_timestamp=None, end_timestamp=None, contain_unfinished_data=False, level=IntervalLevel.LEVEL_1DAY, kdata_use_begin_time=False, close_hour=15, close_minute=0, one_day_trading_minutes=4 * 60) -> None: self.data_schema = get_kdata_schema(entity_type=entity_type, level=level) self.jq_trading_level = to_jq_trading_level(level) super().__init__(entity_type, exchanges, entity_ids, codes, batch_size, force_update, sleeping_time, default_size, one_shot, fix_duplicate_way, start_timestamp, end_timestamp, contain_unfinished_data, level, kdata_use_begin_time, close_hour, close_minute, one_day_trading_minutes) self.current_factors = {} for security_item in self.entities: kdata = get_kdata(entity_id=security_item.id, provider=self.provider, level=self.level.value, order=self.data_schema.timestamp.desc(), limit=1, return_type='domain', session=self.session) if kdata: self.current_factors[security_item.id] = kdata[0].factor self.logger.info('{} latest factor:{}'.format(security_item.id, kdata[0].factor)) auth(JQ_ACCOUNT, JQ_PASSWD)
def __init__(self, security_type=SecurityType.stock, exchanges=['sh', 'sz'], codes=None, batch_size=10, force_update=False, sleeping_time=5, fetching_style=TimeSeriesFetchingStyle.end_size, default_size=2000, contain_unfinished_data=False, level=TradingLevel.LEVEL_1DAY, one_shot=True, start_timestamp=None) -> None: self.data_schema = get_kdata_schema(security_type=security_type, level=level) self.jq_trading_level = to_jq_trading_level(level) self.start_timestamp = to_pd_timestamp(start_timestamp) super().__init__(security_type, exchanges, codes, batch_size, force_update, sleeping_time, fetching_style, default_size, contain_unfinished_data, level, one_shot) self.current_factors = {} for security_item in self.securities: kdata = get_kdata(security_id=security_item.id, provider=self.provider, level=self.level.value, order=self.data_schema.timestamp.desc(), limit=1, return_type='domain', session=self.session) if kdata: self.current_factors[security_item.id] = kdata[0].factor self.logger.info('{} latest factor:{}'.format( security_item.id, kdata[0].factor)) auth(JQ_ACCOUNT, JQ_PASSWD)