balance = 1.0 # amount of reserve tokens supply = 1000.0 # amount of smart tokens crr = 0.001 # arbitrary reserve ratio def printInfo(): price = computePrice() print "balance", balance, "supply", supply, "price", price def computePrice(): return balance / (supply * crr) print "Initial price", computePrice() # keep buying i = 0 while True: # debug if i % 10000 == 0: printInfo() import time time.sleep(0.1) i+=1 # how much to purchase: 1.0 reserve token purchase = 1.0 price = computePrice() balance += purchase supply += purchase / price