Skip to content

Instantly share code, notes, and snippets.

@sayon-bitquery
Last active June 25, 2021 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayon-bitquery/65d5d0f5669554748d939db0558af2df to your computer and use it in GitHub Desktop.
Save sayon-bitquery/65d5d0f5669554748d939db0558af2df to your computer and use it in GitHub Desktop.
tradingview-2:11
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