indicator-scanner
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreate a multi-symbol indicator scanner that screens stocks by technical conditions.
创建一个多标的指标扫描器,用于根据技术条件筛选股票。
Arguments
参数说明
Parse as: scan-type watchlist
$ARGUMENTS- = scan type (e.g., rsi-oversold, rsi-overbought, ema-crossover, supertrend-buy, supertrend-sell, macd-crossover, adx-trending, custom). Default: rsi-oversold
$0 - = watchlist (e.g., nifty50, banknifty, custom). Default: nifty50
$1
If no arguments, ask the user what they want to scan for.
将解析为:扫描类型 观察列表
$ARGUMENTS- = 扫描类型(例如:rsi-oversold、rsi-overbought、ema-crossover、supertrend-buy、supertrend-sell、macd-crossover、adx-trending、custom),默认值:rsi-oversold
$0 - = 观察列表(例如:nifty50、banknifty、custom),默认值:nifty50
$1
如果未提供参数,请询问用户想要扫描的内容。
Instructions
操作步骤
- Read the indicator-expert rules for reference
- Create directory (on-demand)
scanners/{scan_type}/ - Create
{scan_type}_scanner.py - The script must:
- Load from project root
.env - Define the watchlist (predefined or custom)
- Fetch data for each symbol via
client.history() - Compute indicator(s) using
openalgo.ta - Check the scan condition
- Print results as a formatted table
- Save results to CSV
- Optionally get real-time LTP via for current values
client.quotes()
- Load
- 参考指标专家规则
- 按需创建目录
scanners/{scan_type}/ - 创建脚本
{scan_type}_scanner.py - 脚本必须实现以下功能:
- 从项目根目录加载文件
.env - 定义观察列表(预定义或自定义)
- 通过获取每个标的的数据
client.history() - 使用计算指标
openalgo.ta - 检查扫描条件
- 以格式化表格形式打印结果
- 将结果保存为CSV文件
- 可选:通过获取实时最新成交价(LTP)
client.quotes()
- 从项目根目录加载
Scan Logic Pattern
扫描逻辑示例
python
results = []
for symbol in watchlist:
df = fetch_data(symbol, exchange, interval)
close = df["close"]
# Compute indicator
rsi = ta.rsi(close, 14)
current_rsi = rsi.iloc[-1]
# Check condition
if current_rsi < 30: # RSI oversold
results.append({
"symbol": symbol,
"ltp": close.iloc[-1],
"rsi": current_rsi,
"signal": "OVERSOLD",
})python
results = []
for symbol in watchlist:
df = fetch_data(symbol, exchange, interval)
close = df["close"]
# Compute indicator
rsi = ta.rsi(close, 14)
current_rsi = rsi.iloc[-1]
# Check condition
if current_rsi < 30: # RSI oversold
results.append({
"symbol": symbol,
"ltp": close.iloc[-1],
"rsi": current_rsi,
"signal": "OVERSOLD",
})Print table
Print table
df_results = pd.DataFrame(results)
print(df_results.to_string(index=False))
df_results.to_csv(script_dir / f"{scan_type}_results.csv", index=False)
undefineddf_results = pd.DataFrame(results)
print(df_results.to_string(index=False))
df_results.to_csv(script_dir / f"{scan_type}_results.csv", index=False)
undefinedPredefined Scan Types
预定义扫描类型
| Scan Type | Condition | Indicator |
|---|---|---|
| RSI(14) < 30 | RSI |
| RSI(14) > 70 | RSI |
| EMA(10) crossed above EMA(20) in last 3 bars | EMA |
| EMA(10) crossed below EMA(20) in last 3 bars | EMA |
| Supertrend direction changed to -1 (uptrend) | Supertrend |
| Supertrend direction changed to 1 (downtrend) | Supertrend |
| MACD crossed above Signal in last 3 bars | MACD |
| ADX > 25 (strong trend) | ADX |
| Bollinger Width at 20-bar low (volatility squeeze) | Bollinger |
| Volume > 2x 20-day average | Volume |
| Ask user for conditions | Any |
| 扫描类型 | 条件 | 指标 |
|---|---|---|
| RSI(14) < 30 | RSI |
| RSI(14) > 70 | RSI |
| 过去3根K线内EMA(10)上穿EMA(20) | EMA |
| 过去3根K线内EMA(10)下穿EMA(20) | EMA |
| Supertrend方向变为-1(上涨趋势) | Supertrend |
| Supertrend方向变为1(下跌趋势) | Supertrend |
| 过去3根K线内MACD上穿信号线 | MACD |
| ADX > 25(强劲趋势) | ADX |
| 布林带宽度处于20日低位(波动率收缩) | Bollinger |
| 成交量 > 20日平均成交量的2倍 | 成交量 |
| 询问用户自定义条件 | 任意 |
Predefined Watchlists
预定义观察列表
NIFTY 50 (nifty50)
NIFTY 50 (nifty50)
python
NIFTY50 = [
"ADANIENT", "ADANIPORTS", "APOLLOHOSP", "ASIANPAINT", "AXISBANK",
"BAJAJ-AUTO", "BAJFINANCE", "BAJAJFINSV", "BPCL", "BHARTIARTL",
"BRITANNIA", "CIPLA", "COALINDIA", "DIVISLAB", "DRREDDY",
"EICHERMOT", "GRASIM", "HCLTECH", "HDFCBANK", "HDFCLIFE",
"HEROMOTOCO", "HINDALCO", "HINDUNILVR", "ICICIBANK", "INDUSINDBK",
"INFY", "ITC", "JSWSTEEL", "KOTAKBANK", "LT",
"M&M", "MARUTI", "NESTLEIND", "NTPC", "ONGC",
"POWERGRID", "RELIANCE", "SBILIFE", "SBIN", "SUNPHARMA",
"TCS", "TATACONSUM", "TATAMOTORS", "TATASTEEL", "TECHM",
"TITAN", "ULTRACEMCO", "UPL", "WIPRO",
]python
NIFTY50 = [
"ADANIENT", "ADANIPORTS", "APOLLOHOSP", "ASIANPAINT", "AXISBANK",
"BAJAJ-AUTO", "BAJFINANCE", "BAJAJFINSV", "BPCL", "BHARTIARTL",
"BRITANNIA", "CIPLA", "COALINDIA", "DIVISLAB", "DRREDDY",
"EICHERMOT", "GRASIM", "HCLTECH", "HDFCBANK", "HDFCLIFE",
"HEROMOTOCO", "HINDALCO", "HINDUNILVR", "ICICIBANK", "INDUSINDBK",
"INFY", "ITC", "JSWSTEEL", "KOTAKBANK", "LT",
"M&M", "MARUTI", "NESTLEIND", "NTPC", "ONGC",
"POWERGRID", "RELIANCE", "SBILIFE", "SBIN", "SUNPHARMA",
"TCS", "TATACONSUM", "TATAMOTORS", "TATASTEEL", "TECHM",
"TITAN", "ULTRACEMCO", "UPL", "WIPRO",
]Bank NIFTY (banknifty)
Bank NIFTY (banknifty)
python
BANKNIFTY = [
"HDFCBANK", "ICICIBANK", "KOTAKBANK", "AXISBANK", "SBIN",
"INDUSINDBK", "BANKBARODA", "FEDERALBNK", "PNB", "IDFCFIRSTB",
"BANDHANBNK", "AUBANK",
]python
BANKNIFTY = [
"HDFCBANK", "ICICIBANK", "KOTAKBANK", "AXISBANK", "SBIN",
"INDUSINDBK", "BANKBARODA", "FEDERALBNK", "PNB", "IDFCFIRSTB",
"BANDHANBNK", "AUBANK",
]Output Format
输出格式
Symbol LTP RSI(14) Signal
------ --- ------- ------
SBIN 769.60 28.4 OVERSOLD
TATASTEEL 142.30 25.1 OVERSOLD
COALINDIA 385.00 29.7 OVERSOLD
Scan: RSI Oversold (<30) | Watchlist: NIFTY 50 | Date: 2025-02-28
Found 3 / 50 symbols matching condition
Results saved to: scanners/rsi_oversold/rsi_oversold_results.csvSymbol LTP RSI(14) Signal
------ --- ------- ------
SBIN 769.60 28.4 OVERSOLD
TATASTEEL 142.30 25.1 OVERSOLD
COALINDIA 385.00 29.7 OVERSOLD
Scan: RSI Oversold (<30) | Watchlist: NIFTY 50 | Date: 2025-02-28
Found 3 / 50 symbols matching condition
Results saved to: scanners/rsi_oversold/rsi_oversold_results.csvExample Usage
使用示例
/indicator-scanner rsi-oversold nifty50/indicator-scanner ema-crossover banknifty/indicator-scanner supertrend-buy nifty50/indicator-scanner volume-spike nifty50/indicator-scanner custom/indicator-scanner rsi-oversold nifty50/indicator-scanner ema-crossover banknifty/indicator-scanner supertrend-buy nifty50/indicator-scanner volume-spike nifty50/indicator-scanner custom