Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import base64
- import json
- import os
- egelauth="Basic XXXXXXXXXXXX"
- egelaccountid="a63a36e4-1f7a-434a-983c-0b916bc9ecf1" #stable
- i=0
- password="t"
- urlbasis="http://stable.alpha-trader.com/"
- partnerid="XXXXXX" #stable
- headeregel={
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- auth=""
- def createuser(username):
- url = urlbasis+"user/register"
- mail=username+"@gmx.de"
- companyname="comp"+username
- querystring = {"username":username,"emailAddress":mail,"password":password}
- headers = {
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- def createcompany(companyname, username):
- url = urlbasis+"api/companies/"
- querystring = {"name":companyname,"cashDeposit":"50000"}
- headers = {
- 'authorization': auth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- print(response.text)
- def getcompanyidbyuser(username):
- url = urlbasis+"api/companies/ceo/username/"+username
- response = requests.request("GET", url, headers=headeregel)
- parsed_json = json.loads(response.text)
- companyid=parsed_json[0]['id']
- return companyid
- def employegelasceo(companyid):
- url = urlbasis+"api/polls/employceo"
- querystring = {"companyId":companyid,"dailyWage":"150"}
- response = requests.request("POST", url, headers=headeregel, params=querystring)
- url = urlbasis+"api/polls/"
- headers = {
- 'authorization': auth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("GET", url, headers=headers)
- parsed_json = json.loads(response.text)
- pollid=parsed_json[0]['id']
- print(pollid)
- url = urlbasis+"api/polls/"+pollid
- querystring = {"voices":"50000","votingType":"YES"}
- headers = {
- 'authorization': auth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- #print(response.text)
- url = urlbasis+"api/polls/execute/"+pollid
- response = requests.request("POST", url, headers=headeregel)
- def getsecurityidentifier(companyname):
- url = urlbasis+"api/search/companies/"+companyname
- headers = {
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("GET", url, headers=headers)
- parsed_json = json.loads(response.text)
- securityidentifier=parsed_json[0]['securityIdentifier']
- return securityidentifier
- def getsecurityaccount(companyname):
- url = urlbasis+"api/search/companies/"+companyname
- headers = {
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("GET", url, headers=headers)
- parsed_json = json.loads(response.text)
- securityaccount=parsed_json[0]['securitiesAccountId']
- return securityaccount
- def getcompanyidbyname(companyname):
- url = urlbasis+"api/search/companies/"+companyname
- headers = {
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("GET", url, headers=headers)
- parsed_json = json.loads(response.text)
- securityaccount=parsed_json[0]['id']
- return securityaccount
- def otcordersell(company1, company2):
- url = urlbasis+"api/securityorders/"
- querystring = {"owner":getsecurityaccount(company1),"securityIdentifier":getsecurityidentifier(company1),"action":"SELL","type":"LIMIT","price":"1","numberOfShares":"50000","counterparty":getsecurityaccount(company2)}
- headers = {
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- querystring = {"owner":getsecurityaccount(company2),"securityIdentifier":getsecurityidentifier(company1),"action":"BUY","type":"LIMIT","price":"1","numberOfShares":"50000","counterparty":getsecurityaccount(company1)}
- response = requests.request("POST", url, headers=headers, params=querystring)
- def intitiateliquidationpoll(company):
- url = urlbasis+"api/polls/liquidation"
- querystring = {"companyId":getcompanyidbyname(company)}
- headers = {
- 'authorization': egelauth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- #def acceptliquidationpoll(company)
- def sellowncompany(company, auth):
- url = urlbasis+"api/securityorders/"
- querystring = {"owner":getsecurityaccount(company),"securityIdentifier":getsecurityidentifier(company),"action":"SELL","type":"LIMIT","price":"1","numberOfShares":"50000","counterparty":""}
- headers = {
- 'authorization': auth,
- 'x-authorization': partnerid,
- 'cache-control': "no-cache",
- }
- response = requests.request("POST", url, headers=headers, params=querystring)
- def getlastpoll():
- url = urlbasis+"api/initiatedpolls/"
- response = requests.request("GET", url, headers=headeregel)
- parsed_json = json.loads(response.text)
- #print(parsed_json.lentgh())
- pollid=parsed_json[-1]['id']
- return pollid
- def votepoll (pollid):
- url = urlbasis+"api/polls/"+pollid
- querystring = {"voices":"50000","votingType":"YES"}
- response = requests.request("POST", url, headers=headeregel, params=querystring)
- def expoll (pollid):
- url = urlbasis+"api/polls/execute/"+pollid
- response = requests.request("POST", url, headers=headeregel)
- i=0
- while i<1:
- username="12345678910"+str(i)
- ag=username
- auth=username+":"+password
- auth= base64.encodestring(auth)
- auth="Basic "+auth
- auth=auth.replace('\n', '')
- createuser(username)
- createcompany(ag, username)
- print(username)
- employegelasceo(getcompanyidbyuser(username))
- otcordersell(ag, "Bender")
- intitiateliquidationpoll(ag)
- lastpoll=getlastpoll()
- votepoll(lastpoll)
- expoll(getlastpoll())
- i=i+1
- print(username)
- #employegelasceo(getcompanyidbyuser(username))
- #auth=egelauth
- #comp="Bis%20zum%20naechsten%20reset"
- #otcordersell(comp, "Bender")
- #intitiateliquidationpoll(comp)
- #getlastpoll()
- #print(getcompanyidbyname(comp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement