Giter VIP home page Giter VIP logo

list's Introduction

Cryptocurrency-Portfolio

Google Sheet's automatic update with Google Apps Script (GAS) for a cryptocurrency portfolio

img

Features

This script updates a google sheet with currency balances extracted from differents exchanges as

  • Binance
  • Bitfinex
  • Bittrex
  • Bitstamp
  • Cryptopia
  • Kraken
  • Kucoin
  • Poloniex

It also gives prices coming from Coinmarketcap.com

Installation

With the ready template

Without template

Next Steps

  • Click Tools > Script editor... Create a script file using File > New > Script file Copy and paste the contents of main.js and save.
  • Create a new file jsSHA.js and copy the content of https://github.com/Caligatio/jsSHA/blob/master/dist/sha.js
  • Create a new script file for each API exchanges you need
  • Return to the spreadsheet
  • In "Market" sheet, choose your fiat ($ or €) in cell I3 and enter your total deposit in cell G3
  • In "Config" sheet, paste your API key and API secret from the exchanges you want to use (See explanations below API Exchange configuration for each exchange)
  • Reload the page
  • A couple of seconds after the page's reload you should see a "Crypto Tools" menu at the top (on the right of Help menu)
  • Click on "Crypto Tools" and "Update Portfolio" to see your updated personnal crypto portfolio

Note: Multiple exchanges are allowed

API Exchange configuration

Kraken

https://www.kraken.com/u/settings/api

  • Log in into your Kraken account and navigate to Settings -> API
  • Create a new key and select in the permissions only "Query Funds"
  • Enter the Key in B2 cell and the Private Key in B3 cell in "Config" sheet

Bittrex

https://bittrex.com/Manage#sectionApi

  • Log in into your Bittrex account and navigate to Settings -> API Keys
  • Create a new key
  • Enable only READ INFO
  • Click on Update Keys
  • Enter your Key in B6 cell and your Secret in B7 cell in "Config" sheet

Poloniex

https://poloniex.com/apiKeys

  • Log in into your Poloniex account, select the Settings icon and click on API KEYS
  • Please create a new API key. Do not use an already existing key.
  • Please disable (!!!) both checkboxes Enable Trading and Enable Withdrawals as we do not need them!!!
  • Enter your Key in B10 and your Secret here in B11 cell in "Config" sheet

Binance

https://www.binance.com/userCenter/createApi.html

  • Log in into your Binance account and navigate to the Security Settings page
  • Click on 'API Settings' and create a new key
  • Check only the 'Read Info' permission
  • Check Unrestricted (Less Secure) in IP Access Restriction
  • Enter your Key in B14 cell and your Secret in B15 cell in "Config" sheet

Cryptopia

https://www.cryptopia.co.nz/Security

  • Log in into your Cryptopia account and navigate to Settings -> Security
  • Check the 'Enable API' checkbox and create a 'New Key'
  • Save the changes
  • Enter your Key in B18 cell and your Secret in B19 cell in "Config" sheet

Kucoin

https://www.kucoin.com/#/user/setting/api

  • Log in into your KuCoin account and navigate to Settings -> API Keys
  • Click on 'Create'
  • Enter your Key in B22 cell and your Secret in B23 cell in "Config" sheet

Warning: KuCoin.com does not provide API permissions. All keys have full access to your funds.

Biffinex

https://www.bitfinex.com/api

  • Log in into your Bitfinex account and navigate to Account -> API
  • Create a new key
  • Select all Read boxes (should be selected by default) and do not select any Write boxes.
  • Label the API Key and generate it.
  • Enter your Key in B26 cell and your Secret in B27 cell in "Config" sheet

Bitstamp

https://www.bitstamp.net/account/security/api/

  • Log in into your Bitstamp account and select under Security the point API Access
  • Create a new key and select in the perms only Account balance
  • Activate the generated key
  • Enter your Key in B30 cell and your Secret in B31 cell in "Config" sheet
  • Enter your Customer ID (displayed under Account) in B32 cell in "Config" sheet

Optional

Receive by email a pdf copy of "Market" sheet each hours or when you want :

  • Just add an event in script editor with "current project's triggers" button.
  • Run : convertSpreadsheetToPdf()
  • Event : Time-driven

License

MIT License

Copyright (c) August 2017-2021

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

list's People

Contributors

drhus avatar emmtte avatar jelbazi avatar jhanzo avatar markclift avatar merinorus avatar pokemaster974 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

list's Issues

Bittrex

Screen real balance Bittrex and Cryptocurrency-Portfolio.Why?Please help me
balancebittrex
portfolio1

Request Bitmex

Hey, what about BitMEX? We really need BitMEX too!!, thx ;)

Fiat module

I tried the FIAT module, but when I add it and I refresh the cryptocurrency, the FIAT currency disappears.

Kucoin API update

Hi,

Not sure if you're updating this but Kucoin has upgraded their API and the old code doesn't work.

Seems to want a 44 character signature, not 64.

coinMarketCap api error

I followed the installation instructions. However, when clicking Update Portfolio I get the following error:

Exception: Request failed for https://api.coinmarketcap.com returned code 503. Truncated server response: <me... (use muteHttpExceptions option to examine full response)

Clarify instructions please

Hi,

I'm really keen to use this, but can't follow the instructions. Are some of the .js files missing?

The instruction in step 3 "click on the link and search for sheet and enable Google Sheets API" doesn't make sense to me and then in step 4 I'm not clear how to link the new sheet to the scripts that have been created.

Is there an example sheet you can share that I can then make my own copy of?

Thanks!

onOpen -> balance

var entries = [{ name : "Update Portfolio", functionName : "balance" }];
Where is this function balance() in js Files? Maybe there should be another function in Menu?

USD balance and bitfinex/Kraken

USD balance coming from Bitfinex/Kraken appear as unrecognized coin, a quick fix is by adding

if (symbol == "USD") {symbol="USDT"}
to main.js ~line#20 or to the API js, but we should have some rule for USD for price_usd = 1 etc

Sheet Layout

You seem to have a very nice screeshot of your Portfolio with color rules and adapted font.

Is there any chance to have a template file ? Like a Google Sheet Template for example. I think coding this in Script Editor is not easy.

Fixes for KuCoin.js

The end of code:

...
//Logger.log(data);
var array = []; //added
  for(var x in data.data){
    var balance = parseFloat(data.data[x].balance);
    if (balance > 0) {
      var asset = data.data[x].coinType
      array.push({'currency': asset, 'balance': balance, 'market': "Kucoin"});
      //Logger.log(array);
    }
  }
  return array //moved out of 'for()'
}

Symbol exception?

Thanks for sharing guys :)

One of my holdings at Bitfinex, Streamer Data Coin (DATA), shows up in the overview as Datum (DAT) - would I need to edit the main.js script to put in an exception to rectify this? Novice coder here so unsure how to proceed.

Best regards,
D

ReferenceError: jsSHA is not defined

Hi, I am trying to get the data from Binance with google sheets, but I'm getting this error.
ReferenceError: js SHA is not defined
and the error comes from the binance_api file

Sheet showing #NUM!

Next to the Gains and Total value, it should show a percentage. But now it just shows #NUM!

Any idea?
screenshot 2018-03-19 at 15 47 12

Binance API isn't pulling all rates

I'm connected to the Binance API and the sheet updates, as expected. However, not all currencies in my account are pulling all data from Binance. For example, I have FUEL and WAN in my portfolio, and the script pulls the coin symbol name (FUEL, WAN), but no other data for that coin, including my balance, the full coin name, or trading rates. Here's a screenshot of those two rows in my sheet.

Screen Shot 2019-03-22 at 3 56 47 AM

Error 403 binance API

hello, i just tried your portfolio and i have a binance error.
It seems to me that binance has made an update.
Could this be the problem?
Capture d’écran_2021-03-16_14-06-06

The number of rows in the range must be at least 1

I already setup the files like this:
image

After this, I press Cryptos Tool/Update Porfolio and receive the following message:

Exception: The number of rows in the range must be at least 1.

I have not purchased any coins from Kraken. Is that why I am getting the error? If yes, can't I use this tool if I haven't bought coins just to do simulations?

BinanceSignature" is not defined

ReferenceError: "BinanceSignature" is not defined. (line 266, file "balance")Dismiss

function BinanceBalance () {
...
var signature = BinanceSignature (secret, postdata);

Feature request

Is there any way we can get a feature to track profit/loss on each coin?

Let's say I made 4 purchases in 1 coin. I would like to check whether my coin is in profit or loss

Kucoin.js is blank

Your other code is looking good but the kucoin code is blank.

Thanks!

Bitstamp.js

Thanks for looking at this one, I gave it a go and got the following error:

Request failed for http://www.bitstamp.net/api/v2/balance/?key=CORRECT API KEY WAS HERE &signature=LONG STRING SIGNATURE WAS HERE&nonce=1516333128 returned code 400. Truncated server response: POST Only Endpoint (use muteHttpExceptions option to examine full response)

Happy to help test this and here's my (probably terrible) string manipulation code ready to go to pull the results into an array:
function Bitstamp() {
//insert api code here
var data = JSON.parse(response.getContentText());
var json1 = JSON.stringify(data);
parseStampPrices(json1);
}

function parseStampPrices(textString ){

var stringLength = textString.length;

if(stringLength > 80){

var balanceLocation = nthIndex(textString, "balance", 1);
var feeLocation = nthIndex(textString, "fee", 1);
var coinCode = textString.substring(balanceLocation-4, balanceLocation-1);

textString = textString.substring(balanceLocation, textString.length);

var first = nthIndex(textString, "\"", 2);
var second = nthIndex(textString, "\"", 3);
var value = textString.substring(first+1, second);
value =+ value;

if(value == 0){

  textString = textString.substring(feeLocation, textString.length);
  parseStampPrices(textString);

}
else{ 
  coinCode = coinCode.toUpperCase();
  
  if(coinCode == "USD"){
    coinCode = "USDT";
  }

  textString = textString.substring(feeLocation, textString.length);   
  myArray.push({'currency': coinCode, 'balance': value, 'market': "Bitstamp"});
  parseStampPrices(textString);
}

}

}

// This method is used as part of parsing the Bitstamp info
function nthIndex(str, pat, n){
var L= str.length, i= -1;
while(n-- && i++<L){
i= str.indexOf(pat, i);
if (i < 0) break;
}
return i;
}

Kucoin API request fail (code 401)

Exception: Request failed for https://api.kucoin.com returned code 401. Truncated server response: {"code":"400004","msg":"Invalid KC-API-PASSPHRASE"} (use muteHttpExceptions option to examine full response)

I've put the key and secret in the config.

I think it's asking for API passphrase or something.

BITFINEX "apikey: invalid"

Error Message:

Exception: Request failed for https://api.bitfinex.com returned code 500. Truncated server response: ["error",10100,"apikey: invalid"] (use muteHttpExceptions option to examine full response)

Same keys is running on nodejs. No problem with keys.

Binance Error 401 - fapi request

Everytime i try to update protfolio, this error comes. Until now i´m not getting any values.

image

Exception: Error in request for https://fapi.binance.com. The following code was returned: 401. Abbreviated server response: {"code":-2015, "msg": "Invalid API-key, IP, or permissions for action, request ip: 35.187.139.65"}. Use muteHttpExceptions to read the full response.

I would really appreciate a fast help :)

