@mathieuc/tradingview 4.0.0-beta.2 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/data/index.d.ts +2 -0
- package/dist/data/index.js +1 -0
- package/dist/http/index.d.ts +2 -0
- package/dist/http/index.js +1 -0
- package/dist/http/screener.d.ts +32 -0
- package/dist/http/screener.js +36 -0
- package/docs/data-api.md +6 -0
- package/docs/screener.md +42 -0
- package/docs/v4-backlog-triage.md +6 -0
- package/package.json +1 -1
package/dist/data/index.d.ts
CHANGED
|
@@ -28,3 +28,5 @@ export type { GraphicsData } from '../chart/graphics.js';
|
|
|
28
28
|
export type { StrategyReport } from '../chart/strategy.js';
|
|
29
29
|
export { summarizeStrategyReport } from '../chart/strategy.js';
|
|
30
30
|
export type { StrategySummary } from '../chart/strategy.js';
|
|
31
|
+
export { getScreener } from '../http/screener.js';
|
|
32
|
+
export type { ScreenerFilter, ScreenerQuery, ScreenerResult, ScreenerRow } from '../http/screener.js';
|
package/dist/data/index.js
CHANGED
|
@@ -14,3 +14,4 @@ export { DEFAULT_TIMEOUT_MS } from './operation.js';
|
|
|
14
14
|
export { getTechnicalAnalysis, searchIndicators, searchMarkets, } from '../http/index.js';
|
|
15
15
|
export { TradingViewError } from '../errors.js';
|
|
16
16
|
export { summarizeStrategyReport } from '../chart/strategy.js';
|
|
17
|
+
export { getScreener } from '../http/screener.js';
|
package/dist/http/index.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export { getChartToken, getDrawings } from './layouts.js';
|
|
|
9
9
|
export type { Drawing, DrawingPoint, GetDrawingsOptions, LayoutOptions, } from './layouts.js';
|
|
10
10
|
export { PinePermissionManager } from './pine-permissions.js';
|
|
11
11
|
export type { AuthorizedUser, AuthorizedUserOrder, PinePermissionOptions } from './pine-permissions.js';
|
|
12
|
+
export { getScreener } from './screener.js';
|
|
13
|
+
export type { ScreenerFilter, ScreenerQuery, ScreenerResult, ScreenerRow } from './screener.js';
|
package/dist/http/index.js
CHANGED
|
@@ -3,3 +3,4 @@ export { getTechnicalAnalysis, searchMarkets } from './market.js';
|
|
|
3
3
|
export { clearIndicatorCache, getIndicator, getPrivateIndicators, parseIndicatorDefinition, searchIndicators, } from './indicators.js';
|
|
4
4
|
export { getChartToken, getDrawings } from './layouts.js';
|
|
5
5
|
export { PinePermissionManager } from './pine-permissions.js';
|
|
6
|
+
export { getScreener } from './screener.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type AuthHttpOptions } from './request.js';
|
|
2
|
+
export interface ScreenerFilter {
|
|
3
|
+
left: string;
|
|
4
|
+
operation: string;
|
|
5
|
+
right?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export interface ScreenerQuery {
|
|
8
|
+
/** Scanner universe, e.g. america, crypto, forex or global. */
|
|
9
|
+
market?: string;
|
|
10
|
+
/** Exact scanner field names, including optional timeframe suffixes. */
|
|
11
|
+
columns: string[];
|
|
12
|
+
filter?: ScreenerFilter[];
|
|
13
|
+
sort?: {
|
|
14
|
+
sortBy: string;
|
|
15
|
+
sortOrder: 'asc' | 'desc';
|
|
16
|
+
};
|
|
17
|
+
/** Zero-based, end-exclusive page range. Defaults to [0, 50]. */
|
|
18
|
+
range?: [number, number];
|
|
19
|
+
/** Optional exchange-qualified symbols. */
|
|
20
|
+
symbols?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface ScreenerRow {
|
|
23
|
+
symbol: string;
|
|
24
|
+
/** Values retain upstream types and nulls; keys match requested columns. */
|
|
25
|
+
values: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export interface ScreenerResult {
|
|
28
|
+
totalCount: number;
|
|
29
|
+
rows: ScreenerRow[];
|
|
30
|
+
}
|
|
31
|
+
/** One scanner page. This does not subscribe to live prices or grant exchange entitlements. */
|
|
32
|
+
export declare function getScreener(query: ScreenerQuery, options?: AuthHttpOptions): Promise<ScreenerResult>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TradingViewError } from '../errors.js';
|
|
2
|
+
import { request } from './request.js';
|
|
3
|
+
/** One scanner page. This does not subscribe to live prices or grant exchange entitlements. */
|
|
4
|
+
export async function getScreener(query, options = {}) {
|
|
5
|
+
const market = query.market ?? 'global';
|
|
6
|
+
const range = query.range ?? [0, 50];
|
|
7
|
+
if (!/^[a-z][a-z0-9_-]*$/i.test(market)
|
|
8
|
+
|| !Array.isArray(query.columns) || !query.columns.length
|
|
9
|
+
|| query.columns.some((column) => typeof column !== 'string' || !column.trim())
|
|
10
|
+
|| new Set(query.columns).size !== query.columns.length
|
|
11
|
+
|| range.length !== 2 || !range.every(Number.isSafeInteger) || range[0] < 0 || range[1] <= range[0]) {
|
|
12
|
+
throw new TradingViewError('INVALID_ARGUMENT', 'Invalid screener market, columns or page range');
|
|
13
|
+
}
|
|
14
|
+
const { data, status } = await request(`https://scanner.tradingview.com/${market}/scan`, {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
credentials: options.credentials,
|
|
17
|
+
headers: { origin: 'https://www.tradingview.com' },
|
|
18
|
+
json: {
|
|
19
|
+
columns: query.columns, range, filter: query.filter ?? [], sort: query.sort,
|
|
20
|
+
symbols: query.symbols === undefined ? undefined : { tickers: query.symbols },
|
|
21
|
+
},
|
|
22
|
+
}, options);
|
|
23
|
+
if (status < 200 || status >= 300 || !data || !Number.isSafeInteger(data.totalCount)
|
|
24
|
+
|| data.totalCount < 0 || !Array.isArray(data.data)
|
|
25
|
+
|| data.data.some((row) => !row || typeof row.s !== 'string'
|
|
26
|
+
|| !Array.isArray(row.d) || row.d.length !== query.columns.length)) {
|
|
27
|
+
throw new TradingViewError('HTTP_ERROR', `Unexpected screener response (HTTP ${status})`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
totalCount: data.totalCount,
|
|
31
|
+
rows: data.data.map((row) => ({
|
|
32
|
+
symbol: row.s,
|
|
33
|
+
values: Object.fromEntries(query.columns.map((column, index) => [column, row.d[index]])),
|
|
34
|
+
})),
|
|
35
|
+
};
|
|
36
|
+
}
|
package/docs/data-api.md
CHANGED
|
@@ -283,3 +283,9 @@ Every failure is a `TradingViewError` with a `code`:
|
|
|
283
283
|
| `CALLBACK_ERROR` | A watcher callback threw; the stream remains active. |
|
|
284
284
|
|
|
285
285
|
`error.details` keeps the raw server payload when there is one.
|
|
286
|
+
|
|
287
|
+
## Screener
|
|
288
|
+
|
|
289
|
+
Use [`getScreener`](screener.md) for a single scanner page with custom columns,
|
|
290
|
+
filters, ranking and explicit pagination. Available from this high-level entry
|
|
291
|
+
point as well as the root package; no chart or quote session is required.
|
package/docs/screener.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Screener
|
|
2
|
+
|
|
3
|
+
`getScreener` is available from both the root package and `@mathieuc/tradingview/data`.
|
|
4
|
+
It performs one HTTP scan, without creating WebSocket sessions.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
import { getScreener } from '@mathieuc/tradingview/data';
|
|
8
|
+
|
|
9
|
+
const page = await getScreener({
|
|
10
|
+
market: 'america',
|
|
11
|
+
columns: ['name', 'close', 'volume', 'Stoch.RSI.D'],
|
|
12
|
+
filter: [{ left: 'type', operation: 'equal', right: 'stock' }],
|
|
13
|
+
sort: { sortBy: 'volume', sortOrder: 'desc' },
|
|
14
|
+
range: [0, 20],
|
|
15
|
+
});
|
|
16
|
+
console.log(page.totalCount, page.rows);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Each row has an exchange-qualified `symbol` and a `values` object keyed by the
|
|
20
|
+
requested columns. Values retain their upstream types, including null. Columns
|
|
21
|
+
must be nonempty and unique. Unknown fields and invalid server filters throw
|
|
22
|
+
`TradingViewError` with code `HTTP_ERROR`; they do not silently become empty results.
|
|
23
|
+
|
|
24
|
+
The default market is `global`. Other upstream universes include `america`,
|
|
25
|
+
`crypto` and `forex`. Exact column names, filter operations and available markets
|
|
26
|
+
are controlled by TradingView, not a stable schema owned by this package.
|
|
27
|
+
Use `symbols: ['NASDAQ:AAPL']` to restrict the scan to explicit tickers.
|
|
28
|
+
|
|
29
|
+
`range` is zero-based and end-exclusive, defaulting to `[0, 50]`. Request subsequent
|
|
30
|
+
pages explicitly. Rankings can change between requests; pages are not a transactionally
|
|
31
|
+
consistent snapshot. There is no automatic unbounded pagination, polling or retry.
|
|
32
|
+
|
|
33
|
+
The second argument accepts `credentials`, `fetch`, `headers` and `signal`.
|
|
34
|
+
Account cookies may be supplied but do not grant paid exchange rights. This is
|
|
35
|
+
**not a real-time screener subscription**: delays and entitlements remain upstream.
|
|
36
|
+
Use `watchQuotes` separately when you need quote updates for selected symbols.
|
|
37
|
+
|
|
38
|
+
## Live evidence
|
|
39
|
+
|
|
40
|
+
On 3 October 2026 an anonymous America scan with stock filters, volume sorting and
|
|
41
|
+
`name`, `close`, `volume`, `Stoch.RSI.D` returned a total count and two typed rows.
|
|
42
|
+
This establishes the request/response contract, not paid real-time availability.
|
|
@@ -138,3 +138,9 @@ No issues/legacy PRs were closed, and no contributor comments were sent by this
|
|
|
138
138
|
- Dependency audit: baseline had two moderate entries for the same Vitest/mocker advisory; patched development dependency in this change.
|
|
139
139
|
- No new authenticated, private-script, Premium or long-duration claims are made.
|
|
140
140
|
- No npm publication or promotion of the `latest` tag is part of this change.
|
|
141
|
+
|
|
142
|
+
## Screener follow-up
|
|
143
|
+
|
|
144
|
+
Beta.3 adds `getScreener` for #53 and scanner fields relevant to #280. See
|
|
145
|
+
[screener documentation](screener.md). #85 real-time exchange entitlement is not
|
|
146
|
+
resolved by a successful HTTP scan. Watchlists and paid/private cases remain open.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mathieuc/tradingview",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.3",
|
|
4
4
|
"description": "TradingView market data for JavaScript and TypeScript: candles, quotes, indicators and strategies, with a simple data API and full low-level access.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|