tradingview-screener-ts
Version:
TypeScript port of TradingView Screener with 100% Python parity - Based on the original Python library by shner-elmo (https://github.com/shner-elmo/TradingView-Screener)
310 lines (222 loc) ⢠10.7 kB
Markdown
<div align="center">
[](https://www.npmjs.com/package/tradingview-screener-ts)
[](https://www.npmjs.com/package/tradingview-screener-ts)
[](https://www.npmjs.com/package/tradingview-screener-ts)
[](https://www.typescriptlang.org/)
[](https://opensource.org/licenses/MIT)
**A complete TypeScript port of the popular Python TradingView Screener library**
_100% feature parity ⢠Enhanced type safety ⢠Modern JavaScript features_
[š Documentation](
</div>
---
This TypeScript library is a complete port of the original **[TradingView-Screener](https://github.com/shner-elmo/TradingView-Screener)** Python library created by **[shner-elmo](https://github.com/shner-elmo)**.
All credit for the original concept, API design, and implementation goes to the original author. This TypeScript version maintains 100% feature parity while adding type safety and modern JavaScript features.
**Original Python Library:** https://github.com/shner-elmo/TradingView-Screener
---
šÆ **100% Python Parity** - Every feature from the original Python library
š **Full Type Safety** - Complete TypeScript definitions with IntelliSense
š **Global Markets** - 67+ countries including dedicated India market support
š **3000+ Fields** - Complete access to all TradingView data fields
ā” **Modern Async** - Promise-based API with async/await patterns
š®š³ **India Market** - Dedicated support with INR currency formatting
š **Technical Analysis** - 100+ technical indicators and screening tools
š§ **Developer Experience** - Enhanced debugging and error handling
---
```bash
npm install tradingview-screener-ts
```
```typescript
import { Query, col } from 'tradingview-screener-ts';
// Screen large-cap stocks with high volume
const result = await new Query()
.select('name', 'close', 'volume', 'market_cap_basic')
.where(
col('market_cap_basic').gt(1_000_000_000), // Market cap > $1B
col('volume').gt(1_000_000) // Volume > 1M
)
.orderBy('volume', false)
.limit(50)
.getScannerData();
console.log(`Found ${result.totalCount} stocks`);
result.data.forEach(stock => {
console.log(`${stock.name}: $${stock.close} (Vol: ${stock.volume})`);
});
```
```typescript
// Screen Indian large-cap stocks
const indiaStocks = await new Query()
.setMarkets('india')
.select('name', 'close', 'volume', 'market_cap_basic', 'P/E')
.where(
col('market_cap_basic').gt(10_000_000_000), // Market cap > ā¹10B
col('P/E').between(8, 35), // P/E ratio 8-35
col('volume').gt(100_000) // Volume > 100K
)
.orderBy('market_cap_basic', false)
.getScannerData();
console.log(`Found ${indiaStocks.totalCount} Indian stocks`);
```
---
- šŗšø **United States** (`america`) - NYSE, NASDAQ, AMEX
- š®š³ **India** (`india`) - NSE, BSE with INR currency support
- š¬š§ **United Kingdom** (`uk`) - LSE
- š©šŖ **Germany** (`germany`) - XETRA, Frankfurt
- šÆšµ **Japan** (`japan`) - TSE, Nikkei
- š° **Cryptocurrency** (`crypto`) - Bitcoin, Ethereum, Altcoins
- š± **Forex** (`forex`) - Currency pairs
- š **Futures** (`futures`) - Commodity and financial futures
- š **Options** (`options`) - Options contracts
- š¦ **Bonds** (`bonds`) - Government and corporate bonds
- [š®š³ **India Stocks Screener**](https://shner-elmo.github.io/TradingView-Screener/screeners/stocks/india.html) - Complete India market screening
- [šŗšø **US Stocks Screener**](https://shner-elmo.github.io/TradingView-Screener/screeners/stocks/america.html) - US market screening
- [š **Global Stocks Screener**](https://shner-elmo.github.io/TradingView-Screener/screeners/stocks/global.html) - Multi-market screening
---
- [**š Stocks Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/stocks.html) - OHLC, volume, fundamentals, technical indicators
- [**āæ Crypto Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/crypto.html) - Cryptocurrency-specific metrics
- [**š± Forex Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/forex.html) - Currency pair data
- [**š Futures Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/futures.html) - Futures contract data
- [**š Options Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/options.html) - Options Greeks and metrics
- [**š¦ Bonds Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/bonds.html) - Bond yield and duration data
- [**š Economics Fields**](https://shner-elmo.github.io/TradingView-Screener/fields/economics2.html) - Economic indicators
```typescript
// Price & Volume
('close', 'open', 'high', 'low', 'volume');
// Market Data
('market_cap_basic', 'shares_outstanding', 'float_shares_outstanding');
// Valuation Ratios
('P/E', 'P/B', 'P/S', 'EV/EBITDA', 'price_earnings_ttm');
// Technical Indicators
('RSI', 'MACD.macd', 'MACD.signal', 'EMA20', 'SMA50', 'SMA200');
// Financial Metrics
('debt_to_equity', 'return_on_equity', 'return_on_assets', 'gross_margin');
```
---
```typescript
import { Query, col, And, Or } from 'tradingview-screener-ts';
const technicalScreen = await new Query()
.select('name', 'close', 'RSI', 'MACD.macd', 'MACD.signal', 'volume')
.where(
And(
col('RSI').between(30, 70), // Not oversold/overbought
col('MACD.macd').gt(col('MACD.signal')), // MACD bullish crossover
col('close').gt(col('EMA20')), // Above 20-day EMA
Or(
col('volume').gt(col('volume').sma(20)), // Above average volume
col('relative_volume_10d_calc').gt(1.5) // High relative volume
)
)
)
.orderBy('volume', false)
.getScannerData();
```
```typescript
// Screen across multiple markets
const globalScreen = await new Query()
.setMarkets('america', 'india', 'uk', 'germany', 'japan')
.select('name', 'close', 'market_cap_basic', 'country', 'sector')
.where(
col('market_cap_basic').gt(5_000_000_000), // $5B+ market cap
col('P/E').between(5, 25), // Reasonable P/E
col('debt_to_equity').lt(1) // Low debt
)
.orderBy('market_cap_basic', false)
.getScannerData();
```
```typescript
// Screen cryptocurrencies
const cryptoScreen = await new Query()
.setMarkets(['crypto'])
.select('name', 'close', 'volume', 'market_cap_calc', 'change')
.where(
col('market_cap_calc').gt(1_000_000_000), // $1B+ market cap
col('volume').gt(10_000_000), // $10M+ daily volume
col('change').between(-20, 20) // ±20% daily change
)
.orderBy('volume', false)
.getScannerData();
```
---
- **`Query`** - Main screener query builder
- **`Column`** - Column operations and filtering
- **`col()`** - Shorthand for creating Column instances
- `select()` - Choose columns to retrieve
- `where()` - Add filters (AND logic)
- `where2()` - Advanced filtering (AND/OR logic)
- `orderBy()` - Sort results
- `limit()` - Limit number of results
- `setMarkets()` - Choose markets/exchanges
- `getScannerData()` - Execute query and get results
### Column Operations
- **Comparison**: `gt()`, `gte()`, `lt()`, `lte()`, `eq()`, `ne()`
- **Range**: `between()`, `notBetween()`, `isin()`, `notIn()`
- **Technical**: `crosses()`, `crossesAbove()`, `crossesBelow()`
- **Percentage**: `abovePct()`, `belowPct()`, `betweenPct()`
- **String**: `like()`, `notLike()`, `empty()`, `notEmpty()`
---
## š Documentation
- [**Installation Guide**](INSTALLATION-GUIDE.md) - Complete installation instructions
- [**API Reference**](API-REFERENCE.md) - Detailed API documentation
- [**Field References**](FIELD-REFERENCES.md) - Complete field documentation
- [**Migration Guide**](MIGRATION.md) - Python to TypeScript migration
- [**Examples**](examples/) - Practical usage examples
---
## š Migration from Python
### Python vs TypeScript
| Python | TypeScript | Notes |
| ------------------------------------ | ------------------------------------------------------ | ---------------------- |
| `Column('field') > 100` | `col('field').gt(100)` | Method-based operators |
| `query.get_scanner_data()` | `query.getScannerData()` | camelCase naming |
| `from tradingview_screener import *` | `import { Query, col } from 'tradingview-screener-ts'` | ES6 imports |
**Python:**
```python
from tradingview_screener import Query, Column
result = (Query()
.select('name', 'close', 'volume')
.where(Column('close') > 100)
.get_scanner_data())
```
**TypeScript:**
```typescript
import { Query, col } from 'tradingview-screener-ts';
const result = await new Query()
.select('name', 'close', 'volume')
.where(col('close').gt(100))
.getScannerData();
```
---
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
- Original Python library by [shner-elmo](https://github.com/shner-elmo/TradingView-Screener)
- TradingView for providing the excellent screening API
- TypeScript community for the amazing tooling
---
<div align="center">
**Made with ā¤ļø for the TypeScript community**
[ā Star on GitHub](https://github.com/Anny26022/TradingView-Screener-ts) ⢠[š¦ NPM Package](https://www.npmjs.com/package/tradingview-screener-ts) ⢠[š Report Issues](https://github.com/Anny26022/TradingView-Screener-ts/issues)
</div>