tradingview-gex-flashalpha 0.0.0-stage → 1.2.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.
package/embed.js ADDED
@@ -0,0 +1,116 @@
1
+ /*
2
+ * FlashAlpha chart embed: one script tag and a div, no build step.
3
+ *
4
+ * <div data-flashalpha-chart data-symbol="SPX" style="height: 480px"></div>
5
+ * <script async src="https://<chart host>/embed.js" data-key="YOUR_FLASHALPHA_API_KEY"></script>
6
+ *
7
+ * The script loads lightweight-charts (exactly LW_VERSION, served by its own host) and
8
+ * flashalpha-chart-core.js (same host) once, then the optional layer
9
+ * bundle (flashalpha-chart-layers.js, same host) if the host serves one, then mounts every [data-flashalpha-chart]
10
+ * element on the page, reading the chart API on the host it was loaded from. Without the layer bundle the chart works
11
+ * as is with the core layers (levels, maxpain).
12
+ * Attributes (all optional except data-symbol):
13
+ * data-key FlashAlpha API key for this chart, sent as X-Api-Key (default: data-key on the script tag, the
14
+ * page-wide key). Anyone can read it in the page source.
15
+ * data-resolution 1m 5m 15m 1h 1d 1w (default 5m; GEX levels need 1m to 1h)
16
+ * data-range days back, or 1D 5D 1M 6M 1Y (default: per resolution, 5 days on 5m)
17
+ * data-theme dark (default) | light | auto (follows the reader's system setting)
18
+ * data-upgrade-url where the Upgrade button and locked layers link (default flashalpha.com pricing)
19
+ * data-layers comma list, e.g. "levels,maxpain" (default: none, price and volume only; ids from the layer bundle work when it is loaded;
20
+ * the reader's picks are remembered in localStorage and win over it)
21
+ * data-session rth | eth
22
+ * data-controls "false" hides the toolbar
23
+ * data-background CSS colour of the chart background
24
+ * data-refresh seconds between refreshes (default 60, 0 = off)
25
+ * data-metric a per-minute metric column drawn in its own pane (intraday resolutions; needs the layer bundle)
26
+ * data-brand "false" keeps the TradingView logo instead of the FlashAlpha one
27
+ * data-base chart API root, when it is not the host of this script
28
+ * On the <script> tag itself: data-key (the key for every chart on the page), data-layer-bundle="false" skips the layer
29
+ * bundle, data-debug="true" shows load status in the toolbar.
30
+ * The plan of the key decides the layers: layers above it show a lock and an Upgrade link (the API sends the plan).
31
+ * Pages that add charts later (single-page apps) call FlashAlphaEmbed.scan().
32
+ * The core and the bundle are requested with ?v=VERSION, so a new deploy is not hidden by a cached copy: bump VERSION
33
+ * whenever either file changes.
34
+ * lightweight-charts: the host serves dist/vendor/lightweight-charts-<LW_VERSION>.standalone.production.js from this
35
+ * repository's build. To upgrade, change the devDependency, run npm install, set LW_VERSION, and run npm run check
36
+ * (test/lightweight-charts.test.js mounts the chart on the new version and fails until every pin matches).
37
+ */
38
+ (function () {
39
+ 'use strict';
40
+ if (window.FlashAlphaEmbed) { window.FlashAlphaEmbed.scan(); return; }
41
+
42
+ var VERSION = '1.2.0';
43
+ // The tested lightweight-charts, from the chart host (no CDN), like the core. No SRI hash: an integrity check needs a
44
+ // CORS (crossorigin) request, and the host's static files are served without Access-Control-Allow-Origin.
45
+ var LW_VERSION = '5.3.0';
46
+ var RANGES = { '1D': 1, '5D': 5, '1M': 31, '6M': 183, '1Y': 366 };
47
+ var me = document.currentScript;
48
+ var host = me ? me.src.replace(/\/[^\/]*(\?.*)?$/, '') : '';
49
+ var LW_URL = host + '/lightweight-charts-' + LW_VERSION + '.standalone.production.js';
50
+ var withLayers = !(me && me.getAttribute('data-layer-bundle') === 'false');
51
+ var pageKey = me ? me.getAttribute('data-key') : null;
52
+ var debug = !!(me && me.getAttribute('data-debug') === 'true');
53
+
54
+ function script(src, integrity) {
55
+ return new Promise(function (resolve, reject) {
56
+ var s = document.createElement('script');
57
+ s.src = src; s.async = true;
58
+ if (integrity) { s.integrity = integrity; s.crossOrigin = 'anonymous'; }
59
+ s.onload = resolve;
60
+ s.onerror = function () { reject(new Error('could not load ' + src)); };
61
+ document.head.appendChild(s);
62
+ });
63
+ }
64
+
65
+ // The layer bundle registers its layers with FlashAlphaChart.registerLayers, so it loads after the core and before
66
+ // the first mount. A host without it (404) or a blocked request just leaves the core layers.
67
+ // A lightweight-charts the page already has is used only when it is LW_VERSION. Otherwise the pinned copy is loaded and
68
+ // handed to the charts (options.lightweightCharts); the page's own window.LightweightCharts is put back for its charts.
69
+ var lw = null;
70
+ function loadLightweightCharts() {
71
+ var pageLw = window.LightweightCharts;
72
+ var same = pageLw && typeof pageLw.version === 'function' && pageLw.version() === LW_VERSION;
73
+ if (same) { lw = pageLw; return Promise.resolve(); }
74
+ return script(LW_URL).then(function () {
75
+ lw = window.LightweightCharts;
76
+ if (pageLw) window.LightweightCharts = pageLw;
77
+ });
78
+ }
79
+ var ready = loadLightweightCharts()
80
+ .then(function () { return window.FlashAlphaChart ? null : script(host + '/flashalpha-chart-core.js?v=' + VERSION); })
81
+ .then(function () {
82
+ if (!withLayers) return null;
83
+ return script(host + '/flashalpha-chart-layers.js?v=' + VERSION).catch(function () { return null; });
84
+ });
85
+
86
+ function options(el) {
87
+ var d = el.dataset, o = { symbol: (d.symbol || '').toUpperCase() || null, apiKey: d.key || pageKey || null, baseUrl: d.base || host,
88
+ resolution: d.resolution || '5m', symbolButtons: false, debug: debug, lightweightCharts: lw };
89
+ if (d.range) { var days = RANGES[d.range.toUpperCase()] || +d.range; if (days > 0) o.days = days; }
90
+ if (d.theme) o.theme = d.theme;
91
+ if (d.upgradeUrl) o.upgradeUrl = d.upgradeUrl;
92
+ if (d.layers) o.layers = d.layers.split(',').map(function (x) { return x.trim(); }).filter(Boolean);
93
+ if (d.session) o.session = d.session;
94
+ if (d.controls === 'false') o.controls = false;
95
+ if (d.background) o.background = d.background;
96
+ if (d.refresh != null) o.refresh = +d.refresh;
97
+ if (d.metric) o.metric = d.metric;
98
+ if (d.brand !== 'false') o.brand = { logo: host + '/flashalpha-logo.png', href: 'https://flashalpha.com', name: 'FlashAlpha' };
99
+ return o;
100
+ }
101
+
102
+ function scan() {
103
+ return ready.then(function () {
104
+ var els = document.querySelectorAll('[data-flashalpha-chart]');
105
+ for (var i = 0; i < els.length; i++) {
106
+ var el = els[i];
107
+ if (el.__flashalphaChart) continue;
108
+ if (!el.clientHeight) el.style.height = '460px';
109
+ el.__flashalphaChart = window.FlashAlphaChart.mount(el, options(el));
110
+ }
111
+ }).catch(function (e) { if (window.console) console.error('[flashalpha-chart]', e); });
112
+ }
113
+
114
+ window.FlashAlphaEmbed = { scan: scan };
115
+ if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', scan); else scan();
116
+ })();
package/package.json CHANGED
@@ -1,6 +1,99 @@
1
1
  {
2
2
  "name": "tradingview-gex-flashalpha",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.2.0",
4
+ "description": "TradingView-style candlestick chart with options gamma exposure (GEX) levels: call wall, put wall, gamma flip, max pain, plus FlashAlpha indicators such as net GEX, the strike heatmap and the GEX profile. Built on TradingView Lightweight Charts, data from the FlashAlpha API.",
5
+ "keywords": [
6
+ "options",
7
+ "gamma-exposure",
8
+ "gex",
9
+ "dealer-positioning",
10
+ "call-wall",
11
+ "put-wall",
12
+ "gamma-flip",
13
+ "max-pain",
14
+ "candlestick-chart",
15
+ "lightweight-charts",
16
+ "embeddable-chart",
17
+ "stock-chart",
18
+ "trading",
19
+ "gex-chart",
20
+ "options-chart",
21
+ "options-analytics",
22
+ "charting-library",
23
+ "gamma-exposure-chart",
24
+ "dealer-gamma",
25
+ "tradingview",
26
+ "javascript-chart",
27
+ "0dte",
28
+ "tradingview-gex",
29
+ "flashalpha",
30
+ "flashalpha-api",
31
+ "net-gex",
32
+ "gex-heatmap"
33
+ ],
34
+ "homepage": "https://flashalpha-lab.github.io/tradingview-gex-flashalpha/",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/FlashAlpha-lab/tradingview-gex-flashalpha.git"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/FlashAlpha-lab/tradingview-gex-flashalpha/issues"
41
+ },
42
+ "author": "FlashAlpha (https://flashalpha.com)",
43
+ "license": "MIT",
44
+ "type": "module",
45
+ "main": "./dist/tradingview-gex-flashalpha.cjs",
46
+ "module": "./dist/tradingview-gex-flashalpha.mjs",
47
+ "types": "./types/index.d.ts",
48
+ "unpkg": "./dist/tradingview-gex-flashalpha.min.js",
49
+ "jsdelivr": "./dist/tradingview-gex-flashalpha.min.js",
50
+ "exports": {
51
+ ".": {
52
+ "types": "./types/index.d.ts",
53
+ "import": "./dist/tradingview-gex-flashalpha.mjs",
54
+ "require": "./dist/tradingview-gex-flashalpha.cjs"
55
+ },
56
+ "./style.css": "./dist/tradingview-gex-flashalpha.css",
57
+ "./package.json": "./package.json"
58
+ },
59
+ "files": [
60
+ "dist",
61
+ "!dist/vendor",
62
+ "types",
63
+ "embed.js",
64
+ "README.md",
65
+ "CHANGELOG.md",
66
+ "LICENSE"
67
+ ],
68
+ "sideEffects": [
69
+ "*.css",
70
+ "./dist/tradingview-gex-flashalpha.js",
71
+ "./dist/tradingview-gex-flashalpha.min.js"
72
+ ],
73
+ "peerDependencies": {
74
+ "lightweight-charts": "^5.0.0"
75
+ },
76
+ "engines": {
77
+ "node": ">=18"
78
+ },
79
+ "publishConfig": {
80
+ "access": "public",
81
+ "provenance": true
82
+ },
83
+ "scripts": {
84
+ "build": "node scripts/build.mjs",
85
+ "test": "node --test test/*.test.js",
86
+ "lint:source": "node scripts/check-source.mjs",
87
+ "lint:types": "tsc --noEmit --strict --lib es2020,dom --module esnext --moduleResolution bundler types/index.d.ts test/types-usage.ts",
88
+ "check": "npm run lint:source && npm run lint:types && npm run build && npm test && npm pack --dry-run",
89
+ "prepublishOnly": "npm run check"
90
+ },
91
+ "devDependencies": {
92
+ "acorn": "^8.19.0",
93
+ "esbuild": "^0.28.2",
94
+ "jsdom": "^26.1.0",
95
+ "lightningcss": "^1.33.0",
96
+ "lightweight-charts": "5.3.0",
97
+ "typescript": "^5.9.3"
98
+ }
99
+ }