Limit order for long-short example


I am a newbie here. Does anyone know how I can change from market order to limit order using the long-short example available on github?

self.alpaca.submit_order(stock, qty, side, “market”, “day”)

I would like to replace above with something like:
self.alpaca.submit_order(stock, qty, side, “limit”, “day”, float(position.avg_entry_price) )

The problem is that the limit price is an array derived from another loop above the order submission function and has different prices for each stock in the portfolio. I have a feeling that it will require that I define a new function to get these prices onto an array, appending it to a variable outside the function and use it in the submit order. I don’t seem to get a head-start on this. Somebody help!

1 Like