@iccandle/news 0.0.1 → 0.0.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/README.md CHANGED
@@ -35,7 +35,7 @@ function App() {
35
35
  widgetKey={widgetKey}
36
36
  defaultSymbol="XAU_USD"
37
37
  chartInterval="15"
38
- theme="system"
38
+ theme="dark"
39
39
  >
40
40
  {/* Your chart container + TradingView bootstrap; call setChartWidget when ready */}
41
41
  <div id="tv_chart_container" style={{ height: "100%" }} />
@@ -131,13 +131,13 @@ const widgetKey = "your-iccandle-api-key";
131
131
  widgetKey={widgetKey}
132
132
  defaultSymbol="XAU_USD"
133
133
  chartInterval="15"
134
- theme="system"
134
+ theme="dark"
135
135
  >
136
136
  <div ref={containerRef} style={{ height: "100%", minHeight: 400 }} />
137
137
  </NewsWidget>;
138
138
  ```
139
139
 
140
- When a news event is selected, the widget switches to a 50/50 split layout: the event analysis panel on the left and the chart (with pip-range overlays) on the right. On mobile (<1024px) the panels stack vertically.
140
+ When a news event is selected, the widget switches to a 50/50 split layout: the event detail card and TradingView chart (with pip-range overlays) on the left, and the ICCandle iframe on the right. On mobile (<1024px) the panels stack vertically.
141
141
 
142
142
  ### Step 5 — Interact with news events
143
143
 
@@ -152,8 +152,7 @@ Once the widget is mounted:
152
152
 
153
153
  ### Theme and remote branding
154
154
 
155
- - **`theme="light"` / `"dark"`** — forces that palette for the widget chrome and chart overlays.
156
- - **`theme="system"`** (recommended when you don't control parent theme) — follows `prefers-color-scheme` for light/dark resolution.
155
+ - **`theme="light"` / `"dark"` / `"system"`** — forces that palette for the widget chrome and chart overlays. `"system"` resolves automatically based on the user's OS `prefers-color-scheme` setting.
157
156
  - On mount, the widget fetches your org's tokens from ICCandle (see [Widget key and remote theming](#widget-key-and-remote-theming)) and sets CSS custom properties on the widget root, e.g. `--iccandle-primary`, `--iccandle-border`, so the event panel and chart overlays match your configured light/dark branding.
158
157
 
159
158
  ### Full working example
@@ -214,7 +213,7 @@ export function ChartWithNewsWidget() {
214
213
  widgetKey={WIDGET_KEY}
215
214
  defaultSymbol="XAU_USD"
216
215
  chartInterval="15"
217
- theme="system"
216
+ theme="dark"
218
217
  >
219
218
  <div ref={containerRef} style={{ height: "100%", width: "100%" }} />
220
219
  </NewsWidget>
@@ -231,8 +230,7 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
231
230
  | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
232
231
  | **Full-page chart** | Set the parent container to `height: 100vh` and let `NewsWidget` fill the space with `autosize: true`. |
233
232
  | **Dashboard embed** | Give the parent a fixed height (e.g. 600px) and `NewsWidget` handles the split layout internally. |
234
- | **News / events on the time axis** | If your datafeed implements `getTimescaleMarks`, you can sync marks with `localStorage` — see [Optional: timescale marks (news/events)](#optional-timescale-marks-newsevents). |
235
- | **Custom symbol list** | Pass any supported symbol as `defaultSymbol`; the widget supports 100+ forex, metals, indices, crypto, and commodity symbols. |
233
+ | **News / events on the time axis** | If your datafeed implements `getTimescaleMarks`, you can sync marks with `localStorage` — see [Optional: timescale marks (news/events)](#optional-timescale-marks-newsevents). | |
236
234
 
237
235
  ### Troubleshooting
238
236
 
@@ -242,7 +240,7 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
242
240
  | `chartWidget` is always `null` | Ensure you call `setChartWidget` after the widget is created (or inside `onChartReady` if your integration requires it). |
243
241
  | Event panel or theme looks wrong | Confirm `widgetKey` is valid; theme fetch uses `api-key: <widgetKey>`. Network or auth failures may leave defaults. |
244
242
  | CORS / network errors on APIs | In local dev, browser calls to ICCandle APIs may be blocked by CORS unless you proxy; the widget should still function with fallback styling—verify in production or behind your proxy. |
245
- | No events showing on chart | The widget falls back to `XAU_USD` if `defaultSymbol` is unrecognized, but ensure `chartInterval` is one of the accepted values (`"1"`, `"5"`, `"15"`, `"30"`, `"60"`). |
243
+ | No events showing on chart | The widget falls back to the `defaultSymbol` if selected symbol is unrecognized, but ensure `chartInterval` is one of the accepted values (`"1"`, `"5"`, `"15"`, `"30"`, `"60"`). |
246
244
 
247
245
  ## API
248
246
 
@@ -250,8 +248,10 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
250
248
 
251
249
  | Name | Kind | Description |
252
250
  | ----------------- | --------- | ------------------------------------------------- |
253
- | `NewsWidget` | Component | Economic calendar analysis overlay for your chart |
254
- | `NewsWidgetProps` | Type | Props for `NewsWidget` |
251
+ | `NewsWidget` | Component | Economic calendar analysis overlay for your chart |
252
+ | `NewsWidgetProps` | Type | Props for `NewsWidget` |
253
+ | `SymbolMapper` | Type | Mapping from ICCandle tickers to your broker's symbol names |
254
+ | `ICCANDLE_TICKERS` | Type | Union of all ICCandle ticker strings (keys of `SymbolMapper`) |
255
255
 
256
256
  ### `NewsWidget` props
257
257
 
@@ -260,9 +260,10 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
260
260
  | `chartWidget` | `IChartingLibraryWidget \| null` | Yes | Live TradingView widget instance (`null` until ready). |
261
261
  | `children` | `ReactNode` | Yes | Your chart UI (e.g. container + library bootstrap). |
262
262
  | `widgetKey` | `string` | Yes | ICCandle API key. Used for theme fetch, chart data, news events, and scanner validation. |
263
- | `defaultSymbol` | `string` | Yes | Default trading symbol (e.g. `"XAU_USD"`, `"EURUSD"`, `"BTCUSDT"`). Falls back to `"XAU_USD"` if the symbol is unrecognized or unavailable. |
264
- | `chartInterval` | `"1" \| "5" \| "15" \| "30" \| "60"` | Yes | Chart candle interval in minutes. Defaults to `"15"`. |
265
- | `theme` | `"light" \| "dark" \| "system"` | No | Defaults to sensible behavior; `"system"` follows `prefers-color-scheme`. Affects resolved theme tokens and chart overlays. |
263
+ | `defaultSymbol` | `string` | Yes | Default trading symbol used to initialize the chart (e.g. `"XAU_USD"`, `"EURUSD"`, `"BTCUSDT"`). Also used as the fallback when a symbol is unrecognized, unmapped, or unavailable. |
264
+ | `symbolMapper` | `SymbolMapper` | No | Maps ICCandle ticker names to your TradingView symbol names (e.g. `{ XAUUSD: "GOLD", USDCAD: "USD_CAD" }`). When omitted or when a ticker has no entry, the widget falls back to `defaultSymbol`. See [Symbol name mapping](#symbol-name-mapping-symbolmapper). |
265
+ | `chartInterval` | `"1" \| "5" \| "15" \| "30" \| "60"` | Yes | Initial chart candle interval in minutes used when showing the chart. Defaults to `"15"`. |
266
+ | `theme` | `"light" \| "dark" \| "system"` | No | Affects resolved theme tokens and chart overlays. `"system"` resolves to light or dark based on `prefers-color-scheme`. |
266
267
 
267
268
  ### Widget key and remote theming
268
269
 
@@ -273,7 +274,7 @@ On mount, the component loads branding colors from ICCandle:
273
274
 
274
275
  CSS custom properties (`--iccandle-primary`, `--iccandle-border`, `--iccandle-background`, `--iccandle-text`, etc.) are applied on the widget root so the event panel and chart overlays match your configured light/dark tokens.
275
276
 
276
- **Theme prop vs. API tokens:** The `theme` prop (`"light"` | `"dark"` | `"system"`) chooses which variant of those tokens to apply. `"system"` tracks `prefers-color-scheme` so the widget stays aligned with the user's OS preference when you don't pass an explicit light/dark mode from your app shell.
277
+ **Theme prop vs. API tokens:** The `theme` prop (`"light"` | `"dark"` | `"system"`) chooses which variant of those tokens to apply.
277
278
 
278
279
  ### Behavior summary
279
280
 
@@ -286,9 +287,46 @@ CSS custom properties (`--iccandle-primary`, `--iccandle-border`, `--iccandle-ba
286
287
  - Stores selected events in `localStorage` (key `iccandle:current-news-event`) for timescale mark sync.
287
288
  - Listens for `window` `message` events for chart/news integration.
288
289
 
290
+ ### Chart switching between TradingView and ICCandle
291
+
292
+ The widget dynamically switches between the third-party TradingView chart and ICCandle's own history chart depending on how much price data is available after the event:
293
+
294
+ - **ICCandle history chart (elapsed events):** When a user clicks an older event where the selected timeframe has fully elapsed (roughly 50+ candles after the event time), the widget replaces the TradingView chart with ICCandle's history chart rendered via iframe. This chart provides ICCandle's curated pip-range analysis.
295
+ - **TradingView chart (recent/upcoming events):** When the event's timeframe has not yet fully elapsed, the widget keeps the TradingView chart visible in a split layout — event detail card and TradingView chart on the left, ICCandle iframe on the right — and draws pip-range overlays directly on the TradingView chart.
296
+
297
+ ### Symbol handling and limitations
298
+
299
+ ICCandle's history chart supports a fixed set of symbols. When a currency event occurs (e.g. a USD news release), only symbols related to that currency are available in the ICCandle chart, so the impact visualization is scoped to relevant pairs.
300
+
301
+ In the TradingView chart, however, symbol filtering cannot be controlled by the widget — the impact is drawn on whatever symbol is currently active, which may not be directly related to the event's currency. Keep this in mind when interpreting pip-range overlays on unrelated symbols in the TradingView chart.
302
+
303
+ #### Symbol name mapping (`symbolMapper`)
304
+
305
+ ICCandle and your broker/TradingView setup often use different naming conventions for the same instrument — for example, ICCandle uses `XAUUSD` while your chart may use `GOLD`, or ICCandle uses `USDCAD` while your chart may use `USD_CAD`. The optional `symbolMapper` prop lets you define a mapping from ICCandle's ticker names to your chart's symbol names:
306
+
307
+ ```tsx
308
+ <NewsWidget
309
+ chartWidget={chartWidget}
310
+ widgetKey="your-api-key"
311
+ defaultSymbol="XAUUSD"
312
+ chartInterval="15"
313
+ theme="dark"
314
+ symbolMapper={{
315
+ XAUUSD: "GOLD",
316
+ USDCAD: "USD_CAD",
317
+ EURUSD: "EURUSD",
318
+ // ... map ICCandle tickers to your broker's symbol names
319
+ }}
320
+ >
321
+ {children}
322
+ </NewsWidget>
323
+ ```
324
+
325
+ When a symbol change event is received from the ICCandle iframe, the widget looks up the symbol in `symbolMapper`. If no mapping is found (or `symbolMapper` is not provided), the widget falls back to `defaultSymbol`. This ensures the TradingView chart always navigates to a valid symbol.
326
+
289
327
  ## Optional: timescale marks (news/events)
290
328
 
291
- If your data feed implements `getTimescaleMarks`, you can surface stored events (e.g. from `localStorage` under `tv:current-news-event`) as marks on the time axis. Example shape:
329
+ If your data feed implements `getTimescaleMarks`, you can surface stored events (e.g. from `localStorage` under `iccandle:current-news-event`) as marks on the time axis. Example shape:
292
330
 
293
331
  ```ts
294
332
  getTimescaleMarks: async (