Advertisement
1zzy

Untitled

Jan 19th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.29 KB | None | 0 0
  1. def stacking():
  2.     headers = {'Content-type':'application/json'}
  3.     url = 'https://nodes.wavesplatform.com/addresses/data/3PA2w9i9GnbKR3HB7XTmwf3DnaFBFcDiP12'
  4.     answ = requests.get(url, headers = headers)
  5.     r = answ.json()
  6.     slices = {i*5 - 5: i*5 for i in range(int(len(r)/5)+1)}
  7.     slices.pop(-5)
  8.     rawdata = []
  9.     cleardata = []
  10.     cleared = {}
  11.     for t in r:
  12.         g = t['key'].split('_')
  13.         rawdata.append({g[1] : t['value']})
  14.     for j in slices:
  15.         sliced = rawdata[j:slices.get(j)]
  16.         for i in sliced:
  17.            cleared.update(i)
  18.         cleardata.append(cleared)
  19.         cleared = {}
  20.     for l in cleardata:
  21.         t = 2629800 * 1000
  22.         stack, created = Stack.get_or_create(address = l['address'])
  23.         if created:
  24.             stack.balance = l['balance']
  25.             if l['starttime'] > l['updatetime']:
  26.                 droptime = l['starttime'] + t
  27.                 take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
  28.                 time = l['starttime']
  29.             else:
  30.                 droptime = l['updatetime'] + t
  31.                 take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
  32.                 time = l['updatetime']
  33.             stack.starttime = time
  34.             stack.droptime = droptime
  35.             stack.drop = take
  36.             stack.status = l['status']
  37.             stack.save()
  38.         else:
  39.             if stack.status == True and l['status'] == True:
  40.                 if int(datetime.now().timestamp()*1000) > stack.droptime:
  41.                     if l['starttime'] > l['updatetime']:
  42.                         droptime = l['starttime'] + t
  43.                         take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
  44.                         time = l['starttime']
  45.                     else:
  46.                         drop = l['updatetime'] + t
  47.                         take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
  48.                         time = l['updatetime']
  49.                     stack.balance = stack.drop
  50.                     stack.droptime = droptime
  51.                     stack.drop = (stack.balance + (droptime - stack.starttime) / t * stack.balance * 0.01) / 100000
  52.                     stack.save()
  53.             elif stack.status == False and l['status'] == True:
  54.                 stack.balance = l['balance']
  55.                 if l['starttime'] > l['updatetime']:
  56.                     droptime = l['starttime'] + t
  57.                     take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
  58.                     time = l['starttime']
  59.                 else:
  60.                     droptime = l['updatetime'] + t
  61.                     take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
  62.                     time = l['updatetime']
  63.                 stack.starttime = time
  64.                 stack.droptime = droptime
  65.                 stack.drop = take
  66.                 stack.status = l['status']
  67.                 stack.save()
  68.             elif stack.status == True and l['status'] == False:
  69.                 stack.status = False
  70.                 stack.save()
  71.             elif stack.status == False and l['status'] == False:
  72.                 pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement