@mathieuc/tradingview 4.0.0-beta.4 → 4.0.0-rc.0

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.
Files changed (40) hide show
  1. package/README.md +3 -1
  2. package/assets/readme-demo.gif +0 -0
  3. package/dist/client/client.js +8 -2
  4. package/dist/http/account.js +5 -2
  5. package/dist/http/request.js +2 -1
  6. package/docs/README.es.md +1 -1
  7. package/docs/README.fr.md +1 -1
  8. package/docs/README.pt.md +1 -1
  9. package/docs/v4-backlog-triage.md +24 -12
  10. package/docs/v4-coverage.md +22 -3
  11. package/docs/v4-reliability.md +58 -0
  12. package/docs/v4-stabilization.md +87 -0
  13. package/examples/README.md +37 -0
  14. package/examples/builtin-indicator.js +22 -0
  15. package/examples/candles.js +15 -0
  16. package/examples/custom-chart-types.js +17 -0
  17. package/examples/custom-timeframe.js +14 -0
  18. package/examples/drawings.js +16 -0
  19. package/examples/errors.js +44 -0
  20. package/examples/fake-replay.js +24 -0
  21. package/examples/from-to.js +25 -0
  22. package/examples/graphic-indicator.js +18 -0
  23. package/examples/indicator-data.js +23 -0
  24. package/examples/multiple-indicators.js +16 -0
  25. package/examples/pine-permissions.js +18 -0
  26. package/examples/private-indicators.js +27 -0
  27. package/examples/quote-session.js +17 -0
  28. package/examples/quotes.js +15 -0
  29. package/examples/replay.js +36 -0
  30. package/examples/screener.js +10 -0
  31. package/examples/search.js +11 -0
  32. package/examples/simple-chart.js +36 -0
  33. package/examples/strategy-report.js +30 -0
  34. package/examples/user-login.js +15 -0
  35. package/examples/watch-candles.js +16 -0
  36. package/llms.txt +26 -0
  37. package/package.json +12 -3
  38. package/scripts/endurance.mjs +93 -0
  39. package/scripts/parity.mjs +54 -0
  40. package/scripts/probe-account.mjs +55 -0
@@ -0,0 +1,55 @@
1
+ /** Opt-in read-only diagnostics. Never print account tokens, script IDs or names. */
2
+ import { Buffer } from 'node:buffer';
3
+ import { getUser, getPrivateIndicators, getIndicatorData } from '../dist/index.js';
4
+
5
+ const positiveArgument = (name, fallback) => {
6
+ const raw = process.argv.find((value) => value.startsWith(`--${name}=`))?.slice(name.length + 3);
7
+ const value = raw === undefined ? fallback : Number(raw);
8
+ if (!Number.isSafeInteger(value) || value < 1) throw new Error('Invalid probe argument');
9
+ return value;
10
+ };
11
+
12
+ async function main() {
13
+ const maxScripts = positiveArgument('max-scripts', 10);
14
+ const timeoutMs = positiveArgument('timeout-ms', 30_000);
15
+ if (!process.env.SESSION) throw new Error('SESSION is required');
16
+ const credentials = { session: process.env.SESSION, signature: process.env.SIGNATURE };
17
+ const options = { signal: AbortSignal.timeout(timeoutMs) };
18
+ const user = await getUser(credentials, options);
19
+ let planClaim = null;
20
+ try {
21
+ const claims = JSON.parse(Buffer.from(user.authToken.split('.')[1], 'base64url').toString());
22
+ if (typeof claims.plan === 'string') planClaim = claims.plan;
23
+ } catch { /* The account token is not guaranteed to remain a JWT. */ }
24
+ console.log(JSON.stringify({ event: 'account', authenticated: true, planClaim }));
25
+ const scripts = await getPrivateIndicators(credentials, { signal: AbortSignal.timeout(timeoutMs) });
26
+ let failures = 0;
27
+ const selected = scripts.slice(0, maxScripts);
28
+ console.log(JSON.stringify({ event: 'selection', available: scripts.length, selected: selected.length }));
29
+ for (const [index, script] of selected.entries()) {
30
+ const classification = script.id.startsWith('USER;') ? 'user' : script.id.startsWith('PUB;') ? 'published' : 'other';
31
+ try {
32
+ const result = await getIndicatorData({
33
+ symbol: 'BINANCE:BTCUSDT', timeframe: '1D', count: 100,
34
+ indicator: script.id, credentials, timeoutMs, signal: AbortSignal.timeout(timeoutMs),
35
+ });
36
+ console.log(JSON.stringify({
37
+ event: 'script', index, classification, ok: true,
38
+ candles: result.candles.length, values: result.values.length,
39
+ trades: result.strategyReport.trades?.length ?? 0,
40
+ reportPresent: Object.keys(result.strategyReport.performance ?? {}).length > 0,
41
+ }));
42
+ } catch (error) {
43
+ failures += 1;
44
+ console.log(JSON.stringify({ event: 'script', index, classification, ok: false, code: error?.code ?? 'ERROR' }));
45
+ }
46
+ }
47
+ console.log(JSON.stringify({ event: 'summary', checked: selected.length, failures, remaining: scripts.length - selected.length }));
48
+ if (failures || selected.length === 0) process.exitCode = 1;
49
+ }
50
+
51
+ main().catch((error) => {
52
+ // Do not log message/details: upstream failures may carry private script payloads.
53
+ console.error(JSON.stringify({ event: 'failure', code: error?.code ?? 'CONFIG_OR_NETWORK_ERROR' }));
54
+ process.exitCode = 1;
55
+ });