pprint.pprint(quote) # create new dictionary object: order (means you will be placing the same size order all the time) order = { 'account': account, 'venue': venue, 'symbol': pos.ticker, 'price': 3400, 'qty': 50, 'direction': 'sell', 'orderType': 'limit' } # initialise qty pos.qty = 0 pos.cash = 0 basis = 0 while True: # GET SPREAD quote = pos.get_quote() try: bid = quote['bid'] ask = quote['ask'] except KeyError: continue # CALC PRICES FOR NEW ORDER my_bid = bid + 5