Skip to content

Instantly share code, notes, and snippets.

@JackTheMico
Created August 9, 2022 13:46
Show Gist options
  • Save JackTheMico/2b745980c12ae458b87f40834870abaa to your computer and use it in GitHub Desktop.
Save JackTheMico/2b745980c12ae458b87f40834870abaa to your computer and use it in GitHub Desktop.
# 过滤停牌、ST类股票及其他具有退市标签的股票
def filter_paused_and_st_stock(stock_list):
current_data = get_current_data()
return [stock for stock in stock_list
if not current_data[stock].paused
and not current_data[stock].is_st
# and 'ST' not in current_data[stock].name
# and '*' not in current_data[stock].name
and '退' not in current_data[stock].name]
# 过滤涨停的股票
def filter_limitup_stock(context, stock_list):
last_prices = history(1, unit='1m', field='close', security_list=stock_list)
current_data = get_current_data()
# 已存在于持仓的股票即使涨停也不过滤,避免此股票再次可买,但因被过滤而导致选择别的股票
return [stock for stock in stock_list if stock in context.portfolio.positions.keys()
or last_prices[stock][-1] < current_data[stock].high_limit]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment