Dex prices on Google spreadsheet

Hello, does anyone know how to get waves dex prices on Google spreadsheet?

You can write scripts to get data from DEX. AFAIK, Google Spreadsheets supports scripting language and can make HTTP requests: https://developers.google.com/apps-script/guides/sheets

You can get data from Matcher API
https://matcher.wavesplatform.com/api-docs/index.html#/matcher

1 Like

Thank you very much for your response. Please am not actually a programmer, i just have little knowledge about APIs.

I was able to get coinmarketcap price into spreadsheet using the (=CRYPTOFINANCE(“BTCUSD”), i simply paste that into a cell and the price appears. Please can you give me example on how to get the price of let’s say (ETH/WAVES) into the spreadsheet.

I’ll truly appreciate it if you can help me with this. Thanks

I made two simple functions, you can add them as App Scripts. You can use WAVESDEXPRICE as

WAVESDEXPRICE(“474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu”; “WAVES”; false)

First parameter is ETH asset ID, second is WAVES, last parameter is min (if true - will get min price from all orders, false - max price from all orders).

function WAVESDEXTRIGGER(amountAsset, priceAsset, min){
  if (amountAsset == null){
    amountAsset = "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu";
  }
  if (priceAsset == null){
    priceAsset = "WAVES";
  }
  if (min == null || min == true){
    min = true;
  }else{
    min = false
  }
  var aUrl = "https://matcher.wavesplatform.com/matcher/orderbook/" + amountAsset + "/" + priceAsset;
  var response = UrlFetchApp.fetch(aUrl); // get feed
  var dataAll = JSON.parse(response.getContentText());
  var data = dataAll.bids;
  var minPrice = data[0].price;
  for (i in data){
    if (min){
      if (data[i].price < minPrice){
        minPrice = data[i].price;
      }
    }else{
      if (data[i].price > minPrice){
        minPrice = data[i].price;
      }
    }
  }
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var d = new Date();

 sheet.appendRow([d.toLocaleString(), minPrice]);
}


function WAVESDEXPRICE(amountAsset, priceAsset, min){
  
  if (priceAsset == null){
    priceAsset = "WAVES";
  }
  if (min == null || min == true){
    min = true;
  }else{
    min = false
  }

  var aUrl = "https://matcher.wavesplatform.com/matcher/orderbook/" + amountAsset + "/" + priceAsset;
  var response = UrlFetchApp.fetch(aUrl); // get feed
  var dataAll = JSON.parse(response.getContentText());
  var data = dataAll.bids;
  var minPrice = data[0].price;
  for (i in data){
    if (min){
      if (data[i].price < minPrice){
        minPrice = data[i].price;
      }
    }else{
      if (data[i].price > minPrice){
        minPrice = data[i].price;
      }
    }
  }
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];
  var d = new Date();

 return minPrice;
}

Thanks, the demo table spreadsheet you sent on discord worked. I was able to get the highest and lowest bid price from the order book for ETH/WAVES pair.

What if i want to add that of BCH/WAVES, LTC/WAVES, DASH/WAVES, ZEC/WAVES on thesame spreadsheet, do i just duplicate the script file for ETH and edit the asset ID i.e adding new script files?

No, you just have to change parameters of function WAVESDEXPRICE. You can get assetId for BTC, LTC, DASH, ZEC here:

Just put the assetId as first parameter of function.You can find assetIds here: https://marketdata.wavesplatform.com/api/symbols

1 Like

Wow… Thanks alot. You have been very helpful. Exactly what i wanted. Thanks Thanks Thanks

Now am trying to see how to get the 24Hrs Low and High.