Last active
June 25, 2021 19:04
-
-
Save sayon-bitquery/65d5d0f5669554748d939db0558af2df to your computer and use it in GitHub Desktop.
tradingview-2:11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolveSymbol: async (symbolName, onSymbolResolvedCallback, onResolveErrorCallback) =>{ | |
console.log('[resolveSymbol]: Method called!!'); | |
const response = await axios.post( | |
Bitquery.endpoint, { | |
query: Bitquery.GET_COIN_INFO, | |
variables: { | |
"tokenAddress": symbolName | |
}, | |
mode: 'cors', | |
headers: { | |
"Content-Type": "application/json", | |
"X-API-KEY": "YOUR UNIQUE API KEY" | |
} | |
} | |
); | |
// const coin = response.data.data.ethereum.dexTrades[0].baseCurrency; | |
// console.log(response.data.data.ethereum.dexTrades[0].quotePrice); | |
console.log(response.data.data.ethereum.dexTrades[0].baseCurrency); | |
const coin = response.data.data.ethereum.dexTrades[0].baseCurrency; | |
if(!coin){ | |
onResolveErrorCallback(); | |
}else{ | |
const symbol = { | |
ticker: symbolName, | |
name: `${coin.symbol}/USD`, | |
session: '24x7', | |
timezone: 'Etc/UTC', | |
minmov: 1, | |
pricescale: 10000000, | |
has_intraday: true, | |
intraday_multipliers: ['1', '5', '15', '30', '60'], | |
has_empty_bars: true, | |
has_weekly_and_monthly: false, | |
supported_resolutions: configurationData.supported_resolutions, | |
volume_precision: 1, | |
data_status: 'streaming', | |
} | |
//onSymbolResolvedCallback(symbol); | |
onSymbolResolvedCallback(symbol) | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment