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

in #utopian-io8 years ago (edited)

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

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.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Very good program about calculate steemit . Also you did nice analysis . It is very useful for steemit user.

Thanks :)

It's my pleasure . And i would like to invite in my blog

Great contribution sir. You did a great work sharing it with us easily, I might decide to turn a programmer some day.

Your contribution cannot be approved because it does not follow the Utopian Rules.

  • self made repository. This is not valid.

You can contact us on Discord.
[utopian-moderator]

You got a 2.05% upvote from @upmyvote courtesy of @hmushtaq!
If you believe this post is spam or abuse, please report it to our Discord #abuse channel.

If you want to support our Curation Digest or our Spam & Abuse prevention efforts, please vote @themarkymark as witness.

As a follower of @followforupvotes this post has been randomly selected and upvoted! Enjoy your upvote and have a great day!