Stop Order on Current Market price

I want to just Stop an order at the current market price.

Could someone give me an example please. I do not want to put a limit on the Stop, i just want to execute a python statement on the current selling price please

Regards

Rob

@RobDineen I can give an example for placing a stop order. However, a couple of things 1) one cannot set the ‘current market price’ as the stop price. That would imply the order would trigger immediately. Since stop orders are really intended as a ‘stop loss’ the stop price must be lower than the latest market price, and for a sell stop order, must be lower than the current bid price. Otherwise the order would trigger immediately. If not, the order would be rejected.

Secondly, it was stated 2) “I just want to execute a python statement on the current selling price” You probably realize this, but there is not any way to guarantee an order will execute at a specific price unless it is a limit order. If one places a sell market order it will generally fill at the current bid price BUT that is not guaranteed. Stocks don’t really have ‘prices’ (like on Amazon). A market sell order fills at the highest price someone bids for it. If you do not want to place a limit order (which may not always fill) then place a simple market order. Another option is to place a ‘marketable sell limit order’. Set the limit price below the current bid price. It typically will fill immediately at the bid price (like a market order), but has the benefit of never executing below your limit price.

Hi @Dan_Whitnable_Alpaca

thank you for your reply. setting a take profit limit. but just adding the profit you want ie

MarketPrice + 0.20 see example below. The bid amount is a variable i have created. could i dyamically set the limit as above (MarketPrice + 0.20) ???

Kind Regards

Rob

api.submit_order(
symbol=Trade,
qty=quantity_purchased,
side=‘buy’,
type=‘market’,
time_in_force=‘gtc’,
take_profit={‘limit_price’: BidAmount + 0.20}

                )

You have to fetch the current price and add the desired profit, e.g. with using StockBarsRequest or StockLatestQuoteRequest.

Thank you for your reply

this is what i am currently doing.

request_params = StockLatestQuoteRequest(symbol_or_symbols=[str(Trade)],
timeframe=TimeFrame.Minute
)

                quotes = client.get_stock_latest_quote(request_params)

                MarketPrices = pd.DataFrame(quotes.values())

                BidAmount = str(MarketPrices.iloc[0, 3])
                AskAmount = str(MarketPrices.iloc[0, 6])

how do you know to use the Bid Price or the Ask Price when setting the take profit limit.?

This is the spread, I would take the average for calculation of the TP limit.

What i mean is,
sometimes the trade price is the Bid price, and other times the price is the ask price.
Is there a why to workout what the price is using on the Trade. Ie Ask or Bid.?

Maybe just use the last close price from StockBarsRequest,

@RobDineen You asked

sometimes the trade price is the Bid price, and other times the price is the ask price.
Is there a why to workout what the price is using on the Trade. Ie Ask or Bid.?

A ‘bid’ is simply an open limit buy order which someone has placed. A ‘ask’ is simply an open limit sell order which someone has placed. The quotes which Alpaca displays are NBBO quotes and are the best reported/displayed limit orders across all trading venues. When a market order is submitted, you can think of it as being ‘matched’ to one of these limit orders (a market buy is ‘matched’ to a limit sell, and a market sell is ‘matched’ to a limit buy). Technically, orders aren’t usually physically paired like this but this is the net effect. This is the reason market buy orders generally fill at the ‘ask’ price and market sell orders fill at the ‘bid’ price.

If the question was referring to an historical trade, and asking if that trade was driven by a market buy or sell, and therefore did it trade at the bid or the ask, there isn’t any positive way to determine that.