Regular balance recording with Binance (Future and Spot)

Last update: October, 12, 2021

  • Fixed bug with currencies in USDT
  • The balance amount is calculated according to USDT+BUSDT
  • The balance amount is calculated according to USDT+BUSDT: here

To update the script, upload a new script code, fill in the Keys fields (it is possible to specify your own keys for each type), if they match, just duplicate, create a USDT_F sheet, fill in the «Initial balance» fields and put Yes / No where necessary.

Script description

This is a simple script that takes data about the balance on your wallet on a schedule and writes the data to a table. Convenient if you trade with a bot, or just make a lot of transactions:

Report table view

At the moment, the script processes information on BTC and BNB coins from the Coin-M Futures account, Futures USDT and Spot data, and also, if desired, makes a summary report on BTC and BNB for Coin-M.

First, create separate reading keys for yourself so that there are no questions later. The script simply requests information about the balance on the wallet and open positions.
All you need is a key and a secret key (if you have both SPOT and FUTURE on the same account, write the same de key and secret key, if different, write your own to each).

We go to google docs and create a blank table and create the necessary sheets: BTC, BNB, Sum_Info, SPOT and USDT_F.

Required sheets for the reportDo not write the title, their script will do it by itself. Of course, if you plan to work only with BTC or you do not need a summary report, you can not do these sheets.

Now we need to open the script editor. It is located in the Tools — >Script Editor menu.

Opening the script editor

A script editor will open for you to paste the code. First, give the script some name that you can understand (it does not affect anything), just so that there is no “Project without a name”, name, for example, Binance Script.
Delete what is there and paste this code .

You need to fill in the first three lines of data. Key and secret key from Binance, as well as your table id. You can see it in the url. Just switch to google spreadsheet. The address looks like:
Here is what is between /spreadsheets/d/ and /edit#gid=0 and there is the piece you need. Copy it and paste it into the third parameter (be careful, you don’t need to copy the slashes, so: «1Ftff9GRh1DCpJJ7sQkkr-XsaJD4AB_Cw99kllUcr-8A»).

Below are the coin settings. By default, both coins and the pivot are enabled. If, for example, you trade only BTC, then remove Yes in BNB and Sum_info. Same with Spot.
Also, you can specify your initial balance, and then there will be an additional 2 columns: the difference with the initial balance, and % change with the initial balance.
For example, you can set the initial balance every first number. If set to 0, the columns will not be displayed/updated.

Optionally, you can change the time zone in the GTM_TIME=»GMT+3:00″ variable.

The summary report only works if both coins are included (Spot does not go here, this is only for Futures).

It will come out like this:

Script settings

Everything, the script is ready. Check out his work. To do this, run the Run_Me function:

Function run

Permission is required on first launch. Click grant access, select your account where the document is located, and then in the scary red warning, click Advanced settings and then click on the link «Go to the page «Binance coinM» (not secure)»:

Script authorization

Don’t be afraid, it’s just that Google is warning you that some script that Google hasn’t checked yet is trying to perform an operation on a document on your disk. Well, that’s what we want.

Everything should work out, go to your table, the first row with data should appear there. You can do it again — and the second line will appear.

And the final touch is to set up the automatic launch of the script. To do this, go to Triggers in the left menu:

Script triggers

Click the Add Trigger button and select the desired settings. Function -Run_Me, Main deployment, in the third paragraph, select Trigger by time, then by hour, and then how often you want the data to be updated, for example, every 4 or 6 hours. As a result, it will turn out like this (what needs to be changed is highlighted in red. We do not touch the rest):

Setting up a script trigger

That’s all. After the selected period of time, the first launch will be.
I hope it will be useful.
By the way, based on this table, you can build any other report of yours in the next sheet using formulas. Remove unnecessary columns, swap them, add new ones …

Leave feedback in the comments or email:

Binance balance statistics (en)

Добавить комментарий

Ваш адрес email не будет опубликован.