add few data sources

This commit is contained in:
2023-12-07 05:01:46 +01:00
parent 945441fff7
commit edd84c9000

View File

@@ -8,11 +8,43 @@ const dataSources = [
name: 'blockchain.info', name: 'blockchain.info',
url: 'https://blockchain.info/tobtc?currency=USD&value=1', url: 'https://blockchain.info/tobtc?currency=USD&value=1',
pick: res => 1 / +res, pick: res => 1 / +res,
asset: 'USD',
}, },
{ {
name: 'binance', name: 'binance',
url: 'https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT', url: 'https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT',
pick: res => +res.price, pick: res => +res.price,
asset: 'USDT',
},
{
name: 'bybit',
url: 'https://api.bybit.com/v2/public/tickers?symbol=BTCUSD',
pick: res => +res.result[0].last_price,
asset: 'USD',
},
{
name: 'coinbase',
url: 'https://api.coinbase.com/v2/prices/spot?currency=USD',
pick: res => +res.data.amount,
asset: 'USD',
},
{
name: 'kraken',
url: 'https://api.kraken.com/0/public/Ticker?pair=XXBTZUSD',
pick: res => +res.result.XXBTZUSD.a[0],
asset: 'USD',
},
{
name: 'bitstamp',
url: 'https://www.bitstamp.net/api/v2/ticker/btcusd',
pick: res => +res.last,
asset: 'USD',
},
{
name: 'coingecko',
url: 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd',
pick: res => +res.bitcoin.usd,
asset: 'USD',
}, },
]; ];
@@ -23,7 +55,6 @@ const get = async (url) => {
const calcAverage = () => { const calcAverage = () => {
const arr = prices.value; const arr = prices.value;
console.log(arr);
average.value = arr.reduce((sum, val) => sum + val, 0) / arr.length; average.value = arr.reduce((sum, val) => sum + val, 0) / arr.length;
}; };
@@ -47,6 +78,11 @@ const prices = ref([]);
loop(); loop();
})(); })();
// get(`
// `.trim()).then(res => {
// console.log(res);
// });
</script> </script>
<template> <template>