Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickerNews bringing non-related-to-ticker news #189

Open
lropero opened this issue Nov 29, 2023 · 1 comment
Open

tickerNews bringing non-related-to-ticker news #189

lropero opened this issue Nov 29, 2023 · 1 comment
Assignees

Comments

@lropero
Copy link

lropero commented Nov 29, 2023

This code compares reference.tickerNews() response with endpoint /v2/reference/news response and they differ.

import axios from 'axios'
import dotenv from 'dotenv'
import { restClient } from '@polygon.io/client-js'

dotenv.config()

axios.interceptors.request.use(request => {
  request.headers.Authorization = `Bearer ${process.env.POLYGON_API_KEY}`
  return request
})
const polygon = restClient(process.env.POLYGON_API_KEY, process.env.POLYGON_API_URL)

const ticker = 'AAPL'
const responsePolygon = await polygon.reference.tickerNews(ticker)
console.log('polygon', responsePolygon.results.map(n => `${n.published_utc} ${n.title} ${n.tickers.includes(ticker)}`))
const responseAxios = await axios.get(`https://api.polygon.io/v2/reference/news?ticker=${ticker}`)
console.log('axios', responseAxios.data.results.map(n => `${n.published_utc} ${n.title} ${n.tickers.includes(ticker)}`))
@justinpolygon justinpolygon self-assigned this Nov 29, 2023
@justinpolygon
Copy link
Contributor

Changing polygon.reference.tickerNews(ticker) to polygon.reference.tickerNews({ ticker: ticker }) seems to have fixed the problem and should work as a workaround. polygon.reference.tickerNews(ticker) should work though and I'll explore why not. I turned on trace: true, and this shows the url being called which is how I debugged this.

import axios from 'axios'
import { restClient } from '@polygon.io/client-js'

const globalFetchOptions = {
	trace: true,
};

axios.interceptors.request.use(request => {
  request.headers.Authorization = `Bearer ${process.env.POLYGON_API_KEY}`
  return request
})
const polygon = restClient(process.env.POLYGON_API_KEY, process.env.POLYGON_API_URL, globalFetchOptions)

const ticker = 'AAPL'
const responsePolygon = await polygon.reference.tickerNews({ ticker: ticker })
console.log('polygon', responsePolygon.results.map(n => `${n.published_utc} ${n.title} ${n.tickers.includes(ticker)}`))
const responseAxios = await axios.get(`https://api.polygon.io/v2/reference/news?ticker=${ticker}`)
console.log('axios', responseAxios.data.results.map(n => `${n.published_utc} ${n.title} ${n.tickers.includes(ticker)}`))

I'll keep digging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants