Reduce sleep duration and optimize share emission and purchase logic; add .gitignore for virtual environment

This commit is contained in:
Lukian 2025-01-18 21:36:48 +01:00
parent 05c9f5226e
commit df6417e3ea
3 changed files with 8 additions and 9 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
.venv

View file

@ -43,10 +43,9 @@ if __name__ == "__main__":
while True: while True:
companies = getCompanies() companies = getCompanies()
for company in companies: price = randint(20, 2000)
price = randint(20, 2000) for i in range(randint(0, 4)):
for i in range(randint(0, 10)): emitShare(randint(0, len(companies) - 1), price)
emitShare(company["id"], price)
sleep(30) sleep(4)

View file

@ -59,9 +59,8 @@ if __name__ == "__main__":
shareholders = getAllBuyers() shareholders = getAllBuyers()
shares = getAllShares() shares = getAllShares()
for shareholder in shareholders: shareId = randint(0, len(shares) - 1)
shareId = randint(0, len(shares) - 1) buyShare(randint(0, len(shareholders) - 1), shareId, shares[shareId]["price"] + randint(-20, 20))
buyShare(shareholder["id"], shareId, shares[shareId]["price"] + randint(-20, 20))
sleep(30) sleep(4)