def init_factors(self, security_type, exchanges, codes, the_timestamp, start_timestamp, end_timestamp): factor = CrossMaFactor(security_type=security_type, exchanges=exchanges, codes=codes, the_timestamp=the_timestamp, start_timestamp=start_timestamp, end_timestamp=end_timestamp) factor.run() self.must_factors = [factor]
def init_factors(self, security_type, exchanges, codes, the_timestamp, start_timestamp, end_timestamp): ma_factor = CrossMaFactor(security_type=security_type, exchanges=exchanges, codes=codes, the_timestamp=the_timestamp, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider=self.provider, level=self.level) ma_factor.run() self.must_factors = [ma_factor]
def init_selectors(self, entity_ids, entity_type, exchanges, codes, start_timestamp, end_timestamp): myselector = TargetSelector(entity_ids=entity_ids, entity_type=entity_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider='joinquant') myselector.add_filter_factor( CrossMaFactor(entity_ids=entity_ids, entity_type=entity_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp)) self.selectors.append(myselector)
def init_selectors(self, entity_ids, entity_type, exchanges, codes, start_timestamp, end_timestamp): myselector = TargetSelector(entity_ids=entity_ids, entity_type=entity_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider='ccxt', level=IntervalLevel.LEVEL_1MIN) myselector.add_filter_factor( CrossMaFactor(entity_ids=entity_ids, entity_type=entity_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider='ccxt', level=IntervalLevel.LEVEL_1MIN)) self.selectors.append(myselector)
def init_selectors(self, security_list, security_type, exchanges, codes, start_timestamp, end_timestamp): myselector = TargetSelector(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider='ccxt', level=TradingLevel.LEVEL_1MIN) myselector.add_filter_factor( CrossMaFactor(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, provider='ccxt', level=TradingLevel.LEVEL_1MIN)) self.selectors.append(myselector)
def init_selectors(self, security_list, security_type, exchanges, codes, start_timestamp, end_timestamp): myselector = TargetSelector(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp) myselector.add_filter_factor( CrossMaFactor(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp)) self.selectors.append(myselector)
def init_selectors(self, security_list, security_type, exchanges, codes, start_timestamp, end_timestamp): my_selector = TargetSelector(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp) # add the factors my_selector \ .add_filter_factor(CrossMaFactor(security_list=security_list, security_type=security_type, exchanges=exchanges, codes=codes, start_timestamp=start_timestamp, end_timestamp=end_timestamp, level=TradingLevel.LEVEL_1DAY)) self.selectors.append(my_selector)
def test_cross_ma_selector(): security_list = ['stock_sz_000338'] security_type = 'stock' start_timestamp = '2018-01-01' end_timestamp = '2019-06-30' my_selector = TargetSelector(security_list=security_list, security_type=security_type, start_timestamp=start_timestamp, end_timestamp=end_timestamp) # add the factors my_selector \ .add_filter_factor(CrossMaFactor(security_list=security_list, security_type=security_type, start_timestamp=start_timestamp, end_timestamp=end_timestamp, level=TradingLevel.LEVEL_1DAY)) my_selector.run() print(my_selector.open_long_df) print(my_selector.open_short_df) assert 'stock_sz_000338' in my_selector.get_open_short_targets('2018-01-29')
def test_cross_ma_selector(): entity_ids = ['stock_sz_000338'] entity_type = 'stock' start_timestamp = '2018-01-01' end_timestamp = '2019-06-30' my_selector = TargetSelector(entity_ids=entity_ids, entity_type=entity_type, start_timestamp=start_timestamp, end_timestamp=end_timestamp) # add the factors my_selector \ .add_filter_factor(CrossMaFactor(entity_ids=entity_ids, entity_type=entity_type, start_timestamp=start_timestamp, end_timestamp=end_timestamp, level=IntervalLevel.LEVEL_1DAY)) my_selector.run() print(my_selector.open_long_df) print(my_selector.open_short_df) assert 'stock_sz_000338' in my_selector.get_open_short_targets( '2018-01-29')
def test_cross_ma(): factor = CrossMaFactor(entity_type='stock', codes=['000338'], start_timestamp='2019-01-01', end_timestamp='2019-06-10', level=IntervalLevel.LEVEL_1DAY, provider='joinquant', short_window=5, long_window=10) print(factor.get_factor_df().tail()) print(factor.get_result_df().tail()) score = factor.get_result_df()['score'] assert score[('stock_sz_000338', '2019-06-03')] == True assert score[('stock_sz_000338', '2019-06-04')] == True assert score[('stock_sz_000338', '2019-06-05')] == False assert score[('stock_sz_000338', '2019-06-06')] == False assert score[('stock_sz_000338', '2019-06-10')] == False factor.move_on() score = factor.get_result_df()['score'] assert score[('stock_sz_000338', '2019-06-17')] == True
def test_cross_ma(): factor = CrossMaFactor(security_type=SecurityType.stock, codes=['000338'], start_timestamp='2019-01-01', end_timestamp='2019-06-10', level=TradingLevel.LEVEL_1DAY, provider=Provider.JOINQUANT, short_window=5, long_window=10) print(factor.get_depth_df().tail()) print(factor.get_result_df().tail()) score = factor.get_result_df()['score'] assert score[('stock_sz_000338', '2019-06-03')] == True assert score[('stock_sz_000338', '2019-06-04')] == True assert score[('stock_sz_000338', '2019-06-05')] == False assert score[('stock_sz_000338', '2019-06-06')] == False assert score[('stock_sz_000338', '2019-06-10')] == False factor.move_on() score = factor.get_result_df()['score'] assert score[('stock_sz_000338', '2019-06-17')] == True