开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育
Date

Re: How Long does it take orders to reach market.

 

You could find a thinly traded stock, place an out of the money order and measure how long it takes for the order to appear. You need to be receiving market data and looking at the timestamps. Python might not be the best language for precise time values. The actual will probably vary over the day depending on how busy IB and the entire trading network is.


Re: How Long does it take orders to reach market.

Franco Chiesa Docampo
 

开云体育

Your welcome Marc, Im glad it helped. I wonder how can we measure the latency between IB servers and the exchanges though...?


El 8 jun. 2022, a la(s) 23:00, Marc Valme <marcvalme@...> escribió:

Franco, thanks for the link, I'm getting 25ms ping time, which is pretty good.

On Wed, Jun 8, 2022 at 8:48 PM Franco Chiesa Docampo <fchiesadoc@...> wrote:
I assume it depends as well of your physical location. Have you tried to ping IB host servers? Maybe this can help: ?.?Even though I am not 100% sure.

El 8 jun. 2022, a la(s) 21:31, Marc Valme <marcvalme@...> escribió:

I'm not sure of an affective way to measure it, but from the time my python code send the socket msg how long does it take.? I assumed since the there is a 50 message limit per second that it was about .040ms but it Is not.??

I tested this by taking the current market price ( not from IBKR but from source with less latency ) and adding 5 points.? I would repeat and update this every 40ms.? Theoretically the lmt order should not get filled since the emini rarely moves that fast.? I noticed that the order gets filled rather quickly because IBKR could not update the order in less than 40ms.? If I changed this to once second the order does not get filled at all.? So the lag is between 40ms and 1 second.??


Re: How Long does it take orders to reach market.

 

Franco, thanks for the link, I'm getting 25ms ping time, which is pretty good.


On Wed, Jun 8, 2022 at 8:48 PM Franco Chiesa Docampo <fchiesadoc@...> wrote:
I assume it depends as well of your physical location. Have you tried to ping IB host servers? Maybe this can help: ?.?Even though I am not 100% sure.

El 8 jun. 2022, a la(s) 21:31, Marc Valme <marcvalme@...> escribió:

I'm not sure of an affective way to measure it, but from the time my python code send the socket msg how long does it take.? I assumed since the there is a 50 message limit per second that it was about .040ms but it Is not.??

I tested this by taking the current market price ( not from IBKR but from source with less latency ) and adding 5 points.? I would repeat and update this every 40ms.? Theoretically the lmt order should not get filled since the emini rarely moves that fast.? I noticed that the order gets filled rather quickly because IBKR could not update the order in less than 40ms.? If I changed this to once second the order does not get filled at all.? So the lag is between 40ms and 1 second.??


Re: How Long does it take orders to reach market.

Franco Chiesa Docampo
 

开云体育

I assume it depends as well of your physical location. Have you tried to ping IB host servers? Maybe this can help: ?.?Even though I am not 100% sure.

El 8 jun. 2022, a la(s) 21:31, Marc Valme <marcvalme@...> escribió:

I'm not sure of an affective way to measure it, but from the time my python code send the socket msg how long does it take.? I assumed since the there is a 50 message limit per second that it was about .040ms but it Is not.??

I tested this by taking the current market price ( not from IBKR but from source with less latency ) and adding 5 points.? I would repeat and update this every 40ms.? Theoretically the lmt order should not get filled since the emini rarely moves that fast.? I noticed that the order gets filled rather quickly because IBKR could not update the order in less than 40ms.? If I changed this to once second the order does not get filled at all.? So the lag is between 40ms and 1 second.??


How Long does it take orders to reach market.

 

I'm not sure of an affective way to measure it, but from the time my python code send the socket msg how long does it take.? I assumed since the there is a 50 message limit per second that it was about .040ms but it Is not.??

I tested this by taking the current market price ( not from IBKR but from source with less latency ) and adding 5 points.? I would repeat and update this every 40ms.? Theoretically the lmt order should not get filled since the emini rarely moves that fast.? I noticed that the order gets filled rather quickly because IBKR could not update the order in less than 40ms.? If I changed this to once second the order does not get filled at all.? So the lag is between 40ms and 1 second.??


