@iccandle/news 0.0.2 → 0.0.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/README.md CHANGED
@@ -137,7 +137,7 @@ const widgetKey = "your-iccandle-api-key";
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,7 +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.
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.
156
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.
157
157
 
158
158
  ### Full working example
@@ -248,8 +248,10 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
248
248
 
249
249
  | Name | Kind | Description |
250
250
  | ----------------- | --------- | ------------------------------------------------- |
251
- | `NewsWidget` | Component | Economic calendar analysis overlay for your chart |
252
- | `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`) |
253
255
 
254
256
  ### `NewsWidget` props
255
257
 
@@ -258,9 +260,10 @@ For a concrete in-repo reference (custom datafeed, timezone, visibility handling
258
260
  | `chartWidget` | `IChartingLibraryWidget \| null` | Yes | Live TradingView widget instance (`null` until ready). |
259
261
  | `children` | `ReactNode` | Yes | Your chart UI (e.g. container + library bootstrap). |
260
262
  | `widgetKey` | `string` | Yes | ICCandle API key. Used for theme fetch, chart data, news events, and scanner validation. |
261
- | `defaultSymbol` | `string` | Yes | Default trading symbol used to initialize the chart (e.g. `"XAU_USD"`, `"EURUSD"`, `"BTCUSDT"`). Also used as the fallback when a selected symbol is unrecognized or unavailable. |
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). |
262
265
  | `chartInterval` | `"1" \| "5" \| "15" \| "30" \| "60"` | Yes | Initial chart candle interval in minutes used when showing the chart. Defaults to `"15"`. |
263
- | `theme` | `"light" \| "dark" \|` | Yes | Affects resolved theme tokens and chart overlays. |
266
+ | `theme` | `"light" \| "dark" \| "system"` | No | Affects resolved theme tokens and chart overlays. `"system"` resolves to light or dark based on `prefers-color-scheme`. |
264
267
 
265
268
  ### Widget key and remote theming
266
269
 
@@ -271,7 +274,7 @@ On mount, the component loads branding colors from ICCandle:
271
274
 
272
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.
273
276
 
274
- **Theme prop vs. API tokens:** The `theme` prop (`"light"` | `"dark"`) chooses which variant of those tokens to apply.
277
+ **Theme prop vs. API tokens:** The `theme` prop (`"light"` | `"dark"` | `"system"`) chooses which variant of those tokens to apply.
275
278
 
276
279
  ### Behavior summary
277
280
 
@@ -284,9 +287,46 @@ CSS custom properties (`--iccandle-primary`, `--iccandle-border`, `--iccandle-ba
284
287
  - Stores selected events in `localStorage` (key `iccandle:current-news-event`) for timescale mark sync.
285
288
  - Listens for `window` `message` events for chart/news integration.
286
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
+
287
327
  ## Optional: timescale marks (news/events)
288
328
 
289
- 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:
290
330
 
291
331
  ```ts
292
332
  getTimescaleMarks: async (