totalNetWorthStart = getTotalNetWorth() while True: var = urllib.request.urlopen('https://api.bitfinex.com/v1/pubticker/btcusd') html = var.read() bitfinexBtcusd = (json.loads(html)) db.store(bitfinexBtcusd ['mid'], bitfinexBtcusd ['bid'],bitfinexBtcusd ['ask'], bitfinexBtcusd ['last_price'], bitfinexBtcusd ['low'], bitfinexBtcusd ['high'], bitfinexBtcusd ['volume'], bitfinexBtcusd ['timestamp']) currentPrice = getSellPrice() print ('old;',oldPrice,'currentPrice;',currentPrice) if currentPrice > oldPrice and walletBitcoin > 0: print ("sell") walletBitcoin = walletBitcoin - 1 cash_wallet.collect(currentPrice) cash_wallet.give(getTransectionfee()) elif currentPrice < oldPrice and cash_wallet.cash > 0: print ("buy") walletBitcoin = walletBitcoin + 1 cash_wallet.give(currentPrice) cash_wallet.give(getTransectionfee()) showTotalNetWorth() oldPrice = currentPrice time.sleep(config['simulator']['seconds_between_refresh'])