Loyalty and Influence Index - LnI by ActnEarn

in #actnearn6 years ago (edited)

Introduction

ActnEarn rewards those who support actnearn initiatives on the ground. Currently we are mostly promoting steem blockchain related content from inside and outside. We have seen good growth and involvement of the steemians who are supporting us. As the participants are increasing -it is important that we develop a transparent and fair system that rewards the participants.

In order to respond to that need we have developed Loyalty and Influence Index. Below are the details how it is computed and used to reward with increasingly higher upvote weight to loyal participants

Scope

  • Contributions to last seven posts are used

Loyalty Index - LI

  • number of posts action contributed to by an steemin account/ number of posts

Influence Index - II

  • Total upvote value in steem against all the contributions by an steemian account/Largest Total upvote value in steem against all the contributions by an steemian account

LnI Index

  • LnI Index = II*LI

Example

  • Suppose an account took action against one post out of seven. Then the loyalty index will be 1/7=0.142.
  • This account shared on twitter and facebook. And depending on his/her followers actnearn gave total rewards of 1 steem. And let us assume maximum rewards earned by any other participant account against these posts is 3 steem. Then the influence index of this participant will be 1/3=0.33
  • So the LnI index for this account = 0.33*0.5=0.165

Effective Upvote Weight

  • If account contributed to minimum one post in last 7 then the upvote weight = min(LnI x UpvoteWeight x 0.1+ LI x UpvoteWeight,100). That means if a doer is not acting on each post then despite of his/her large influence the upvote weight will reduce significantly
  • If not then the upvote weight=UpvoteWeight*(1/7)

UpvoteWeight

  • 100 if your followers are >=5000
  • 75 if your followers are >=2500
  • 50 if your followers are >=1000
  • 25 if your followers are >=250
  • 15 if your followers are >=100
  • 10 if your followers are >=50
  • 5 Token Upvote

We have developed the python code to do above computations.

Note- This post is primarily to use as reference in future and for development purpose. However, we will upvote if anyone contributes to increase its visibility.

from datetime import datetime
import time
import math
from steem import Steem
from steem.converter import Converter
from datetime import timedelta
from contextlib import suppress
from steem.account import Account
from steem.account import Amount
from steem.post import Post
from steem.blog import Blog
import csv
from beem.account import Account
from beem.comment import Comment

