CL-2954: Update datafeed tutorial#156
Conversation
SimonMorda
left a comment
There was a problem hiding this comment.
Added comment as Simon instead of Romain but didn't want to switch user and restart again.
| @@ -1,62 +1,120 @@ | |||
| # Advanced Charts: Connecting data via the Datafeed API | |||
| # TradingView Charting Library Datafeed Example | |||
There was a problem hiding this comment.
Could you please add a mention somewhere when was the last time this tutorial was tested and with which versions of the TV lib and dependencies (aka Binance, CoinDesk, etc)?
There was a problem hiding this comment.
Added the following:
Last tested: June 2026 with TradingView Advanced Charts 31.2.0, Trading
Platform 31.2.0, Binance public Spot REST/WebSocket APIs, CoinDesk RSS, and the
npm dependencies frompackage-lock.json.
| @@ -0,0 +1,236 @@ | |||
| import { | |||
There was a problem hiding this comment.
Im aware you've explained in other md files the purpose of this file but could you at least add an intro at the very top of the file to quickly indicate what's that file for while inviting people to read the README & INTEGRATION files?
| @@ -0,0 +1,162 @@ | |||
| import { cp, mkdir, rm, stat } from 'node:fs/promises'; | |||
There was a problem hiding this comment.
Added the same style of header here too
| const alertIndex = activeAlerts.findIndex( | ||
| alert => alert.id === id | ||
| ); | ||
| if (alertIndex === -1) return; |
There was a problem hiding this comment.
Even though the setTimeout is very small I would move this block down into it. activeAlerts may be different between now and within the setTimeout resulting in out of date data.
There was a problem hiding this comment.
Used codex and moved the alert lookup inside the timeout and now resolve by id against the latest activeAlerts state before updating.
|
|
||
| notify( | ||
| 'Alert Triggered', | ||
| `Price crossed your alert at ${alert.price.toFixed(2)}` |
| const price = lastPlusClickPrice; | ||
| const alertAction = actionsFactory.createAction({ | ||
| actionId: 'create_custom_alert', | ||
| label: `Add Alert at ${price.toFixed(2)}`, |
There was a problem hiding this comment.
Possible refinement to bring here at some point.
Depending on the formater used/precision set in Settings, toFixed may be wrong.
Not the end of the world though.
There was a problem hiding this comment.
Codex replaced toFixed with helped function that falls back to toFixed. I think this helped is not working so it will always fall back to toFixed(). I will look into it more in the future
| if (interval === '1M') { | ||
| return null; | ||
| } |
|
Really good tutorial! I think some tweaks could be brought to centralize some common logic, especially when it comes to creating and managing web socket creation. |
|
@illetid , @SlicedSilver could you also please provide your feedback? 🙏 |
No description provided.