Cryptopia.js not working

Hi, I get "{Error=Signature does not match request parameters., Success=false}" in the logs when I try to run the cryptopia() method.

Could it be because there is a + and an = in my secret like this:

j4Ni6YNpzp9TmcKu3dhy32HkKw7SR6lRT+BXq6D4lZiU=

These are quite common in Cryptopia sectets.

Here's the whole log:

[18-01-09 14:54:31:913 PST] mZFLkyvTelC5g8XnyQrpOw== mZFLkyvTelC5g8XnyQrpOw==
[18-01-09 14:54:31:914 PST] https%3a%2f%2fwww.cryptopia.co.nz%2fapi%2fgetbalance
[18-01-09 14:54:31:914 PST] signature b08ce14d2e9c4956ad4a2bee3ba8f4bcPOSThttps%3a%2f%2fwww.cryptopia.co.nz%2fapi%2fgetbalance1515538471mZFLkyvTelC5g8XnyQrpOw==
[18-01-09 14:54:31:995 PST] signed: qMf1ONALXtokfN50jPMHqzBv084fH+RjL+AcDzh4VtI=
[18-01-09 14:54:31:996 PST] header_value: amx b08ce14d2e9c4956ad4a2bee3ba8f4bc:qMf1ONALXtokfN50jPMHqzBv084fH+RjL+AcDzh4VtI=:1515538471
[18-01-09 14:54:32:092 PST] {Error=Signature does not match request parameters., Success=false}
[18-01-09 14:54:32:093 PST] []

Thanks.

Updated Bitfinex API

Added two coins that were missing from the the Bitfinex API, similar issue to the previous one with Bitfinex using their own naming conventions - posting here as you might want to update the master :)

`// API_Bitfinex.js V1.0
// I assume that key and secret API are in the "Config" spreadsheet. The key is in cell B26 and the secret in cell B27

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"}
if (asset=="DAT") {asset="DATA"}
if (asset=="SPK") {asset="SPANK"}
if (asset=="MNA") {asset="MANA"}
array.push({'currency': asset, 'balance': balance, 'market': "Bitfinex"})}
}

return array;
}`

Request: Telegram

This is a feature request to add Telegram functionality to send a update of your portfolio to your own Telegram bot or channel.

Like a list of coins that you want to be reminded on a regular basis.

jsSHA.js issue

First of all, thank you for sharing this with us.

I'm getting an error on line 12 (Illegal character. (line 12,) when copy pasting the jsSHA.sh in the google scripts file. Is there something special that I have to enable in order to make it work?

Cheers

Did the instruction but nothing happens

I'm looking for a simple way to look into my Binance portfolio, this project looks good, but I can't get it to work, nothing happens after I create all scripts and entered API, not sure if I doing this wrong.
I did all the step in the instruction, in the script editor, it asks me to name every script, and it auto adds .gs at the end of every files' name, like this:
screen shot 2018-02-11 at 8 11 40 pm
not sure if this cause this sheet not working, now all the numbers still are zero, please help, thanks.

sheet.addMenu

Hello,
When trying to run the function onOpen I get the error: TypeError: Cannot call method "addMenu" of null. (line 6, file "Code"). I have a spreadsheet opened with two tabs, one being Market and the other Config. Config has my API keys in B14 and 15.
Thanks.

Deposit Address

Hi,
How to get the deposit Address of that specific Coin on the Market Sheet ?
Thanks
Mouad

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.