Giter Site home page Giter Site logo

Comments (5)

krasnopv avatar krasnopv commented on June 11, 2024 1
function Bitfinex () {
    function bytesToHex(data) {
        return data.map(function(e) {
            var v = (e < 0 ? e + 256 : e).toString(16);
            return v.length == 1 ? "0" + v : v;
        }).join("");
    }
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Config");
    const apiKey = sheet.getRange("B26").getValue();
    const apiSecret = sheet.getRange("B27").getValue();
    const apiPath = "v2/auth/r/wallets";
    const nonce = Date.now().toString();
    const body = { "type": "price" };
    const rawBody = JSON.stringify(body);
    var signature = "/api/" + apiPath + nonce + rawBody;
    signature = Utilities.computeHmacSignature(Utilities.MacAlgorithm.HMAC_SHA_384, signature, apiSecret);
    signature = bytesToHex(signature);
    const url = "https://api.bitfinex.com/" + apiPath;
    const options = {
      method: 'POST',
      contentType: "application/json",
      headers: {
        'bfx-nonce': nonce,
        'bfx-apikey': apiKey,
        'bfx-signature': signature
      },
      payload: rawBody
    };
    var response = UrlFetchApp.fetch(url, options);
    var data = JSON.parse(response.getContentText());  
  var array = [];
  for(var x in data){ balance=parseFloat(data[x][2]);
    if (balance > 0) {
      asset=data[x][1]
      if (asset=="IOT") {asset="MIOTA"}
      if (asset=="QSH") {asset="QASH"}
      array.push({'currency': asset, 'balance': balance, 'market': "Bitfinex"})}
    } 
  }
  return array;
}

This works for me.
I used for 'signature = bytesToHex(signature);' except jsSHA.
I didn't check all Bitfinex's symbols, but I could check them in future.
API settings in Config: B26 and B27 cells.

from cryptocurrency-portfolio.

emmtte avatar emmtte commented on June 11, 2024

No, I have no account on bitfinex.

from cryptocurrency-portfolio.

krasnopv avatar krasnopv commented on June 11, 2024

Ok. I try to do it myself.
I will push on Success ;)

from cryptocurrency-portfolio.

emmtte avatar emmtte commented on June 11, 2024

found this may help you
https://gist.github.com/tanaikech/1104d039341f198f95eee66af57c0abf

from cryptocurrency-portfolio.

emmtte avatar emmtte commented on June 11, 2024

Really good job and fastest
Thanks @krasnopv
Updated with main.js and readme

from cryptocurrency-portfolio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.