Giter Club home page Giter Club logo

tradingview-adapter's Introduction

Polygon.io TradingView Adapter

JS Library for using Polygon.io with TradingView charting.

Installation

	npm i @polygon.io/tradingview-adapter --save-dev

Usage

import PolygonAdapter from '@polygon.io/tradingview-adapter'

const client = new PolygonAdapter({
	apikey: 'YOUR_APIKEY',
	realtimeEnabled: true 	// True(default) = Use websockets for updates. False = use polling for new data.
})

const widget = new TradingView.widget({
	fullscreen: true,
	symbol: 'AAPL',
	interval: '1D',
	timezone: 'America/New_York',
	container_id: "tv_chart_container", /* ID of the container element */
	datafeed: client, /* Our Polygon.io Adapter */
	library_path: "/charting_library/", /* Where your TV Library files reside */
	locale: "en",
	disabled_features: ["use_localstorage_for_settings"],
	enabled_features: ["study_templates"],
	charts_storage_url: 'http://saveload.tradingview.com',
	charts_storage_api_version: "1.1",
	client_id: 'tradingview.com',
	user_id: 'public_user_id',
	theme: 'Light', /* Light or Dark */
})

Currently only stocks are supported at 1min and 1day intervals. This will be fixed soon.

tradingview-adapter's People

Contributors

qrpike avatar stacho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tradingview-adapter's Issues

resolveSymbol method not working !

Hello,
we integrated this charting library and the polygon provider months ago, it was work correctly, now it's not working because of this method called: resolveSymbol, I almost sure that the problem is that you changed something in the Endpoint api request so you have to fix it to work with the new changes you made to the API endpoint/s, here is the full code of the NOT working mehtod:

resolveSymbol( symbol, cb, cberr ){
		console.log('resolve symbol:', symbol)
		let TickerTypeMap = {
			'STOCKS': 'stock',
			'FX': 'forex',
			'CRYPTO': 'bitcoin',
		}
		axios.get(`${BASE_URL}/v2/reference/tickers/${symbol}?apiKey=${this.apikey}`).then(( data ) => {
			console.log('DATAAA', data)
			let c = Get( data, 'data.results', {} )
			let intFirst = Get( c, 'aggs.intraday.first', false )
			let dayFirst = Get( c, 'aggs.daily.first', false )
			cb({
				name: c.ticker.ticker,
				ticker: c.ticker.ticker,
				type: TickerTypeMap[ c.ticker.type ] || 'stocks',
				exchange: c.ticker.exchange,
				timezone: 'America/New_York',
				first_intraday: intFirst,
				has_intraday: ( intFirst != false ),
				first_daily: dayFirst,
				has_daily: ( dayFirst != false ),
				supported_resolutions: SUPPORTED_RESOLUTIONS,
			})
		})
	}

Thank you.

Getting resolveSymbol to work

Not sure if Polygon changed data format since this was built but I was having some issues integrating the adapter into tradingview charts. Updating resolveSymbol as follows solved the problem for me. Figured I'd share in case anyone else is having the same problem.

	resolveSymbol( symbol, cb, cberr ){
		console.log('resolve symbol:', symbol)
		let TickerTypeMap = {
			'STOCKS': 'stock',
			'FX': 'forex',
			'CRYPTO': 'bitcoin',
		}
		axios.get(`${BASE_URL}/v2/reference/tickers?search=${symbol}&perpage=50&page=1&apiKey=${this.apikey}`).then(( data ) => {
			console.log('DATAAA', data)
			let c = Get( data, 'data.tickers[0]', {} )
			console.log('c',c)
			cb({
				name: c.name,
				ticker: c.ticker,
				type: TickerTypeMap[ c.market ] || 'stocks',
				exchange: c.primaryExch,
				minmov: 1,
				pricescale: 100,
				session:'0900-1630',
				timezone: 'America/New_York',
				has_intraday: true,
				supported_resolutions: SUPPORTED_RESOLUTIONS,
			})
		})
	}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.