开云体育

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

Re: Since Today, scanner not working

 

Yes, the stable version works.? Thanks.?


Locked Re: , MFA client doubles account in 6 weeks

 
Edited

This post has been deleted by the Moderator and the topic has been locked to prevent further posts.

.


C/C++ code for Market Depth Level 2 Streaming?

 

Hello,

Does anyone have a C/C++ Market Depth Level 2 Streaming code posted anywhere? (single file preferred rather than a full project library).
Bonus if it saves data to RDIS or another DB.

Thanks,


Re: Place a Limit Order with 2 Profit Takers and 1 Stop Loss for a Stock

 

开云体育

Place your limit order on its own (or with just a protective stop-loss in case you lose your connection before you do the next bit).

?

When the limit order is filled, place two separate OCA orders, each with a profit taker and a stop loss, and each for half the quantity (or whatever proportions you want), and cancel the original protective stop loss if any.

?

Note that there is still a tiny risk of trouble due to some sort of failure during the second part of this, but if you submit the two OCAs and do the cancel immediately consecutively you'd have to be very unlucky to get caught out. But trading is never risk free…

?

Then you need to consider things like partial fills etc, but you can work that out for yourself!

?

?

From: [email protected] <[email protected]> On Behalf Of Pavan M
Sent: 03 February 2021 16:43
To: [email protected]
Subject: [TWS API] Place a Limit Order with 2 Profit Takers and 1 Stop Loss for a Stock

?

Hello,

I am using Python TWS API. For a Stock, I want to place a Limit Order with 2 Profit Takers and 1 Stop Loss. If Profit Taker 1 is hit, then the stop loss should decrease by the commensurate amount (so after Profit Taker 1 is hit, the stop loss quantity is now updated to be equal to Profit Taker 2 quantity). How to do this ?

?

I have tried a Bracket Order with Two Profit Takers as . But as soon as Profit Taker 1 is hit, Profit Taker 2 and the Stop Loss is auto cancelled.?

?

How do I place a Limit Order with Two Profit Takers and 1 Stop Loss for a Stock ?

?

Thank You.

--
Best Regards,
Pavan


Place a Limit Order with 2 Profit Takers and 1 Stop Loss for a Stock

 

Hello,
I am using Python TWS API. For a Stock, I want to place a Limit Order with 2 Profit Takers and 1 Stop Loss. If Profit Taker 1 is hit, then the stop loss should decrease by the commensurate amount (so after Profit Taker 1 is hit, the stop loss quantity is now updated to be equal to Profit Taker 2 quantity). How to do this ?
?
I have tried a Bracket Order with Two Profit Takers as . But as soon as Profit Taker 1 is hit, Profit Taker 2 and the Stop Loss is auto cancelled.?
?
How do I place a Limit Order with Two Profit Takers and 1 Stop Loss for a Stock ?
?
Thank You.
--
Best Regards,
Pavan


reqMatchingSymbols not working today

 

开云体育

Hello everybody,

?

reqMatchingSymbols doesn?t work today it seems. I do not get any results. I?m using Excel VBA.

?

Does someone experience the same problem?

?

Kind regards,

Marc

?

?

?


Re: Timestamp for streaming market data and tick by tick?

 

The concept of "market lines" is explained at and cost details for quote boosters at
Without boosters, you have 100 market lines and, consequently, Level 2 data for up to three instruments per the table.It never came up for us but the way I read the table is that you'd have to

  • purchase four boosters to get Level 2 data for a total of four instruments
  • purchase five boosters for five Level 2 data streams total
  • ?...

You can purchase a maximum of 10 boosters so I guess the absolute maximum is 1100 market lines and Level 2 data for eleven instruments. At that point it may make sense to look at a real-time market feed provider. Keep in mind that data services and other API functions at IB have been designed for the support of a human sitting in front of the Trader Workstation. So there are lots of limitations.

The 3.5ms I mentioned is the "one way packet flight time" I have measured between my cloud instance and ndc1.ibllc.com and is calculated as one half of the round-trip ping time (which is just over 7ms). This was more of an "order of magnitude" example.

I don't think that there is a lot of time wasted. Keep in mind the API you are using is only for the connection between your client and TWS/Gateway and the message format are quite efficient. You do not communicate with IBKR servers directly and the connection between TWS/Gateway and IBKR servers is already FIX or similar. I can't see a reason to think about FIX unless you'd also colocate your server with IBKR to get the packet flight time down into the low microseconds or even nanoseconds. It is a completely different game at that point. But the FIX capabilities are documented at if you want to take a look.

Your question yesterday made me curious so I ran some stats on the 10 Million or so TickByTickTradeAll data objects and 50 Million TickByTickBidAsk objects we processed in January 2021 for ESH1:

Our system records an arrival time stamp (currently in ms) and each arriving object gets a unique serial number so that the arrival order can be maintained (despite the 1 second trade time resolution). The system clock is pretty stable with a long term average offset of only 1 micro second.

So I calculated arrivalTimeInMS minus (TickByTickTimeStampInSeconds * 1000) and plotted the result (see below and attached PDF):

  • The fastest reports arrivals with a lag of 3ms, but only very few arrive this quickly
  • The most frequent arrival delay is 770ms with another peak at around 1,030ms
  • Average and median arrival delay is around 870ms with a standard deviation of 385
Hope this helps/


Re: Historical downloader

 

Hi VirginCoder,

For your Github code I get a BadZipFile File is not a zip file error.

Would you have a simple program for market depth level 2 OR tick-by-tick streaming as well?

Thanks,


On Fri, Jan 10, 2020 at 06:08 AM, VirginCoder wrote:
Try this :



let me know if you need me to post the code... best Ruth


Re: Since Today, scanner not working

Nick
 

开云体育

There's no perfect solution but there's an argument to be made for not changing TWS versions once everything is working and stable for your needs.

Some people always upgrade to the latest version but I only upgrade when forced (IB servers enforce oldest TWS supported).


On 2/2/2021 1:05 PM, Stryder wrote:

Following a brief back and forth with IB, it turns out that the issue lies in one of the latest versions of TWS.

SOLUTION:? Downgrade to the latest max-stable version, which is currently? Build 978.2l.?

(you can see your current version in the top left corner of TWS > Help > About Trader Workstation... )

and, especially with the real money scripts, it is recommendable to not use the latest versions anyway...




Re: Since Today, scanner not working

 

Following a brief back and forth with IB, it turns out that the issue lies in one of the latest versions of TWS.

SOLUTION:? Downgrade to the latest max-stable version, which is currently? Build 978.2l.?

(you can see your current version in the top left corner of TWS > Help > About Trader Workstation... )

and, especially with the real money scripts, it is recommendable to not use the latest versions anyway...



Re: reqHistoricalData Duplicate Bars?

 

I'm sorry if this isn't directly helpful but I thought I could provide my own experience,
because I have downloaded massive amounts of 1min data through the ibapi, and the only types of duplicates I occasionally get are full days, not individual bars.

so if I requested 1m data for two weeks, it sometimes happens that I get 11 days, one being a duplicate.
But none of my sample-cleaning scripts have ever found random duplicate bars within any of the days...?

So, I would certainly check your handling of the data but?I am also not sure to what degree this can differ between clients, so it's also possible that the issue doesn't lie in your script...

?


Re: Timestamp for streaming market data and tick by tick?

 

Hi JR,

Thanks for the feedback.

I think tick-by-tick is a misnomer for what they send as tick-by-tick. They *may be sending all data but bunching them with a single time stamp negates the idea of tick by tick. I think a true tick by tick should be price, sell or buy, and exact timestamp.

