tradingview / charting-library-examples

Examples of Charting Library integrations with other libraries, frameworks and data transports
MIT License
1.33k stars 744 forks source link

I am not able to implement Datafeed for NextJS example #287

Open duanescarlett opened 2 years ago

duanescarlett commented 2 years ago

I followed the tutorial on how to setup a datafeed using Cryptocompare but I cant get it to run I just keep getting a socket error.

This is how I connect to my chart widget

        const widgetOptions = {
            symbol: this.props.symbol,
            // BEWARE: no trailing slash is expected in feed URL
            datafeed: new window.Datafeeds.UDFCompatibleDatafeed(DATAFEED),
            interval: this.props.interval,
            container: this.ref.current,
            library_path: this.props.libraryPath,

            locale: getLanguageFromURL() || 'en',
            disabled_features: ['use_localstorage_for_settings'],
            enabled_features: ['study_templates'],
            charts_storage_url: this.props.chartsStorageUrl,
            charts_storage_api_version: this.props.chartsStorageApiVersion,
            client_id: this.props.clientId,
            user_id: this.props.userId,
            fullscreen: this.props.fullscreen,
            autosize: this.props.autosize,
            studies_overrides: this.props.studiesOverrides,
        }

socketError

romfrancois commented 2 years ago

Hi @duanescarlett!

Could you please provide more details as to how/what you implemented?

duanescarlett commented 2 years ago

I used the NextJs example and tried to implement the tutorial that uses the crypto compare API and I just kept getting socket errors, but I need help understanding how to implement a custom datafeed or at least a recommended on that works.

edew commented 2 years ago

Hi @duanescarlett

You can use https://github.com/tradingview/yahoo_datafeed for a reference of how to implement a UDF compatible datafeed.

And this repository from a member of the public gives an example of how to implement streaming data https://github.com/jonchurch/tradingview-js-api-tutorial