Created
July 21, 2021 17:28
-
-
Save sayon-bitquery/777b725da8ecef86eed432856aea9c92 to your computer and use it in GitHub Desktop.
Tradingview-3.8
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) =>{ | |
const response = await axios.post( | |
Bitquery.endpoint, { | |
query: ` | |
{ | |
ethereum(network: bsc) { | |
dexTrades( | |
options: {desc: ["block.height", "transaction.index"], limit: 1} | |
exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"} | |
baseCurrency: {is: "${baseCurrency}"} | |
quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"} | |
) | |
{ | |
block { | |
height | |
timestamp { | |
time(format: "%Y-%m-%d %H:%M:%S") | |
} | |
} | |
transaction { | |
index | |
} | |
baseCurrency { | |
name | |
symbol | |
decimals | |
} | |
quotePrice | |
} | |
} | |
} | |
`, | |
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; | |
if(!coin){ | |
onResolveErrorCallback(); | |
}else{ | |
const symbol = { | |
ticker: symbolName, | |
name: `${coin.symbol}/BNB`, | |
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) | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment