Communitygithub.com

ZhuLinsen/alphasift

Automated stock screening Skill. Use when: the user wants to screen A-shares by strategy, list available strategies, run screens like dual-low/volume-breakout, or save/run and perform T+N backtesting. Outputs a candidate stock list via the alphasift CLI or Python interface.

What is alphasift?

alphasift is a full-market candidate discovery and cross-sectional ranking engine for A-shares. It operates upstream of single-stock deep analysis (like daily_stock_analysis) and provides structured JSON results (ScreenResult) containing ranked picks with scores, price data, technical indicators, LLM-based reasoning, risk assessments, and portfolio concentration notes. The skill supports multiple built-in strategies (e.g., dual_low, volume_breakout, balanced_alpha, capital_heat) and can be extended via YAML profiles for scoring, risk, portfolio, scorecard, and event rules. It integrates with local and remote LLMs for thematic tagging and ranking, and offers L3 post-analysis via a local scorecard or an optional DSA (Deep Stock Analysis) HTTP service. Users can list strategies, run one-shot demos (quickstart), screen with customizable parameters, save run results for later T+N evaluation (with optional cost deduction and drawdown estimation), and audit the current configuration. The tool also caches industry/theme mappings and board heat metrics, automatically enriches top candidates with daily K-line data, and uses portfolio concentration logic to reduce crowded trades. It currently supports only the `cn` market and requires a local Python package installation (`pip install -e .`).

Works with~Claude Code✓Codex CLI~Cursor✓Gemini CLI
npx skills add ZhuLinsen/alphasift

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

alphasift — Automatic Stock Screening Skill

Screen, score, and rank candidate A-share stocks by strategy.

Positioning: full-market candidate discovery and cross-sectional ranking engine. It sits upstream of single-stock deep analysis services like daily_stock_analysis; DSA is only an optional L3 post-analyzer, not a primary screening dependency.

Use When

  • The user wants to list available strategies
  • The user wants to screen A-shares by strategies such as dual_low, volume_breakout
  • The user wants structured JSON results for further analysis by downstream agents
  • The user wants to save screening runs and evaluate results later using the latest snapshot
  • The user is new to this project and wants to see the minimal end-to-end pipeline (full market → candidates → ranking) with one command alphasift quickstart

Preconditions

  • Currently only supports market="cn"
  • Must install the package from the repo root first: pip install -e .
  • To use LLM ranking, set LITELLM_MODEL, LLM_CHANNELS, LITELLM_CONFIG or the legacy variables LLM_API_KEY/LLM_MODEL/LLM_BASE_URL
  • You can reuse the LiteLLM configuration fields from daily_stock_analysis, including OPENAI_*, GEMINI_*, DEEPSEEK_API_KEY, OLLAMA_API_BASE
  • Strategy YAML can override default rules via scoring_profile, risk_profile, portfolio_profile, scorecard_profile
  • Strategy YAML can configure preferred/avoided events, announcement categories, and candidate context source weights via event_profile
  • LLM outputs candidate industry/theme tags; if a candidate provides industry/concepts/board_heat_score/board_heat_trend_score, these serve as anchor points for LLM, theme heat factors, and portfolio diversification layers. The history sidecar can backfill persistence, cooling, and state fields. The default portfolio diversification layer uses these tags to map risk buckets, reducing duplicate allocation in the same crowded trade
  • L3 uses the local scorecard post-scorer by default, and can also append dsa or external_http
  • To enable DSA post-analysis, set DSA_API_URL; the default calls POST /api/v1/analysis/analyze
  • Strategies that depend on daily K-line data automatically perform daily K-line enrichment on the Top N candidates after L1
  • The daily K-line data source DAILY_SOURCE supports akshare (default), baostock, or auto; auto automatically degrades to baostock when akshare fails as a free fallback

Operations

1. List Strategies

alphasift strategies

1.1 Quickstart Demo (No API Key Required)

alphasift quickstart
alphasift quickstart --strategy balanced_alpha --max-output 8

2. Run Screening

alphasift screen dual_low --no-llm
alphasift screen volume_breakout --max-output 10
alphasift screen balanced_alpha --no-llm
alphasift screen capital_heat
alphasift screen balanced_alpha --context "Today the brokerage sector saw increased volume, with low-valuation financial stocks attracting capital inflows"
alphasift --env-file /home/ubuntu/daily_ai_assistant/.env screen balanced_alpha
alphasift screen balanced_alpha --explain
alphasift screen balanced_alpha --candidate-context-file candidate_context.csv
alphasift screen dual_low --no-post-analysis
alphasift screen shrink_pullback --no-llm
alphasift screen dual_low --post-analyzer dsa
alphasift audit
alphasift industry-cache --output data/industry_map.csv --explain
alphasift screen dual_low --no-llm --save-run
alphasift runs
alphasift evaluate <run_id> --explain
alphasift evaluate-batch --limit 20 --explain
alphasift evaluate <run_id> --with-price-path --explain

3. Python API

from alphasift import evaluate_saved_run, evaluate_saved_runs, list_strategies, screen

list_strategies()
screen("dual_low", market="cn", use_llm=False)
evaluate_saved_run("<run_id>")
evaluate_saved_runs(limit=20)

Output

Returns a ScreenResult JSON with key fields:

  • strategy
  • market
  • strategy_version
  • snapshot_count
  • after_filter_count
  • picks
  • llm_ranked
  • llm_market_view
  • llm_selection_logic
  • llm_portfolio_risk
  • llm_coverage
  • post_analyzers
  • daily_enriched
  • risk_enabled
  • portfolio_concentration_notes
  • degradation
  • snapshot_source
  • source_errors

Each Pick contains:

  • rank
  • code
  • name
  • final_score
  • screen_score
  • ranking_reason
  • risk_summary
  • price
  • change_pct
  • amount
  • total_mv
  • turnover_rate
  • volume_ratio
  • pe_ratio
  • pb_ratio
  • industry
  • concepts
  • board_heat_score
  • board_heat_latest_score
  • board_heat_trend_score
  • board_heat_persistence_score
  • board_heat_cooling_score
  • board_heat_observations
  • board_heat_state
  • board_heat_summary
  • change_60d
  • signal_score
  • macd_status
  • rsi_status
  • breakout_20d_pct
  • range_20d_pct
  • volume_ratio_20d
  • body_pct
  • pullback_to_ma20_pct
  • consolidation_days_20d
  • factor_scores
  • llm_confidence
  • llm_sector
  • llm_theme
  • llm_tags
  • llm_catalysts
  • llm_risks
  • llm_thesis
  • llm_style_fit
  • llm_watch_items
  • llm_invalidators
  • risk_score
  • risk_level
  • risk_penalty
  • risk_flags
  • portfolio_penalty
  • portfolio_flags
  • post_analysis_status
  • post_analysis_score_deltas
  • deep_analysis_status
  • deep_analysis_summary
  • deep_analysis_result
  • deep_analysis_signal_score
  • deep_analysis_sentiment_score
  • deep_analysis_operation_advice
  • deep_analysis_trend_prediction
  • deep_analysis_risk_flags

Boundaries

  • There is currently no standalone remote get_result service; use --save-run, runs, evaluate, and evaluate-batch locally to manage run records
  • audit is used for self-checking strategy profile overrides, known capability gaps, and next-step priorities
  • --candidate-context-file supports CSV/JSON/JSONL format, aligns candidate-level news, announcements, capital flows, or research summaries via the code field, and only injects rows related to the current candidate pool. Optional fetching will include source_count, source_confidence, source_weight_score, context_summary, and announcement categories
  • Candidate-level context identifies coarse-grained event tags and negative risk tags for LLM cross-sectional ranking reference
  • industry-cache caches industry/concept mappings and sector heat fields, and writes them into the history sidecar. When loading the mapping later, it can backfill sector heat rolling trends, persistence, cooling, and state fields for LLM context and the theme_heat factor
  • The portfolio diversification layer prioritizes industry/theme tags returned by the LLM, falling back to the candidate's industry field if needed. If both are missing, rule scores remain unchanged
  • L3 post-analyzers run only on the final candidates and do not participate in the full-market initial screening; the local scorecard is enabled by default, and DSA is just one of the optional backends
  • T+N evaluation is based on the saved price and the latest snapshot price at the time of evaluation, not equivalent to full back-adjusted backtesting. Transaction costs can be deducted, and breakout/pullback pattern posterior labels can be output. --with-price-path additionally estimates maximum drawdown and maximum floating profit

Related Skills