alphasift

Full-market stock discovery for AI agents: A-shares plus US/HK/JP/KR/TW/IN, auditable YAML strategies, optional LLM ranking, sector-diversified picks, and true T+N evaluation vs. benchmark. AI选股

Automatically checked · GitHub checked 2026-11-15

alphasift

Overview

AlphaSift

Full-market stock discovery for AI agents. AlphaSift scans every A-share (or the larger listings of six other markets), screens them with auditable YAML strategies, optionally lets an LLM rank the shortlist, keeps the final picks diversified across sectors, and saves every run so you can check later whether the picks worked.

Python 3.10+ License: Apache 2.0 Markets

English | 中文 | 日本語

Track record: every built-in strategy runs after each close and its picks are measured at T+5 / T+10 / T+20 against the market benchmark — see the dashboard and the raw runs on the track-record branch.

full market ──► L1 hard filters + factor scores ──► L2 LLM ranking (optional)
  (5,000+ names)    (YAML strategy, no API key)        (cross-candidate reasoning)
                                                              │
saved run ◄── L3 post-analysis ◄── risk overlay + sector diversity cap
   │          (scorecard / DSA / HTTP)
   └──► T+N evaluation: returns, win rate, failure review

Why AlphaSift

  • A-shares first, six more markets in beta. China A-shares go through a dedicated multi-source chain. US, Hong Kong, Japan, South Korea, Taiwan and India go through the Yahoo Finance screener, which also works from overseas servers and CI runners; they have one unofficial data source and fewer fields (see Known limitations).
  • Runs without an API key. L1 screening, scoring, risk and diversity control are deterministic. An LLM only re-ranks the shortlist when you configure one.
  • Strategies are YAML, not code. Filters, factor weights, scoring curves, risk thresholds and sector buckets live in readable files that you can diff and review.
  • Picks don't all come from one sector. Every row carries an industry or sector label. portfolio_profile.mode: hard_cap keeps at most N picks per sector in the Top N.
  • Data sources heal themselves. Source outcomes persist across runs, so dead sources are tried last. Each source has a time budget. A last-good snapshot is used, marked as stale, when every live source fails.
  • Every run is checkable. Save runs and evaluate them later with transaction costs, win rates, failure samples and optional price paths (max drawdown / run-up).
  • Built for agents. SKILL.md describes the callable interface. alphasift serve exposes a read-only JSON API for dashboards and orchestrators.

Quick start

pip install -e .

# A-shares, no API key needed
alphasift screen dual_low --no-llm

# Other markets: us, hk, jp, kr, tw, in
alphasift screen global_value --market hk --no-llm

# Add LLM ranking: set GEMINI_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEY
# (or LITELLM_MODEL / LLM_CHANNELS) in .env first
cp .env.example .env
alphasift screen dual_low

# Save a run, then evaluate it a few days later
alphasift screen dual_low --no-llm --save-run
alphasift evaluate <run_id> --with-price-path --explain

Run alphasift quickstart for a guided no-key demo, and alphasift strategies to list the strategies.

Example output

Real runs on 2026-11-03 with --no-llm. They show what the engine outputs; they are not recommendations.

China A-shares (dual_low): 5,218 stocks, 284 after filters, Top 5 capped at 2 per sector

#CodeNameIndustryPEPB
1601169北京银行Banks5.80.43
2600016民生银行Banks5.70.26
3601668中国建筑Construction6.60.39
4601186中国铁建Infrastructure6.30.29
5601919中远海控Shipping7.91.12

Hong Kong (global_value --market hk): 581 stocks, 275 after filters

#CodeNameSectorPEPB
10998.HKChina CITIC BankFinancial Services5.80.43
20267.HKCITIC LimitedIndustrials5.30.38
31398.HKICBCFinancial Services6.50.59
40001.HKCK HutchisonIndustrials6.90.45
50358.HKJiangxi CopperBasic Materials5.70.77

Japan (global_value --market jp): 773 stocks, 408 after filters

#CodeNameSectorPEPB
19501.TTokyo Electric PowerUtilities2.60.21
29022.TCentral Japan RailwayIndustrials7.20.71
39502.TChubu Electric PowerUtilities10.60.66
41911.TSumitomo ForestryConsumer Cyclical9.00.70
57203.TToyota MotorConsumer Cyclical8.70.97

On an overseas server, the A-share run takes about 10 seconds once source health is warm. Each Yahoo market takes 2–10 seconds.

Supported markets

--marketMarketSnapshot sourceNotes
cnChina A-sharessina → efinance → akshare_em → em_datacenter (Tushare first when a token is set)Health-aware ordering; EastMoney industry backfill
usUnited StatesYahoo screener (NYSE / Nasdaq listings ≥ $1B, including ADRs)ALPHASIFT_US_TICKERS uses an explicit ticker list instead
hkHong KongYahoo screenerUniverse floor ≈ HK$8B
jpJapanYahoo screenerUniverse floor ≈ ¥150B
krSouth KoreaYahoo screener + Naver FinanceYahoo has no KR PE/PB; they come from Naver's (unofficial) mobile API, about 10s extra. ALPHASIFT_KR_VALUATION=0 turns it off
twTaiwanYahoo screenerTWSE and TPEx listings
inIndiaYahoo screenerNSE and BSE listings

