Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functions import *
- def sellStocks(auth, ag):
- securityAccount=getSecurityAccount(ag)
- portfolio=getPortfolio(securityAccount)
- n=0
- while n<len(portfolio['positions']):
- securityIdentifier=portfolio['positions'][i]['securityIdentifier']
- askPrice=portfolio['positions'][i]['currentAskPrice']
- print(securityIdentifier)
- sell=0
- price=0
- if portfolio['positions'][i]['currentAskPrice'] is None and securityIdentifier.startswith("ST"):
- if portfolio['positions'][i]['currentBidPrice'] is None:
- price=portfolio['positions'][i]['lastPrice']['value']
- print("last")
- print(price)
- else:
- price=portfolio['positions'][i]['currentBidPrice']*0.99
- price=str(price)
- print("bid")
- sell=1
- elif securityIdentifier.startswith("ST"):
- price=portfolio['positions'][i]['currentAskPrice']
- price=float(price)
- count=portfolio['positions'][i]['numberOfShares']
- price=round(price, 2)
- if sell==1:
- sellSecurity(securityIdentifier, securityAccount, count, price, auth)
- output="SELL "+str(count)+" "+str(securityIdentifier)+" with "+str(securityAccount)+" for "+str(price)
- print(output)
- n=n+1
- allBonds=getAllBonds()
- i=0
- usernames=loadUsers(bondbuyerfile)
- password="plBL7r4aiU"
- while i<len(allBonds):
- cash=getCash(allBonds[i]['issuer']['listing']['name'])
- faceValue=allBonds[i]['faceValue']
- volume=allBonds[i]['volume']
- timestamp = int(time.time())
- maturityDate=int(allBonds[i]['maturityDate']/1000)
- securityIdentifier=allBonds[i]['listing']['securityIdentifier']
- if cash<volume*faceValue and maturityDate-timestamp<90000:
- a=randint(0,2)
- username=usernames[a]['user']
- ag=usernames[a]['ag']
- auth=authGen(username, password)
- if getCash(ag)-getCommitedCash(ag)<10000:
- deleteAllOrders(getSecurityAccount(ag), auth)
- volume=getCash(ag)-getCommitedCash(ag)
- price=100
- if allBonds[i]['priceSpread']['askPrice'] is None:
- price=100+allBonds[i]['interestRate']
- else:
- price=allBonds[i]['priceSpread']['askPrice']
- count=volume/(faceValue*price)
- count=count*100
- count=int(count)
- price=round(price, 4)
- buySecurity(securityIdentifier, getSecurityAccount(ag), count, price, auth)
- sellStocks(auth, ag)
- i=i+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement