A program to calculate the real worth of your steemit account (with tutorial)

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@hmushtaq·
0.000 HBD
A program to calculate the real worth of your steemit account (with tutorial)
In one of my recent posts (https://steemit.com/steemit/@hmushtaq/how-to-calculate-steem-power-from-vests), I showed how one can find the STEEM power of an account, using VESTS. This is useful when you want to progammatically find out the value of STEEM power of an account.

This is exactly, what I've done in this program that I've written (https://github.com/HamidMushtaq/steemtools/blob/master/steemaccworthcalc.py), which gives the total worth of your steemit account in BTC and the  currency of your choice. Moreover, it also shows the current prices of STEEM, SBD and BTC. Furthermore, it shows the value of _steem_per_mvests_, which is necessary to find STEEM power from VESTS. 

Note that the account worth shown in your Steemit wallet, is not your real account worth, as was discussed by @jbn in his post https://steemit.com/steem/@jbn/your-estimated-account-value-is-way-more-than-you-think-it-is-everything-about-steem-wallet-value. On the other hand, this program gives the exact current value of your Steemit account.

### How to use the program
Before explaining how this program works, let me show you how to use it. The program takes 2 arguments. The first argument being the username and the second argument being the currency (For example, _usd_ and _eur_). The program can also run with just one argument. In that case, it will use _usd_ as the currency. Moreover, if you don't give it any argument, it would ask for the username. Note that at the moment, the program only runs with Python 2.7. For Python 3, I would need to make slight modifications. Given is an example run of the code.

![image.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1519568422/n7dvk73rue1yrlgjfxsd.png)

If you know Python, this program is pretty straightforward to understand. The main functionality is in the functions _get_steem_per_mvests_,  _get_btc_price_, _get_sbd_price_in_btc_, _get_steem_price_in_btc_ and _get_user_data_. The code in the main body is just simple calculations and printing. So, let us discuss how the aforementioned functions work.

### 1. get_steem_per_mvests
In this function, we get the content of the https://steemd.com/ page, using the _urllib_ library. Then from the content, we see the line which has _steem_per_mvests_ in it. In the same line, its value is found as well, which we extract out using a simple regular expression. You can checkout https://www.tutorialspoint.com/python/python_reg_expressions.htm to learn more about how to use regular expressions in Python.

### 2. get_btc_price
The price of BTC in the given currency can be found out by using Coinmarketcap's REST api. For example, to find the value of BTC in euros, the following request string is sent.

    https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=eur

As a result, we get a json output, which also contains the field _price_eur_, whose value is then returned by this function.

### 3. get_sbd_price_in_btc & get_steem_price_in_btc
These functions are very similar to the _get_btc_price_ function, as they also use the Coinmarketcap's REST api to get the value of STEEM and SBD in the form of BTC.

### 4. get_user_data
Here, we use Steemit's REST api to get information about the user. We provide the username in the json input, and as a result we get quite detailed information about the user in json form. From that output, we are only interested in the value of STEEM, VESTS and SBD that the user possesses, which are then returned by this function. Later on in the program, I use the formula described in my post https://steemit.com/steemit/@hmushtaq/how-to-calculate-steem-power-from-vests, to convert VESTS to STEEM power.
___
I hope you liked this article and that you learned useful things by going through this code. Moreover, I hope that you would found this program useful for keeping up to date with the prices of STEEM, SBD and BTC and for finding the real total worth of your Steemit account.
 
<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@hmushtaq/a-program-to-calculate-the-real-worth-of-your-steemit-account-with-tutorial">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍 , , , , , , , , , , , , , ,