Non-CN codes are Yahoo symbols (AAPL, 0700.HK, 7203.T, 005930.KS). Daily K-line enrichment and T+N evaluation use yfinance for these markets. Candidate-level news, announcement and fund-flow context is A-share only.

Built-in strategies

StrategyMarketsTypeIdea
dual_lowcnValueLow PE + low PB, activity and stability confirmation, hard cap per sector
quality_valuecnValueReasonable valuation with liquidity and controlled volatility
blue_chip_incomecnIncomeLiquid blue chips with dividend quality
low_volatility_qualitycnQualityDefensive screen using daily volatility, drawdown and ATR
volume_breakoutcnTrendVolume expansion through resistance
shrink_pullbackcnTrendPullback into support within an uptrend (daily K-line)
capital_heatcnMomentumActive capital flow without extreme overheating
oversold_reversalcnReversalRepair candidates with controlled drawdown
balanced_alphacnFrameworkGeneral multi-factor discovery
momentum_qualitycnFrameworkTrend confirmation plus quality filters
global_valueus, hk, jp, kr, tw, inValuedual_low for other markets, with no currency-dependent thresholds
us_momentum_qualityusTrendMomentum and quality for US large caps

Write your own in strategies/. See the strategy guide.

Configuration

Copy .env.example to .env. AlphaSift reads LiteLLM-style settings, so it can reuse the configuration of daily_stock_analysis. The most common settings:

VariablePurposeDefault
LITELLM_MODELMain model, provider/modelgemini/gemini-2.5-flash
GEMINI_API_KEY / OPENAI_API_KEY / DEEPSEEK_API_KEYProvider key for LLM ranking-
LLM_CHANNELS / LITELLM_CONFIGMulti-channel or LiteLLM Router config-
TUSHARE_TOKENPuts Tushare first in the A-share chain-
SNAPSHOT_SOURCE_PRIORITYOverride the A-share source orderdepends on token
ALPHASIFT_SNAPSHOT_CALL_TIMEOUT_SECTime budget per snapshot source60
INDUSTRY_AUTO_BACKFILLFill missing A-share industry labelstrue
ALPHASIFT_DATA_DIRRuns, caches and source health./data
DSA_API_URLEnable the optional DSA deep-analysis step-

The full list is in docs/configuration.md.

More features

  • Python API: from alphasift import screen, evaluate_saved_run, then screen("dual_low", use_llm=False, market="cn").
  • LLM context: --context "..." adds market notes, and --candidate-context-file adds per-stock research.
  • Post-analysis (L3): the local scorecard runs by default. --post-analyzer dsa sends the final shortlist to daily_stock_analysis for single-stock deep analysis.
  • Hotspots: alphasift hotspots and alphasift hotspot "<topic>" rank A-share themes and resolve leader stocks with cache and fallback metadata.
  • Agent and UI payloads: alphasift overview --json, alphasift serve, and alphasift doctor data-sources --all-strategies --explain. Endpoints are listed in the usage guide.

Known limitations

  • AlphaSift is a discovery and ranking engine, not a backtester or an execution system. T+N evaluation compares saved prices with later prices and does not model dividends, suspensions or position constraints.
  • evaluate-strategies --window 5,10,20 measures true T+N: each pick's return at the close of the Nth trading bar after entry, against the market benchmark (CSI 300, S&P 500, Hang Seng, Nikkei 225, KOSPI, TAIEX, Nifty 50) over the same bars. Picks whose window has not elapsed are reported as pending. evaluate and evaluate-batch without a window still measure return to the latest price.
  • Entry is placed in exchange time: a run saved before the session open enters at the previous close; a run saved during or after the session does not count that day's bar toward run-up or drawdown. Exchange holidays are not modeled beyond the bars the data source returns.
  • Yahoo-screener markets are not the whole market: the universe is listings above a market-cap floor (about USD 1B), one query per Yahoo sector, capped at 4000 rows. They depend on a single unofficial endpoint, estimate traded value as price × volume, and use total market cap as float cap. Korean PE/PB come from Naver Finance (another unofficial endpoint); loss-making companies have no PE. PE/PB are only derived from EPS and book value when the trading and reporting currencies match.
  • Daily K-line strategies enrich only the L1 shortlist, not the whole market.
  • strategies/ and alphasift/strategies/ mirror each other (development vs installed package) and must stay in sync.

Disclaimer

This project is for learning, research and engineering experiments. It is not investment advice, a return guarantee or a buy/sell instruction. Market data, LLM output and strategy parameters can be delayed, incomplete or wrong. You are responsible for your own research, compliance, costs and decisions.

Documentation

Usage · Configuration · Strategy guide · Scoring · Design · Positioning · Comparison · Reference · Changelog · SKILL.md

License

Apache License 2.0