Re: Double entry

 

O I see now that I have al several of those entries with extra .01?? But normally it seems always to be the case of a BAG order.

In this specific case I have on BAG with two legs. But the legs are added again without a "BAG entry". That's why the legs are double. But I have no idea why? It's the first time I saw this. It makes the trade log at bit unreliable.

Indeed in the FlexQuery there are no double entries.

I also had a time that I had missing trades see /g/twsapi/topic/87500038#48542? But now I use the latest stable version so I hope that's not the problem.


Re: Double entry

 

I haven’t been able to find any documentation on the format of ExecId so I am of limited help.? But here’s a bit more detail on what I’ve seen.?

?

The first time I saw this additional ‘.01’ show up on execution was in February 2022. I’ve only seen it on an execution coming through the API.? When that same execution is included in a FlexQuery report, it no longer has the additional ‘.01’.? However, the executions in the FlexQuery report all have a ‘PartialExecution’ or ‘P’ note on them, which is why I mentioned it might have something to do with a partial execution.? Since you only traded one contract and got one fill, there must be other occasions when this ‘.01’ gets appended.


Re: Problems to filter ApiController's option chain for reqContractDetails()

hrecalde
 

First of all, thanks for replying to this topic?闯ü谤驳别苍, I appreciate your opinion.

I'll take a look at creating reqOptionChain(...) which I agree could be the best approach.
--------------------------------------------------------------------------------------------------------------------------------------
It is not desirable from an architecture point of view that you push this very specific functionality into ApiController. Keep in mind that all?objects need to be consumed in order to prevent problems with the API message reader. Simply ignoring callbacks for??? that you are not interested in is not a good idea.
----------------------------------------------------------------------------------------------------------------------------------------------------------
I completely agree with you regarding modifying ApiController, that's why I was saying to create a new class and overwrite the reqContractDetails() method but I'll look into the first solution before.
Best regards!



Re: Double entry

 

How is that possible if I had one option contract and one position after fill?

Is there a explanation about the format of the ExecId. Now it's interpreted as two trades in my log.


Re: Rolling Credit Spread Converts Bull Put to Bear Put?

 

TWS doesn’t always interpret a spread in the same way. But you can right-click the position and select ‘Flip position’ (if I remember correctly), to have TWS display it as a Bull Put.


Re: Double entry

 

I’ve seen that extra .01 show up on executions that are filled across multiple exchanges.? For example, a thinly traded option might get filled across ISE, EMERALD, EDGX, PSE, etc. at slightly different prices.? The execution records will have a separate entry for each fill on each exchange all having that extra .01 at the end.


Re: Double entry

 

开云体育

Sorry, sent this too quickly!? Just noticed that the execution ID’s you list are different, so may not be a correction.

?

From: [email protected] <[email protected]> On Behalf Of David Walker
Sent: Tuesday, 7 June 2022 8:53 AM
To: [email protected]
Subject: Re: [TWS API] Double entry

?

It is likely a correction, per the note on the Executions page ()

?

“Note if a correction to an execution is published it will be received as an additional IBApi.EWrapper.execDetails callback with all parameters identical except for the execID in the Execution object. The execID will differ only in the digits after the final period.”

?

From: [email protected] <[email protected]> On Behalf Of info@...
Sent: Tuesday, 7 June 2022 4:17 AM
To: [email protected]
Subject: [TWS API] Double entry

?

Dear all,

I grab all completed orders and store them. But now I see that one day I had two of the same entries. All fields are the same even ConId, PermId date and time of execution.

But only the ExecId is different, especially one has an extra .01 at the end.

000xxx83.62xxxfex.02.01
000xxxc2.62xxx27x.02.01.01

Why is there an extra entry and what does that mean (the extra .01)?


Re: Double entry

 

开云体育

It is likely a correction, per the note on the Executions page ()

?

“Note if a correction to an execution is published it will be received as an additional IBApi.EWrapper.execDetails callback with all parameters identical except for the execID in the Execution object. The execID will differ only in the digits after the final period.”

?

From: [email protected] <[email protected]> On Behalf Of info@...
Sent: Tuesday, 7 June 2022 4:17 AM
To: [email protected]
Subject: [TWS API] Double entry

