ptrade排除A股创业板,科创板的股票
由于创业板和科创板的股票波动会比沪深主板的要大,所以如果想要按照某些策略,排除这两个板块的股票,可以使用下面的方法:
返回的all_stock_set就是排除了创业板,科创板的股票列表。
ptrade接口文档:http://ptradeapi.com
MARKET_DICT = {0: '科创板', 1: '创业板', }
IGNORE_MARKET = [0, 1]
def create_target(context):
all_stock_set = set(get_Ashares(date=None))
for ignore_code in IGNORE_MARKET:
market = MARKET_DICT.get(ignore_code)
if market == '科创板':
all_stock_set = all_stock_set - set(filter(lambda x:x.startswith('68'),all_stock_set))
if market == '创业板':
all_stock_set = all_stock_set - set(filter(lambda x:x.startswith('3'),all_stock_set))
return all_stock_set
返回的all_stock_set就是排除了创业板,科创板的股票列表。
ptrade接口文档:http://ptradeapi.com