Open position with stop loss and take profit

Hi. I’m using Python and trying to open a position when the market opens. But I’m finding it hard to set the take profit and stop loss. Let’s say I’m trying to set the take profit at 5% and the stop loss also and 5%. But to be able to set the stop loss and take profit I need to know the price at which I opened the position. Which I don’t know because the position is yet not opened.

So, I could obtain the ask price and immediately open the position using that price to set the stop loss and take profit. But I 'm not able to find how to obtain the ask price. Any guidance? Thanks.