def test_split_time_interval(): first = None last = None start = '2020-01-01' end = '2021-01-01' for interval in split_time_interval(start, end, interval=30): if first is None: first = interval last = interval print(first) print(last) assert is_same_date(first[0], start) assert is_same_date(first[-1], '2020-01-31') assert is_same_date(last[-1], end)
def test_split_time_interval_month(): first = None last = None start = "2020-01-01" end = "2021-01-01" for interval in split_time_interval(start, end, method="month"): if first is None: first = interval last = interval print(first) print(last) assert is_same_date(first[0], start) assert is_same_date(first[-1], "2020-01-31") assert is_same_date(last[0], "2021-01-01") assert is_same_date(last[-1], "2021-01-01")
end_timestamp=end_timestamp, provider='joinquant', level=IntervalLevel.LEVEL_1DAY) day_selector.add_factor(day_gold_cross_factor) # 同时使用日线,周线级别 self.selectors.append(day_selector) self.selectors.append(week_selector) if __name__ == '__main__': start = '2019-01-01' end = '2021-01-01' trader_name = 'keep_run_trader' clear_trader(trader_name=trader_name) for time_interval in split_time_interval(start=start, end=end, interval=40): start_timestamp = time_interval[0] end_timestamp = time_interval[-1] # 成交量 vol_df = get_top_volume_entities(entity_type='stock', start_timestamp=next_date( start_timestamp, -50), end_timestamp=start_timestamp, pct=0.3) # 机构重仓 ii_df = get_top_fund_holding_stocks(timestamp=start_timestamp, pct=0.3, by='trading') current_entity_pool = list( set(vol_df.index.tolist()) & set(ii_df.index.tolist()))