Determine Share Quantity at Trigger of Stop Price of a Buy Stop-Limit Order, Possible? #354
Replies: 1 comment
-
I guess another question might be, would it be possible for me to submit the 30 Buy Stop-Limit orders, where each order's quantity of shares is 1/5 of the total equity, or would that give me some kind of "not enough money" error when I tried to submit the 6th Stop-Limit order? That might be an option too if it would allow it, because upon triggering 5 of the orders, the other 25 limit orders would be cancelled off anyway so there wouldn't actually be an equity issue, but if does an equity check when submitting each order at first, than that wouldn't work. Just another thought I had... UPDATE Looking through the notebooks and the IB API documents some more, I see that there are some quicker streaming data pipelines in the |
Beta Was this translation helpful? Give feedback.
-
Here's an interesting question.
I'm developing a trading algo, and part of it is to buy at the breakout of pre-market highs. So what I had initially planned was to set Buy Stop-Limit orders where the Stop price is 1 cent above the stock's pre-market high level, and the Limit price would be 5 cents above that. The problem is, I could have as many as 30 stocks being monitored at one time, so this would thin out my equity too much, having 30 different Buy Stop-Limit orders out there. In addition, you would need to calculate your share size for each order ahead of time when you submit each Stop-Limit order, and I'll get into why I want to find a way around this in a second.
I'm also policing my strategy to only allow 5 open positions at one time, so even though there may be 30 pending Buy Stop-Limit orders waiting to be triggered, if 5 of them ARE triggered, it won't allow the other ones the be triggered (i.e. I'll cancel all other pending orders), until one of them sells its position and opens up 1 more slot for another one to potential fill, etc. The point here is, I won't know which 5 of the 30 are going to be triggered, it could be any one of them, but what I'd like is, once one of them DOES trigger, I want the position size to be 1/5 of my current equity for that order (so each of the 5 orders get an equal share of the available equity at the time of order triggering). So what I'm trying to figure out is, is there a way to dynamically determine the quantity of shares upon trigger of the Stop-Price? I don't think using Stop orders is the way to go here as I think you have to submit the order to IB servers WITH a quantity and it just sits there until its executed. I just used Stop orders in this example to help draw out what I'm after.
What I'm thinking is, does the IB API offer a Price Alert service? I didn't see anything in the documentation, but setting up some kind of
onAlertEvent
where that could trigger a Limit order would be ideal, because then, once price alert is triggered, I could send a Limit order with the appropriate number of shares upon the alert. I could just set up 30 price alerts and handle each appropriately upon alert. I know another option would be to start a stream of live market data and just set up a local price alert in my script and this might be the way I have to go, but I would rather avoid the delays in data reporting, I'd like it to be as close to real time prices as possible for faster order execution. The 5 second delay is not very attractive in the live bars function.Would love to hear some creative ideas/be pointed in the right direction of something I could try to achieve this. I love this repo! Thanks!!
Beta Was this translation helpful? Give feedback.
All reactions