Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def stacking():
- headers = {'Content-type':'application/json'}
- url = 'https://nodes.wavesplatform.com/addresses/data/3PA2w9i9GnbKR3HB7XTmwf3DnaFBFcDiP12'
- answ = requests.get(url, headers = headers)
- r = answ.json()
- slices = {i*5 - 5: i*5 for i in range(int(len(r)/5)+1)}
- slices.pop(-5)
- rawdata = []
- cleardata = []
- cleared = {}
- for t in r:
- g = t['key'].split('_')
- rawdata.append({g[1] : t['value']})
- for j in slices:
- sliced = rawdata[j:slices.get(j)]
- for i in sliced:
- cleared.update(i)
- cleardata.append(cleared)
- cleared = {}
- for l in cleardata:
- t = 2629800 * 1000
- stack, created = Stack.get_or_create(address = l['address'])
- if created:
- stack.balance = l['balance']
- if l['starttime'] > l['updatetime']:
- droptime = l['starttime'] + t
- take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
- time = l['starttime']
- else:
- droptime = l['updatetime'] + t
- take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
- time = l['updatetime']
- stack.starttime = time
- stack.droptime = droptime
- stack.drop = take
- stack.status = l['status']
- stack.save()
- else:
- if stack.status == True and l['status'] == True:
- if int(datetime.now().timestamp()*1000) > stack.droptime:
- if l['starttime'] > l['updatetime']:
- droptime = l['starttime'] + t
- take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
- time = l['starttime']
- else:
- drop = l['updatetime'] + t
- take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
- time = l['updatetime']
- stack.balance = stack.drop
- stack.droptime = droptime
- stack.drop = (stack.balance + (droptime - stack.starttime) / t * stack.balance * 0.01) / 100000
- stack.save()
- elif stack.status == False and l['status'] == True:
- stack.balance = l['balance']
- if l['starttime'] > l['updatetime']:
- droptime = l['starttime'] + t
- take = (l['balance'] + (droptime - l['starttime']) / t * l['balance'] * 0.01) / 100000
- time = l['starttime']
- else:
- droptime = l['updatetime'] + t
- take = (l['balance'] + (droptime - l['updatetime']) / t * l['balance'] * 0.01) / 100000
- time = l['updatetime']
- stack.starttime = time
- stack.droptime = droptime
- stack.drop = take
- stack.status = l['status']
- stack.save()
- elif stack.status == True and l['status'] == False:
- stack.status = False
- stack.save()
- elif stack.status == False and l['status'] == False:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement