Trying to get mid-point pricing data

Hello, I’m just trying to figure out how to get a fair entry or exit limit price…My code is below…a lot of time I’m getting bid prices that are above the ask prices…which doesn’t make sense…any ideas? Thanks in advance!

def get_mid_price(symbol):
pricing = get_last_quote(symbol)
bid = pricing[‘last’][‘bidprice’]
ask = pricing[‘last’][‘askprice’]
return (bid + ask) / 2
return None

The get last quote function is basically just (where the url is just alpaca’s endpoint: STOCKS_URL = “{}/v1/last_quote/stocks/”.format(DATA_URL):

r = requests.get(STOCKS_URL + ticker, headers=HEADERS)