¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io
Date

Does option combo guarantee full execution of leg ratios?

 

I want to create a limit order for a BAG contract consisting of 2 SPX option legs. Each contract leg would have a ratio of 5. Order total quantity is 1. Is it guaranteed that this order will only be executed fully, meaning 2x5=10 options, or does it only ensure proportions of each leg, so something like partial fill with only 1 option of each leg is possible?


Re: Why is this order invalid and rejected?

 

On Wed, Sep 8, 2021 at 09:08 PM, @jiamin wrote:
Does this "read-only" look reasonable?
Does this "read-only" task look reasonable?


Re: Why is this order invalid and rejected?

 

I know what I am doing. Thanks for checking with me.?

Now with the API,? I am just in "read-only" mode.? And the current task is to read out the margin report of my portfolio, namely the maintenance margin of each symbol.? ?If you are familiar with the margin report provided by interactive broker,?? this is what I want to get, programatically.? And if's not possible, I want to get an approximation.? Does this "read-only" look reasonable?


Re: Why is this order invalid and rejected?

 

Honestly I think you may want to zoom out, you are fixated on a particular solution that might not even really solve your problem.?? Can you explain more about your strategy and why you need those orders in the first place?

Options are a very slippery slope and you should definitely tread carefully... if you don't know what you're doing you really should go learn first before playing with the API.


On Wed, Sep 8, 2021 at 6:13 AM <groups@...> wrote:
The central question, I want to know the maintenance margin impact of this order.?

There are obviously multiple ways to separate this non-standard combo.? So the question is Which way to separate this combo into standard combos so that the question in the first line can be solved.? ?Can you provide some answers in this case? More specially?
-- What will be your way to separate into smaller combos? For example,? into calls and puts
-- and how to combine the maintenance? margin of smaller combos? For example, add?


Re: Why is this order invalid and rejected?

 

The central question, I want to know the maintenance margin impact of this order.?

There are obviously multiple ways to separate this non-standard combo.? So the question is Which way to separate this combo into standard combos so that the question in the first line can be solved.? ?Can you provide some answers in this case? More specially?
-- What will be your way to separate into smaller combos? For example,? into calls and puts
-- and how to combine the maintenance? margin of smaller combos? For example, add?


Re: Why is this order invalid and rejected?

 

On Tue, Sep 7, 2021 at 01:10 PM, @jiamin wrote:
Thanks for the reply.? I am thinking about how to decouple the combo, get the margin of smaller pieces and aggregate them together.? Should I always split into calls and puts and stocks and add them together?? or split into long positions and short positions and take the maximum?? I cannot sort my head clear how should the "splitting" logic work so that I can implement them.?
You need to separate them into standard combos.. if you don't know what those are, I'd suggest you go take an options course.. and well, you probably shouldn't be trading options if you don't already know the basics for options and margining.? Or more accurately, IB should not be allowing you to trade options if you haven't proven competence already.


Re: Spotty historical bars for TICK-AMEX and other indexes

 

Thank you, it was actually a bug in my program.? I'll stick to that request format though.??


Re: TagValue Implementation, Java, Q: HistoricalData

 

Well, I did look at the code when you made the repository public and felt that my last post said it all:

  • Requests for historical data currently do not utilize Tag/Value parameters
  • That may change in the future, but for now you simply send and empty list (just like you do already)

No need to pay for that answer.

´³¨¹°ù²µ±ð²Ô


Re: TagValue Implementation, Java, Q: HistoricalData

 

Hi All,

Any takers?? Provided code is posted here and for public use, I willing to pay 200USD.? Just need starter inspiration.. couple of lines.? no rush.? I am guessing need the codes here... [3 places]

Main.java
public static void main(String[] args)
public static void HistoricalData_MainOPERATIONS


EWrapper_Implementation.java
EWrapper_Implementation


Thank you,
best
Rv


Re: Spotty historical bars for TICK-AMEX and other indexes

 

That should work, according to the documentation. At least if your TWS is using a US time zone.

Why don't you try "20210904 00:00:00 US/Eastern", that we use:

  • We found that 00:00:00 on the day following the end date works more reliably than 23:59:59 on end date.
  • We found that it is more convenient and more reliable when the instrument's native time zone is appended (from the contract object). That reduces confusion especially when the "end of day" is involved and works well regardless of the of TWS time zone.
  • And finally, we use dateFormat = 2 to be independent from the TWS time zone. That way you get a time stamp in seconds (which is always in GMT by definition) instead of a structured date/time format.