A) You 3.5ms for your trading system in the cloud to receive things. I am assuming you have done a ping test and see your cloud server being 3.5ms away from one of the data servers. I wonder how much time is also wasted with type of data sent (due to not be FIX; if FIX is more efficient), and also if FIX requests are given priority over the regualar API requests. Can you comment on that?

B) At the bottom of the page you linked for limitations of market depth level 2, I see this chart which I don't understand. Would you know to explain please? I get that one need booster quotes and I sort of think they allow 60 lines (i.e. 10 rows per security = 6 securities like 6 forex pairs) to come through. And then with each booster quote one can get 1 or 3 more securities added which is maybe 10 more lines or 30 more lines (forgot the exact amount). I do not understand the chart they are showing. Can you or anyone explain this table please?


C) FIX allows only for order placement and not real-time streaming data. And for streaming data one has to again use TWS or IB Gateway?

D) Can someone speak of the FIX order placement speed in milli or micro seconds? and also overall general speed advantage over the API?

Thanks,


On Mon, Feb 1, 2021 at 02:01 PM, JR wrote:
#2 - The TBT time stamp has a resolution of one second as ds-avatar said. It appears (but I can't point to documentation) that the time stamp denotes the beginning of the second. Just as if ms, us, ns, ... are 0. In other words, no rounding takes place.

#2 and #3 - John and Sally will definitely receive their data at different times depending on where their systems are located relative to IB. In my case, for example, "data flight time" from IB to my systems is (approximate and not including the time it takes to go through TWS/Gateway and into the client app)

  • 3.5ms for my trading system in the cloud (US East)
  • 9.0ms for a large data center in the mid-west
  • 33ms to my home that is only 10 miles north of the mid-west data center (thanks for nothing, Comcast)
I assume (but again cannot point to documentation) that the time stamp in the TBT data is the same for all recipients fr the same tick.

#3 and #4 - There is no time stamp returned with reqMktDepth data. Take a look at the documentation atwhere they also describe limits and quote boosters.


reqHistoricalData Duplicate Bars?

 

I am facing a strange problem which I do not recall seeing before.

I am downloading 1 day of 1 min data and I am getting duplicate bars sometimes. None are missing and I am currently "erase"ing duplicates from my vector of bars.

I am just wondering if this is the nature of this type of request or I have some form of re-entry in my thread causing the problem.


Re: Historical downloader

 

开云体育

For bars up to and including daily, it’s bar start time.

?

But I think (though I’d have to go and check, which I can’t at the moment) that for weekly and monthly bars it’s the end date that’s returned. And, if I remember correctly, for the current week/month it’s today’s date.

?

You know, you really should check this out for yourself, or at least verify what I said. I may well be remembering incorrectly.

?

Richard

?

?

From: Andrew_
Sent: 16 January 2021 17:24
To: [email protected]
Subject: Re: [TWS API] Historical downloader

?

Richard, what's bar time is returned by the broker's servers - the start time of the bar or the end time of the bar?

?


Re: Since Today, scanner not working

 

I, too, am seeing this problem.? exactly as you are saying.? As of this morning, it has NOT been fixed.? I am NOT impressed.? I also have submitted a ticket with IB.? Hopefully they can fix this soon.??


Re: Timestamp for streaming market data and tick by tick?

 

#2 - The TBT time stamp has a resolution of one second as ds-avatar said. It appears (but I can't point to documentation) that the time stamp denotes the beginning of the second. Just as if ms, us, ns, ... are 0. In other words, no rounding takes place.

#2 and #3 - John and Sally will definitely receive their data at different times depending on where their systems are located relative to IB. In my case, for example, "data flight time" from IB to my systems is (approximate and not including the time it takes to go through TWS/Gateway and into the client app)

  • 3.5ms for my trading system in the cloud (US East)
  • 9.0ms for a large data center in the mid-west
  • 33ms to my home that is only 10 miles north of the mid-west data center (thanks for nothing, Comcast)
