quote = pos.get_quote() try: bid = quote['bid'] ask = quote['ask'] except KeyError: continue # CALC PRICES FOR NEW ORDER my_bid = bid + 5 my_ask = ask + 5 # ------------- POST ORDERS ------------------------------- # BUY order['direction'] = 'buy' order['price'] = my_bid buy_response = pos.stock_order(order) # SELL order['direction'] = 'sell' order['price'] = my_ask sell_response = pos.stock_order(order) # ----------------------------------------------------------- # ADD ORDER IDs TO OPEN ORDER LIST # order_id = buy_response['id'] try: pos.append(buy_response['id']) pos.append(sell_response['id']) except: KeyError # UPDATE OPEN ORDERS AND POSITION