@mathieuc/tradingview 4.0.0-beta.3 → 4.0.0-beta.4
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/watchlists.d.ts +22 -0
- package/dist/http/watchlists.js +42 -0
- package/docs/data-api.md +5 -0
- package/docs/v4-backlog-triage.md +6 -0
- package/docs/watchlists.md +56 -0
- package/package.json +1 -1
package/dist/data/index.d.ts
CHANGED
|
@@ -30,3 +30,5 @@ export { summarizeStrategyReport } from '../chart/strategy.js';
|
|
|
30
30
|
export type { StrategySummary } from '../chart/strategy.js';
|
|
31
31
|
export { getScreener } from '../http/screener.js';
|
|
32
32
|
export type { ScreenerFilter, ScreenerQuery, ScreenerResult, ScreenerRow } from '../http/screener.js';
|
|
33
|
+
export { getWatchlists, getHotlist } from '../http/watchlists.js';
|
|
34
|
+
export type { Watchlist, WatchlistOptions, HotlistKind, HotlistQuery } from '../http/watchlists.js';
|
package/dist/data/index.js
CHANGED
|
@@ -15,3 +15,4 @@ export { getTechnicalAnalysis, searchIndicators, searchMarkets, } from '../http/
|
|
|
15
15
|
export { TradingViewError } from '../errors.js';
|
|
16
16
|
export { summarizeStrategyReport } from '../chart/strategy.js';
|
|
17
17
|
export { getScreener } from '../http/screener.js';
|
|
18
|
+
export { getWatchlists, getHotlist } from '../http/watchlists.js';
|
package/dist/http/index.d.ts
CHANGED
|
@@ -11,3 +11,5 @@ export { PinePermissionManager } from './pine-permissions.js';
|
|
|
11
11
|
export type { AuthorizedUser, AuthorizedUserOrder, PinePermissionOptions } from './pine-permissions.js';
|
|
12
12
|
export { getScreener } from './screener.js';
|
|
13
13
|
export type { ScreenerFilter, ScreenerQuery, ScreenerResult, ScreenerRow } from './screener.js';
|
|
14
|
+
export { getWatchlists, getHotlist } from './watchlists.js';
|
|
15
|
+
export type { Watchlist, WatchlistOptions, HotlistKind, HotlistQuery } from './watchlists.js';
|
package/dist/http/index.js
CHANGED
|
@@ -4,3 +4,4 @@ export { clearIndicatorCache, getIndicator, getPrivateIndicators, parseIndicator
|
|
|
4
4
|
export { getChartToken, getDrawings } from './layouts.js';
|
|
5
5
|
export { PinePermissionManager } from './pine-permissions.js';
|
|
6
6
|
export { getScreener } from './screener.js';
|
|
7
|
+
export { getWatchlists, getHotlist } from './watchlists.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Credentials, type HttpOptions } from './request.js';
|
|
2
|
+
import { type ScreenerQuery, type ScreenerResult } from './screener.js';
|
|
3
|
+
export interface Watchlist {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
/** Ordered upstream entries, including any section markers. */
|
|
7
|
+
symbols: string[];
|
|
8
|
+
/** Additional upstream metadata, preserved without coercion. */
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface WatchlistOptions extends HttpOptions {
|
|
12
|
+
credentials: Credentials;
|
|
13
|
+
}
|
|
14
|
+
/** Reads all watchlists belonging to the authenticated account. Never modifies them. */
|
|
15
|
+
export declare function getWatchlists(options: WatchlistOptions): Promise<Watchlist[]>;
|
|
16
|
+
export type HotlistKind = 'gainers' | 'losers' | 'mostActive' | 'volumeGainers';
|
|
17
|
+
export interface HotlistQuery extends Omit<ScreenerQuery, 'columns' | 'sort'> {
|
|
18
|
+
kind: HotlistKind;
|
|
19
|
+
columns?: string[];
|
|
20
|
+
}
|
|
21
|
+
/** Scanner-ranked lists, not a promise of parity with the TradingView UI hotlist widget. */
|
|
22
|
+
export declare function getHotlist(query: HotlistQuery, options?: HttpOptions): Promise<ScreenerResult>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TradingViewError } from '../errors.js';
|
|
2
|
+
import { request } from './request.js';
|
|
3
|
+
import { getScreener } from './screener.js';
|
|
4
|
+
/** Reads all watchlists belonging to the authenticated account. Never modifies them. */
|
|
5
|
+
export async function getWatchlists(options) {
|
|
6
|
+
if (!options?.credentials?.session) {
|
|
7
|
+
throw new TradingViewError('INVALID_ARGUMENT', 'getWatchlists requires account credentials');
|
|
8
|
+
}
|
|
9
|
+
const { data, status } = await request('https://www.tradingview.com/api/v1/symbols_list/all/', {
|
|
10
|
+
credentials: options.credentials,
|
|
11
|
+
headers: { origin: 'https://www.tradingview.com' },
|
|
12
|
+
redirect: 'manual',
|
|
13
|
+
}, options);
|
|
14
|
+
if (status === 401 || status === 403 || (status >= 300 && status < 400)) {
|
|
15
|
+
throw new TradingViewError('AUTH_ERROR', `Watchlist access rejected (HTTP ${status})`);
|
|
16
|
+
}
|
|
17
|
+
if (status < 200 || status >= 300 || !Array.isArray(data)
|
|
18
|
+
|| data.some((list) => !list || !Number.isSafeInteger(list.id) || typeof list.name !== 'string'
|
|
19
|
+
|| !Array.isArray(list.symbols) || list.symbols.some((symbol) => typeof symbol !== 'string'))) {
|
|
20
|
+
throw new TradingViewError('HTTP_ERROR', `Unexpected watchlist response (HTTP ${status})`);
|
|
21
|
+
}
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
/** Scanner-ranked lists, not a promise of parity with the TradingView UI hotlist widget. */
|
|
25
|
+
export async function getHotlist(query, options = {}) {
|
|
26
|
+
const rankings = {
|
|
27
|
+
gainers: { sortBy: 'change', sortOrder: 'desc' },
|
|
28
|
+
losers: { sortBy: 'change', sortOrder: 'asc' },
|
|
29
|
+
mostActive: { sortBy: 'volume', sortOrder: 'desc' },
|
|
30
|
+
volumeGainers: { sortBy: 'relative_volume_10d_calc', sortOrder: 'desc' },
|
|
31
|
+
};
|
|
32
|
+
if (!Object.hasOwn(rankings, query.kind)) {
|
|
33
|
+
throw new TradingViewError('INVALID_ARGUMENT', 'Unknown hotlist kind');
|
|
34
|
+
}
|
|
35
|
+
return getScreener({
|
|
36
|
+
...query,
|
|
37
|
+
market: query.market ?? 'america',
|
|
38
|
+
columns: query.columns ?? ['name', 'close', 'change', 'volume', 'relative_volume_10d_calc'],
|
|
39
|
+
filter: query.filter ?? [{ left: 'type', operation: 'equal', right: 'stock' }],
|
|
40
|
+
sort: rankings[query.kind],
|
|
41
|
+
}, options);
|
|
42
|
+
}
|
package/docs/data-api.md
CHANGED
|
@@ -289,3 +289,8 @@ Every failure is a `TradingViewError` with a `code`:
|
|
|
289
289
|
Use [`getScreener`](screener.md) for a single scanner page with custom columns,
|
|
290
290
|
filters, ranking and explicit pagination. Available from this high-level entry
|
|
291
291
|
point as well as the root package; no chart or quote session is required.
|
|
292
|
+
|
|
293
|
+
## Watchlists and rankings
|
|
294
|
+
|
|
295
|
+
[`getWatchlists` and `getHotlist`](watchlists.md) provide read-only account lists
|
|
296
|
+
and scanner-based gainers, losers and volume rankings. Available from both entry points.
|
|
@@ -144,3 +144,9 @@ No issues/legacy PRs were closed, and no contributor comments were sent by this
|
|
|
144
144
|
Beta.3 adds `getScreener` for #53 and scanner fields relevant to #280. See
|
|
145
145
|
[screener documentation](screener.md). #85 real-time exchange entitlement is not
|
|
146
146
|
resolved by a successful HTTP scan. Watchlists and paid/private cases remain open.
|
|
147
|
+
|
|
148
|
+
## Watchlist follow-up
|
|
149
|
+
|
|
150
|
+
Beta.4 adds read-only `getWatchlists` and scanner-ranked `getHotlist` (#87).
|
|
151
|
+
Authenticated discovery returned two empty lists; populated entries are fixture-tested.
|
|
152
|
+
Exact TradingView UI hotlist parity is not claimed. See [watchlists](watchlists.md).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Watchlists and ranked lists
|
|
2
|
+
|
|
3
|
+
## Read your watchlists
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { getWatchlists } from '@mathieuc/tradingview/data';
|
|
7
|
+
|
|
8
|
+
const lists = await getWatchlists({
|
|
9
|
+
credentials: {
|
|
10
|
+
session: process.env.TV_SESSION,
|
|
11
|
+
signature: process.env.TV_SIGNATURE,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
for (const list of lists) console.log(list.id, list.name, list.symbols);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This is a read-only account API. Each list preserves its numeric ID, name, ordered
|
|
18
|
+
`symbols` and additional upstream metadata. Entries can include section markers;
|
|
19
|
+
do not blindly pass every entry to `getQuotes`. Filter for exchange-qualified
|
|
20
|
+
symbols appropriate to your application. No lists are created, edited or deleted.
|
|
21
|
+
|
|
22
|
+
Credentials are required. Access rejection (401/403 or login redirects) produces
|
|
23
|
+
`AUTH_ERROR`; malformed responses and other failed statuses produce `HTTP_ERROR`.
|
|
24
|
+
Authenticated redirects are not followed. The options also accept `fetch`,
|
|
25
|
+
`headers` and `signal`. Treat returned names/symbols as private account data.
|
|
26
|
+
|
|
27
|
+
## Scanner-ranked lists
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { getHotlist } from '@mathieuc/tradingview/data';
|
|
31
|
+
|
|
32
|
+
const page = await getHotlist({ kind: 'gainers', range: [0, 10] });
|
|
33
|
+
console.log(page.rows);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Kind | Ranking |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `gainers` | Percentage change descending |
|
|
39
|
+
| `losers` | Percentage change ascending |
|
|
40
|
+
| `mostActive` | Volume descending |
|
|
41
|
+
| `volumeGainers` | Relative volume (`relative_volume_10d_calc`) descending |
|
|
42
|
+
|
|
43
|
+
These are convenient [screener](screener.md) queries, **not an exact replica of the
|
|
44
|
+
TradingView hotlist widget**. UI universe, session and liquidity filters may differ.
|
|
45
|
+
Default universe: America stocks; default fields: name, close, change, volume and
|
|
46
|
+
relative volume. Override `market`, `columns`, `filter`, `range` or `symbols` as
|
|
47
|
+
needed. For a non-stock universe, supply appropriate filters (or `filter: []`),
|
|
48
|
+
since changing the market does not remove the default stock filter. Exchange data
|
|
49
|
+
may be delayed. No automatic polling or paid entitlement is implied.
|
|
50
|
+
|
|
51
|
+
## Evidence and limits
|
|
52
|
+
|
|
53
|
+
On 3 October 2026, the account endpoint returned two watchlists successfully.
|
|
54
|
+
Both were empty, so nonempty ordered entries and section preservation are covered
|
|
55
|
+
by deterministic fixtures, not claimed as live-tested account content. An anonymous
|
|
56
|
+
America relative-volume scan returned populated rows. No account data was modified.
|
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.4",
|
|
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",
|