Tutorial: Get the value of your steemit earnings, Part #2 - Calculate Steem Power

In the second post of this series I added the conversation of the VESTS rewards to Steem Power.

The Mission

The requirements for the first part of this series:

  1. Get the steemit earnings (STEEM, SBD, VESTS) for an account
  2. Create a HTML and CSV report
    You can find the first part here:
    @schererf/tutorial-get-the-value-of-your-steemit-earnings-part-1

The requirements for this second part:

  1. Calculate the Steem Power (SP) for the VESTS reward

System Requirements

nodeJS

As the runtime system for the program I used "nodeJS" (LTS version).
You can download nodeJS here: https://nodejs.org

Implementation

git repository

You can download the complete sources of this tutorial from my GitHub repository:
https://github.com/SchererF/steemit-earnings

calculation of Steem Power

The Steem Power is calculated using the following formula:

total_vesting_fund_steem * (user's vesting_shares / total_vesting_shares)



Thanks to @lantto:
@lantto/how-to-calculate-steem-power-using-the-api

using steemd data

To calculate the Steem Power of VESTS reward, we need historical data for total_vesting_fund_steem and total_vesting_shares. The only way I found to get this historical data is provided by @jesta. He creates snapshots of steemd data on a regular base.

Thanks to @jesta:
@jesta/jesta-witness-update-2016-09-02

The data are provided under this URL:
https://steemdb.com/api/props

        var url='https://steemdb.com/api/props';
        console.log( 'loading data from "' + url + '"');
        return fetch(url
            ).then((response) => response.json()
            ).then((data) => steemdApiPropsData = data);



Get the timestamp of an single item

var date = new Date(parseInt(steemdApiPropsDataItem.time.$date.$numberLong));


Calculate the steem_per_mvests value

steem_per_mvests = steemdApiPropsDataItem.total_vesting_fund_steem * 1000000 / steemdApiPropsDataItem.total_vesting_shares;

Example

time.$date.$numberLong 1515871554000 (GMT: Saturday, January 13, 2018 7:25:54 PM)
total_vesting_fund_steem 199304254.488
total_vesting_shares 408153245669.0034
steem_per_vests 0.000488307 = 199304254.488 / 408153245669.0034

small deviations

Unfortunately, there are small deviations in the comma range for the calculated Steem Power values compared to those in the wallet. Personally, I can live with this small deviations, but if you know a solution to this problem, I would appreciate a hint.

Let's do it

Please have a look at the first post of this series if you want to know how to download, install and run this program.
@schererf/tutorial-get-the-value-of-your-steemit-earnings-part-1

Take a look at the output HTML

The created HTML now includes the values for steem_per_mvests and SP values.

Tutorial Preview

In the next parts of this little series add the STEEM and SBD earnings as EUR/USD based on the historical exchange rate of the reward claim date.

Note

This tool can simply be used for your personal interests or of course to create a template for reporting your steemit earnings for a financial office (as we need it in Germany for the tax office).

The created report is of course not an official document. It is just an idea on how to report your earnings!

Please give me feedback if this tutorial was helpful for you.

Thanks for reading and watching,
@schererf

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
20 Comments