I assume (but again cannot point to documentation) that the time stamp in the TBT data is the same for all recipients fr the same tick.

#3 and #4 - There is no time stamp returned with reqMktDepth data. Take a look at the documentation atwhere they also describe limits and quote boosters.


[JAVA][TWS API][reqHistoricalTicks] Iterating over ArrayList of Contracts, Sending reqHistoricalTicks, Not Receiving Anything

mchaney2
 

Hi all,

I have a program that does the following:

1. Obtain list of stock symbols
2. Create skeleton Contract for each stock
3. For each Contract send reqContractDetails to get full Contract
4. For each received contract send reqSecDefOptParams to get all strikes and expirations
5. For each point (Symbol, expiration, strike) create skeleton Contract
6. For each skeleton Contract send reqContractDetails to get full Contract
7. Collect all Contracts received in (6) in an ArrayList
8. Iterate over the ArrayList and send reqHistoricalTicks to obtain price data

Here's the relevant code to where my problem lies:
??????? int index = 0;
?? ???? for (Contract x : underlyingList) {
???????????
?????? ???? client.reqHistoricalTicks(index, x, "20210129 15:50:00", null, 50, "TRADES", 0, false, mktDataOptions);
?????? ???? ?????? ????
?????? ???? Thread.sleep(22);
?????? ???? index++;
?????? ???? ?????? ????
?? ???? }

I also have a line in the for loop that prints the underlying symbol, the contract ID, and the secType ("OPT") for each contract.

When I run the program I am seeing each contract's ID and symbol so I know the iteration is happening. However, I am receiving maybe 1% of the prices back that I think I should be seeing.

Since I am using "TRADES", I think that I need to give you my code for historicalTicksLast:

??? public void historicalTicksLast(int reqId, List<HistoricalTickLast> ticks, boolean done) {
?? ???
?? ???? for (HistoricalTickLast tickLast : ticks) {

?? ???? ??? System.out.println(reqId + "|" + tickLast.price() "| @: " + tickLast.time() );
?? ???? }
?? ?}


I am sending a lot of requests but I think that since I am waiting over 20 ms each iteration I am not overloading the server.

I believe that I am setting snapshot to true, so I am NOT waiting on streaming data, correct?

Am I ensuring that at any time t I will be able to get a price upon request?

Why am I able to often run my program and not receive a single point of price data?

I am doing this for thousands of contracts but waiting >20ms each time thereby staying within the 50 message per second limit... Is this "rude" or okay?

If there are any other relevant parts of my code that you need to see I'll be happy to add it upon request.

Thank you for any help.

?


Re: How to deal with "disconnected from he HMDS server"?

 

Thanks for the reply.

Can you link me for HDMS only being for historical data?

For how it effects trading, let's say you are trading USDEUR late night at 12:05am and HDMS disconnects then you won't be able to move your position to higher or lower until you close/reopen TWS or wait I guess till HDMS connects again. There is a momentarily pause in everything probably and that can be a missed opportunity for a modification to a buy/sell order that is already placed but not executed yet.

Also, last night I noticed my balance in portfolio was not updating in TWS - probably also because of HDMS. This can be a serious issue when looking at available margin for example.

But then again maybe TWS is slow to connect to HDMS server and API won't have that issue and disconnect would be temporarily?

I also wonder if IB Gateway does better in this respect and other server connection errors than TWS since it's lighter and maybe more agile?


Re: Timestamp for streaming market data and tick by tick?

 

Thanks.

You said all times are cut off to 1s base. You mean rounded it off by 1s and it is not a complete epoch time with milli or micro seconds precision?

How about streaming tick data? Anyway to get their timestamp?

Thanks,



Re: MOO orders not being executed

 

IBKR absolutely supports opening and closing auction orders on Nasdaq. I placed and filled hundreds of these.

The errors you quote suggest you are using some IB algorithms, especially the last one. Make sure the algorithms you use support auction orders.