c = Converter()
nodes=['https://api.steemit.com']
#nodes=["https://api.steemitstage.com"]
keys=[post', 'active'] ## Keys to be provided

s = Steem(nodes,keys)

def rewardshare():
    reward_fund = s.get_reward_fund()
    reward_balance = reward_fund["reward_balance"]  
    reward_fund = s.get_reward_fund()
    recent_claims = reward_fund["recent_claims"]   
    reward_fund = s.get_reward_fund()
    recent_claims = reward_fund["recent_claims"]   
    reward_fund = s.get_reward_fund()
    recent_claims = reward_fund["recent_claims"]
    reward_balance = Amount(reward_fund["reward_balance"]).amount
    reward_share = reward_balance / float(recent_claims)    
    #price_of_steem = Amount(s.get_current_median_history_price()["base"]).amount 
    return reward_share

def getReplyRewards(v,reward_share):     
    total_rshares = int(v['rshares']) 
    post_value_in_steem = total_rshares * reward_share
    print("Post Rewards in Steem   : ", post_value_in_steem)
    return post_value_in_steem;
def lni():  #loyalty and influence
    from_account="actnearn"             
    b = Blog(from_account) 
    number_of_posts=7    
    posts = b.take(number_of_posts)    
    print(posts) 
    athr=[]
    rewrd=[]
    loyl=[]    
    reward_share=rewardshare()
    postcount=0
    for pst in posts:  
        postcount=postcount+1
        p=str(pst)
        p=p.replace("<","")
        p=p.replace(">","")
        p=p.replace("Post-"+from_account+"/","") 
        message = p
        replies=s.get_content_replies(from_account,message) 
        for i in range(len(replies)-1): 
            if "twitter.com" in replies[i]["body"] or "facebook.com" in replies[i]["body"] or "linkedin.com" in replies[i]["body"] or "plus.google.com" in replies[i]["body"]: 
                author=replies[i]["author"]
                print("&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&")
                print(author)                
                identifier = ('@'+author+'/'+replies[i]["permlink"])             
                cmnt=Comment(identifier)
                upvoted=0
                for v in cmnt['active_votes']: 
                    voter=v.get('voter')
                    if voter=="actnearn" and upvoted==0:
                        replyreward=getReplyRewards(v,reward_share)
                        upvoted=1
                        print(voter)
                        print("already upvoted by @actnearn")
                        athr.append(author)
                        rewrd.append(replyreward)
                        loyl.append(postcount)
                if upvoted==0:
                    print("upvote by @actnearn after validating")
                    print("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
    print(athr)
    print(rewrd)
    print(loyl)
    zipped = zip(athr, rewrd,loyl)
    zipps=sorted(zipped)
    athr, rewrd,loyl = zip(*zipps)
    print(athr)
    print(rewrd)
    print(loyl)
    athrfin=[]  
    rewdfin=[]
    loylfin=[]
    
    k=0
    while k < (len(athr)-1):    
        rwd=rewrd[k]
        ath=athr[k] 
        lyl=loyl[k]
        k=k+1
        postn=1
        while ath == athr[k] and k<=len(athr)-2:            
            rwd=rwd+rewrd[k] 
            if lyl==loyl[k]:
                postn=postn
            else:
                postn=postn+1
                lyl=loyl[k]
            k=k+1
        athrfin.append(ath)
        rewdfin.append(rwd)
        loylfin.append(postn)
    print(athrfin)
    print(rewdfin)
    print(loylfin)   
    doers=len(athrfin)
    lnii = [[0 for x in range(3)] for y in range(doers)] 
    for j in range(doers):
        LI=min(postcount,loylfin[j])/postcount ## in case old post is upvoted during new post
        II=rewdfin[j]/(max(rewdfin))
        lnii[j][0]=athrfin[j]
        lnii[j][1]=LI*II
        lnii[j][2]=LI
    print(lnii)   
    with open('lnii.csv',  "w") as f:
        writer = csv.writer(f, delimiter=',', lineterminator='\n')
        writer.writerows(lnii)
    return
Sort:  

https://www.facebook.com/vulturespick/?hc_ref=ARTP4_0jqkDEUYyJJ-rzUIiUnw6S5UbxKoFO5SybRYaq5IijBg-TVqrQo4PtXW7PQNE&fref=nf&xts[0]=68.ARA3xRIUCHog3GMOFP1jguhD0oO81iTBjo6dfzm61DCWkqw2XzV_iPOOTOBVvNR-XHpePExidziUqRO2EYRV_at8UmWmvB4YULj0c85BwHQtRSKAxdak1JJ9b6JbYvAmMsVUW64&tn=kC-R

@actnearn here is facebook shared link
https://www.facebook.com/vikas.goel.758/posts/10214979984667007?xts[0]=68.ARAMWZmnclRLx7JuQ4amQK2UfUQdFfGoKdolkX7_KYjvGtFI_7VPSpqIwcDuJebilbVlHuLs9bRQtHdUu0ZKkKk__9eHavsXAbwryQefGu5z3WAbo_7Vx0hvIR5Q1oDX05rNXUk&tn=-R

Now our facebook page is working and you can share from there.

@actnearn Thanx. Just now I have shared through your facebook link as well. here is the link for that
https://www.facebook.com/vikas.goel.758/posts/10214982351286171?xts[0]=68.ARBPZATjhUMRJu_0P4FNrcqx_VB2jVnaveZt_MvHXOq01xDYwgSEmA6_Zk5fLWkr1i99D54jQ0mZEcep45sxTULffx7_3Ktw93aDizuC-6zct9k9aoDqdvVQTKqrVbb059UMwCw&tn=-R

Coin Marketplace

STEEM 0.22
TRX 0.24
JST 0.038
BTC 94692.02
ETH 3236.92
USDT 1.00
SBD 3.29