Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TradingView integration trough websocket

I am trying to implement trading view charting library into my angular project and use data from Crypto Compare trough web socket.

I went over the documentation and find it a bit confusing.

Do I need to create my own custom Datafeed object? And if yes than how?

In general if someone has an example of how to do that It would be great.

Tnx in advance!!

Edit

I am adding my widget config object, I want to understand what should I change in order to get data from CryptoCompare:

const widgetOptions: ChartingLibraryWidgetOptions = {
  symbol: this._symbol,
  datafeed: new (window as any).Datafeeds.UDFCompatibleDatafeed(this._datafeedUrl),
  interval: this._interval,
  container_id: this._containerId,
  library_path: this._libraryPath,
  locale: 'en',
  disabled_features: ['use_localstorage_for_settings'],
  enabled_features: ['study_templates'],
  charts_storage_url: this._chartsStorageUrl,
  charts_storage_api_version: this._chartsStorageApiVersion,
  client_id: this._clientId,
  user_id: this._userId,
  fullscreen: this._fullscreen,
  autosize: this._autosize,
};

What params should I change in order to access crypto compare for data?

Tnx

like image 595
Asaf Avatar asked Dec 03 '25 23:12

Asaf


1 Answers

Use JS Api tradingview, in subscribeBars you can implement websocket with onRealtimeCallback

this.subscribeBars = function (symbolInfo, resolution, onRealtimeCallback, subscribeUID, onResetCacheNeededCallback) {

    $scope.$on('handleBroadcastDfn', function () {

        if (symbolInfo.id === dfnData.message.symbol) {
            onRealtimeCallback(
                {
                    time: lastData.time,
                    close: dfnData.message.ask,
                    open: lastData.open,
                    low: lastData.low,
                    high: lastData.high, volume: 0
                });

        }

    });
}
like image 61
Ufuk Aydın Avatar answered Dec 05 '25 14:12

Ufuk Aydın



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!