The value of useRTH makes no difference for TICK-AMEX since the contract indicates the exact same time frames of 06:00 through 20:00 Eastern for tradingHours and liquidHours.

´³¨¹°ù²µ±ð²Ô


On Tue, Sep 7, 2021 at 01:24 PM, <nshale2@...> wrote:
Actually the exact string for endDateTime is?"20210903 23:59:59" with no timezone specified.


Re: Spotty historical bars for TICK-AMEX and other indexes

 

Actually the exact string for endDateTime is?"20210903 23:59:59" with no timezone specified.


Re: Spotty historical bars for TICK-AMEX and other indexes

 

Thank you.? I am using:

endDateTime =?"2021-09-03"
durationString = "1 D"
barSizeSetting = "1 min"
whatToShow = "TRADES"
useRTH = 1
formatDate = 1
keepUpToDate = False
chartOptions = []

I believe it is the New York time zone.? Maybe it is useRTH or whatToShow.? Are you pulling TRADES?

Thanks


Re: Inconsistent behaviour of WHATIF orders

 

This is exactly the problem. On portfolio margin IB sets the margin requirement according to their risk model and not according to some fixed rules. Meaning every new positions margin is depending on which positions are already open. So using WHAT-IF orders simply doesn't work for positions
build from many legs.
Instead of using WHAT-IF orders I now calculate the margin according to this rules:

Most often the margin requirement of the whole position is <= the sum of the legs according to the rules. It only happened once so far that the requirement was higher (probably there was too much concentrated risk).


Re: whyHeld in orderStatus

 

I'm also receiving 404 Order held while securities are located. in my error handler.


whyHeld in orderStatus

 

In orderStatus, whyHeld is always empty when in TWS I can clearly see there are no locates.
I can work around this by looking for PreSubmitted orders and assume they're most likely orders without locate but this is a hack. Has anyone else experienced this?
I've tried both 983 and 1010.

<orderStatus orderId=7008823, status=PreSubmitted, filled=0.0, remaining=6199.0, avgFillPrice=0.0, permId=1583934260, parentId=0, lastFillPrice=0.0, clientId=16,
whyHeld=, mktCapPrice=0.0>


Re: Why is this order invalid and rejected?

 

Thanks for the reply.? I am thinking about how to decouple the combo, get the margin of smaller pieces and aggregate them together.? Should I always split into calls and puts and stocks and add them together?? or split into long positions and short positions and take the maximum?? I cannot sort my head clear how should the "splitting" logic work so that I can implement them.?

Also,? is it possible to access the margin report programatically?? I know with flex query it is possible to get it with api, but i am not sure if it's possible with margin report.?


Re: Why is this order invalid and rejected?

 

On Mon, Sep 6, 2021 at 04:17 PM, @jiamin wrote:
What I really want to do is to check the margin difference if I close all these positions but so far I haven't found a way to do so programatically.
That's probably the other reason they don't allow it, the orders you included don't margin against each other well.??

In this case, you're best off with a +4 and -1 call spread..? and then the long puts as a second order.? And then add the margin's from each.??


Re: Spotty historical bars for TICK-AMEX and other indexes

 

Can you be a little more specific? What bar size, duration, and duration unit are you using? And how do you specify the end time (time, time zone)?

Just ran a quick test for 20210901, 20210902, and 20210903 and got all the data to be expected:

  • With duration "1 day" and useRTH = false in the Chicago Time Zone
  • Data was returned for 06:00 through 19:00 Chicago time (13 hours)
  • Received 9,360 bars of 5 second bars per day
  • Received 780 bars of 1min per day

´³¨¹°ù²µ±ð²Ô


Spotty historical bars for TICK-AMEX and other indexes

 

Has anyone else experienced day-long gaps in these type of indexes when requesting historical bars from IB API?? For example, I get no data back for September 3rd, 2021 for TICK-AMEX, but I get it for September 2.

Thanks


Re: openOrder:orderState vs orderStatus:status

 

I use OrderState mostly for its CompletedStatus field which can indicate such things as "Rejected" or "Cancelled by Trader". My automation routine is stateless so it is useful for it to differentiate between reasons for orders getting canceled.