Skip to content

TradingView chart service ​

The trade page uses the TradingView charting library. The candles it draws come from one of three places, depending on each market's Chart type setting. One of them is a small Node.js service, chart-udf, which you run next to the platform.

10 minutesServer administrationDevOpsVerified against the platform code

Where candles come from ​

Each market chooses its chart source in Admin → Markets → edit → Chart (see Markets → Chart):

Chart type / settingCandles come fromServed by
InternalTrades on your own exchangeThe platform, at /tradingview-chart
Internal + External chart data onBinance, MEXC or Bybit, cachedThe platform, at /tradingview-chart
From liquidity providerBinancechart-udf, at /chart.io
External custom marketTradingView's own widget for the symbol you nameTradingView

So you need chart-udf running for every market whose chart type is From liquidity provider. The other types work without it.

The chart-udf service ​

Folderchart-udf/
Start commandnpm start (runs node ./src/app.js)
PM2 processchart, a background service in config/pm.php (started by pm:watcher)
Port8081, or TRADINGVIEW_CHART_PORT
Addresshttps://yourdomain.com/chart.io (through Nginx)
Data sourceapi.binance.com (symbols and candles)
ConfigurationThe platform's main .env (read from the project root)

It reloads Binance's symbol list every 30 seconds and keeps recent candles in memory.

Install and start it ​

bash
cd /var/www/exchange/chart-udf && npm ci && cd ..

The scheduler's pm:watcher then starts it. To start it right away: php artisan pm:ecosystem && pm2w start storage/app/pm2/ecosystem.json --only chart. Admin → Market services shows it as Chart Data Server, with a health check on /chart.io/time.

Nginx proxy ​

The browser loads candles from https://yourdomain.com/chart.io/.... Nginx passes those requests to the service. This block goes in your exchange's server { }, as in the installation guide:

nginx
location /chart.io {
    proxy_pass http://127.0.0.1:8081;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
}

Check it works:

bash
curl -s https://yourdomain.com/chart.io/time      # prints a Unix timestamp
curl -s https://yourdomain.com/chart.io/config    # prints the chart configuration

Built-in HTTPS (optional) ​

You normally don't need this, because Nginx handles HTTPS. If you want the service itself to serve HTTPS (for example without Nginx in front), set:

ini
TRADINGVIEW_CHART_SSL="true"
TRADINGVIEW_CHART_PRIVATE_KEY="/etc/letsencrypt/live/yourdomain.com/privkey.pem"
TRADINGVIEW_CHART_CERT_FILE="/etc/letsencrypt/live/yourdomain.com/fullchain.pem"

The service user must be able to read both files. Restart it with pm2w restart chart.

TRADINGVIEW_CHART_SSL must be set

The service reads TRADINGVIEW_CHART_SSL when it starts. If the variable is missing from .env, it crashes on start. Keep the line TRADINGVIEW_CHART_SSL="false" from .env.example.

External chart data and cache warming ​

With External chart data on, the platform loads candles from the source you pick (Binance, MEXC or Bybit) and caches them. This gives a new market a full price history from day one, even before anyone trades it.

The scheduler runs chart:warm-cache --all every 5 minutes, which refreshes the cache for every market with external chart data, so charts open quickly. You can also warm the cache by hand:

bash
php artisan chart:warm-cache --all
php artisan chart:warm-cache --symbol=BTCUSDT --exchange=mexc

Chart data requests are limited to 80 per minute per user or IP address, so one visitor can't overload the service.

Troubleshooting empty charts ​

SymptomCheck
Chart area stays blank on a provider marketpm2w status: is chart online? Does curl https://yourdomain.com/chart.io/time answer?
chart keeps restartingpm2w logs chart. Most often TRADINGVIEW_CHART_SSL is missing, or the certificate paths are wrong.
/chart.io returns 404The Nginx location /chart.io block is missing, or Nginx wasn't reloaded
"No data" on a provider marketThe pair doesn't exist on Binance under that name. Use Internal with External chart data and set the external symbol.
"No data" on an internal marketNobody has traded it yet. Turn on External chart data, or place a first trade.
External data chart is emptyThe server can't reach the source exchange. Test with curl -I https://api.binance.com. Some hosting regions block Binance; choose MEXC or Bybit instead.

Owner documentation for the CryptoTech exchange platform.