?

Dear all,

I grab all completed orders and store them. But now I see that one day I had two of the same entries. All fields are the same even ConId, PermId date and time of execution.

But only the ExecId is different, especially one has an extra .01 at the end.

000xxx83.62xxxfex.02.01
000xxxc2.62xxx27x.02.01.01

Why is there an extra entry and what does that mean (the extra .01)?


Re: Problems to filter ApiController's option chain for reqContractDetails()

 

The "query" contract you provide to the? call? determines how many results you will get. The more precise the query is written, the fewer? get returned.

The TWS API returns each? result object by an individual callback and indicates the end of the data with an call. ApiController simply handles the callbacks for you, collects all objects and returns them in a list.

The best approach would be that you tweak the request contract so that only those objects are returned that you are interested in. If that is not possible, filtering the list would be the next best choice. You might want to think about a thin layer between TWS API and your application that takes care of these more specialized functions. You would have something like a reqOptionChain call that makes the query, filters the list according to your rules, and returns just the chain you were looking for. Or it could make several narrowly defined? queries if that is faster.

It is not desirable from an architecture point of view that you push this very specific functionality into ApiController. Keep in mind that all objects need to be consumed in order to prevent problems with the API message reader. Simply ignoring callbacks for? ? that you are not interested in is not a good idea.

闯ü谤驳别苍


Re: Problems to filter ApiController's option chain for reqContractDetails()

hrecalde
 

I forgot to mentioned that I'm using the Java API and only passing one specific expiration like 20220610


Problems to filter ApiController's option chain for reqContractDetails()

hrecalde
 

Hi all,

First of all, I'm using the ApiController class to do my work. ?This class has a reqContractDetails(contract, processor) method that returns the whole option chain when given a contract. I don't want the whole chain, ?I only need, say 15 strikes from the current underling price a-la TWS OptionTrader. ?As you know, ApiController hides a lot of stuff from the caller so how would you approach this design? ?I see 2 ways which have not been tested yet
1) modify the list returned from the controller (if I could access it) and filter/reduce the handler's list or
2) Derive another class from ApiController and overwrite the reqContractDetails() and filter the data before adding it to the List<ContractDetails> array.?

I'd be really interested if someone already had to do something similar to ApiController.

Best regards,
Horacio


Rolling Credit Spread Converts Bull Put to Bear Put?

Jacob Pfeil
 

I'm using the TWS api to manage bull credit spreads. I'm working out a mechanism to roll contracts. Basically, I just create a bag contract that sells the original credit spread and buys a new credit spread.

First I bought a 0DTE trade to test things out.


Then, I rolled the trade here


This results in a another bull credit spread. But I think I might be doing something wrong because in TWS is says I created a bear put spread
I'm confused ebcause if I sell a put at 410 and buy a put at 408, isn't that a bull put spread?

Thanks


Double entry

 

Dear all,

I grab all completed orders and store them. But now I see that one day I had two of the same entries. All fields are the same even ConId, PermId date and time of execution.

But only the ExecId is different, especially one has an extra .01 at the end.

000xxx83.62xxxfex.02.01
000xxxc2.62xxx27x.02.01.01

Why is there an extra entry and what does that mean (the extra .01)?


Re: Conditional Trailing Stop ?

 

Thank you.
It works with adjustable stops.

For info, found this example in another message:

// Initial Stop Order Fields
Order order = new Order();
order.orderType("STP");
order.totalQuantity(1);
order.action("SELL");
order.auxPrice(170);
?
//Additional Fields for adjusted order
order.triggerPrice(175);
order.adjustedOrderType(OrderType.TRAIL);
order.adjustedStopPrice(173);
//trailing by and amount (0) or a percent (1)...
order.adjustableTrailingUnit(0);
order.adjustedTrailingAmount(5);
m_s.placeOrder(NextOrderId++, aapl, order);


Re: Conditional Trailing Stop ?

 

Look into IB documentation for Adjustable stops. In short, you set the Adjustable stop properties on the stop order of your bracket order, and the stop order adjusts to become that new stop type at the Trigger price.