¿ªÔÆÌåÓý

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

Multiple Contracts Data Request and Calculation

 

I'm trying to do calculations on live prices for two different contracts with IB Live data. ??

What I'm trying to do, this is a newbie problem, is:?

request mktdata for two different contracts (not a problem)?

THEN do calculations on those prices and from that result submit orders for both contracts.

When you request live data from IB, the (reqMktData) method sends data concurrently down through tickPrice. Where I'm stuck is how to get the data OUT of tickPrice to do a simple difference calculation against it.

(Yup, trying to setup a pair trader system for myself) ??

It seems like, once you reqMktData the live data in stuck in that thread. ?I've try everything I understand and think it may have to do with setting up a delegate or interface or event or listener to get the data out of the tickPrice thread and onto another thread to do calculations and order submit.?


Any help is greatly appreciated. ?I've been trying to figure this out of weeks with C# and now Java and I'm totally stuck. ? :(?


Thanks in Advance.

John D.


Python Collaboration

 

I'm a month into Python development with IB and curious if anyone would like to collaborate.

The work would involve a robust infrastructure platform for live trading.


Currently I have the basics down:

-contract creation

-streaming tick data

-historical download

-database uploads

-misc account calls


I've been bouncing back and forth between ibpy and?swigibpy. ?Let me know if you're interested




Re: VBA: TWS ActiveX not Responing

 

There's nothing wrong with that spreadsheet, except that the code violates all rules of good programming and most rules of good VBA/Excel programming. ?That is, the basic TWS API stuff is all there and it all works. ?I would recommend developing ?your project side-by-side with an unmodified version of the spreadsheet (you can connect both simultaneously using different client IDs) ... for every method and event, first make sure you know how it works in the unmodified version, then translate to your no-worksheet version.


VBA: TWS ActiveX not Responing

 

This is my first post here.


Whilst I consider my Excel/VBA skills to be quite good, ActiveX has me drawing blanks.


I have taken the?TwsActiveX.xls file and attempted to separate the VBA from the worksheets.


I have created a new Module with a few Subs:

TWS_Connect

TWS_Time

TWS_PlaceOrder

TWS_GetOpenOrders


I have copied the relevant IB private subs from the worksheets and replaced worksheet/cell references with local variables & tested hardcode values. (I haven't changed the logic in any way or added any smarts)


In the cTWCControl Class modules and replaced worksheet references with local variables and msgbox's to tell me it's working.


TWS_Connect?

?works well

TWS_Time?

?works well

TWS_PlaceOrder

? the subs in the?cTWCControl module are not envoked by the ActiveX (I receive no msg or VBA error)

TWS_GetOpenOrders?

?the subs in the?cTWCControl module are not envoked by the ActiveX (I receive no msg or VBA error)


There are no compile errors in VBA


Any feedback would be much appreciated


PS:?

I have a quant DB (MySQL) & algos updated by & built in Excel VBA.

I don't actually use worksheets at all, I use Excel VBA because I've been using it for 15yrs.

I know C++/VB is the better alternative however I would prefer to stick with VBA.

?


Re: Subject: IBController - the future

 

Thanks MM. I¡¯ll certainly be around on this list (I¡¯m still the Moderator!), and you know where I live (electronically speaking).



Can I please ask everyone else to refrain from posting responses to the IBController announcement here? I set up the IBController User Group specifically to avoid the unnecessary pollution of this group with IBController matters, which are really outside its scope, so please post there (the address for it is in my announcement).



Thanks all for your cooperation.



Richard



From: TWSAPI@... [mailto:TWSAPI@...]
Sent: 08 June 2016 19:15
To: TWSAPI@...
Subject: Re: [TWS API] Subject: IBController - the future





Richard,

Thanks for all your effort over the years.



I hope, we, I, can continue to maintain contact, in some form, into the future (probably on this list, unless Yahoo does something foolish).



Jared's company is an up and coming contender to compete with the likes of Quantopian and to offer plebes like me the opportunity to join the heralded halls of high finance (were I so inclined).



I'm sure he and his team will be highly regarded and attentive stewards of the project.



MM





On Wed, Jun 8, 2016 at 10:59 AM, 'Richard L King' rlking@... <mailto:rlking@...> [TWSAPI] <TWSAPI@... <mailto:TWSAPI@...> > wrote:



I¡¯ve been looking after IBController since 2003, maintaining the code, developing new features, and supporting users. My aim has always been to make it a useful tool that anyone can use to improve their experience of working with Interactive Brokers¡¯ Trader Workstation and Gateway. My philosophy in supporting users has been to respond to their problems or suggestions as soon as possible, and to try to understand why it is that they have such problems and, if possible, to remove or alleviate these causes.



The amount of time I¡¯ve had to commit to this task has varied widely over the years, from periods of months where there has been practically nothing to do, to times when it¡¯s been truly taxing to get everything done along with my everyday work and life. The last few months since IB introduced their new packaging with TWS 952 has been one of those difficult periods, and it has caused me to re-evaluate my relationship to IBController. As a result, I¡¯ve decided that I need to bow out from my role as guardian of IBController, and hand it over to someone else.



So today I¡¯m pleased to be able to announce that with immediate effect, IBController will have a new champion in the person of Jared Broad (email Jared Broad jared@... <mailto:jared@...> ). Jared is the mastermind behind a young and dynamic company who use IBController within their commercial offerings, and he has a vested interest in ensuring that it continues to work well with current and future versions of TWS/Gateway. He is committed to further developing IBController to make it easier to install and use, and to introduce innovations that will make it easier for users with special requirements to adapt it to their needs without having to fork the project.



Future IBController development will be undertaken by an experienced Java developer, under Jared¡¯s management, and employed by his company.



I expect to contribute some guidance and background understanding in the coming days or weeks while the new developer gets up to speed. Also as a full-time user of IBController myself, I will feel free to make comments and suggestions via GitHub as IBController evolves.



IBController will of course remain completely free and open source, and licensed under the GPL version 3.



If you have any questions or concerns arising from this announcement, please post them on the IBController User Group at /g/ibcontroller.



Thanks for your often flattering appreciation of my efforts over the past 13 years.



Richard King









[Non-text portions of this message have been removed]


Re: Subject: IBController - the future

 

Richard,
Thanks for all your effort over the years.

I hope, we, I, can continue to maintain contact, in some form, into the future (probably on this list, unless Yahoo does something foolish).

Jared's company is an up and coming contender to compete with the likes of Quantopian and to offer plebes like me the opportunity to join the heralded halls of high finance (were I so inclined).

I'm sure he and his team will be highly regarded and attentive stewards of the project.

MM


On Wed, Jun 8, 2016 at 10:59 AM, 'Richard L King' rlking@... [TWSAPI] <TWSAPI@...> wrote:


I¡¯ve been looking after IBController since 2003, maintaining the code, developing new features, and supporting users. My aim has always been to make it a useful tool that anyone can use to improve their experience of working with Interactive Brokers¡¯ Trader Workstation and Gateway. My philosophy in supporting users has been to respond to their problems or suggestions as soon as possible, and to try to understand why it is that they have such problems and, if possible, to remove or alleviate these causes.

?

The amount of time I¡¯ve had to commit to this task has varied widely over the years, from periods of months where there has been practically nothing to do, to times when it¡¯s been truly taxing to get everything done along with my everyday work and life. The last few months since IB introduced their new packaging with TWS 952 has been one of those difficult periods, and it has caused me to re-evaluate my relationship to IBController. As a result, I¡¯ve decided that I need to bow out from my role as guardian of IBController, and hand it over to someone else.

?

So today I¡¯m pleased to be able to announce that with immediate effect, IBController will have a new champion in the person of Jared Broad (email Jared Broad jared@...). Jared is the mastermind behind a young and dynamic company who use IBController within their commercial offerings, and he has a vested interest in ensuring that it continues to work well with current and future versions of TWS/Gateway. He is committed to further developing IBController to make it easier to install and use, and to introduce innovations that will make it easier for users with special requirements to adapt it to their needs without having to fork the project.

?

Future IBController development will be undertaken by an experienced Java developer, under Jared¡¯s management, and employed by his company.

?

I expect to contribute some guidance and background understanding in the coming days or weeks while the new developer gets up to speed. Also as a full-time user of IBController myself, I will feel free to make comments and suggestions via GitHub as IBController evolves.

?

IBController will of course remain completely free and open source, and licensed under the GPL version 3.

?

If you have any questions or concerns arising from this announcement, please post them on the IBController User Group at ?/g/ibcontroller.

?

Thanks for your often flattering appreciation of my efforts over the past 13 years.

?

Richard King





Subject: IBController - the future

 

¿ªÔÆÌåÓý

I¡¯ve been looking after IBController since 2003, maintaining the code, developing new features, and supporting users. My aim has always been to make it a useful tool that anyone can use to improve their experience of working with Interactive Brokers¡¯ Trader Workstation and Gateway. My philosophy in supporting users has been to respond to their problems or suggestions as soon as possible, and to try to understand why it is that they have such problems and, if possible, to remove or alleviate these causes.

?

The amount of time I¡¯ve had to commit to this task has varied widely over the years, from periods of months where there has been practically nothing to do, to times when it¡¯s been truly taxing to get everything done along with my everyday work and life. The last few months since IB introduced their new packaging with TWS 952 has been one of those difficult periods, and it has caused me to re-evaluate my relationship to IBController. As a result, I¡¯ve decided that I need to bow out from my role as guardian of IBController, and hand it over to someone else.

?

So today I¡¯m pleased to be able to announce that with immediate effect, IBController will have a new champion in the person of Jared Broad (email Jared Broad jared@...). Jared is the mastermind behind a young and dynamic company who use IBController within their commercial offerings, and he has a vested interest in ensuring that it continues to work well with current and future versions of TWS/Gateway. He is committed to further developing IBController to make it easier to install and use, and to introduce innovations that will make it easier for users with special requirements to adapt it to their needs without having to fork the project.

?

Future IBController development will be undertaken by an experienced Java developer, under Jared¡¯s management, and employed by his company.

?

I expect to contribute some guidance and background understanding in the coming days or weeks while the new developer gets up to speed. Also as a full-time user of IBController myself, I will feel free to make comments and suggestions via GitHub as IBController evolves.

?

IBController will of course remain completely free and open source, and licensed under the GPL version 3.

?

If you have any questions or concerns arising from this announcement, please post them on the IBController User Group at ?/g/ibcontroller.

?

Thanks for your often flattering appreciation of my efforts over the past 13 years.

?

Richard King


Re: How to get Uptick Status through API

 

Hi,

Unfortunately no the 'short sale restriction' status in Tws isn't available programmatically from IB - either from the API or the ftp site.

Josh


Re: TWS that does not update

 

Hi Alice,

Yes you just need to install a version of 'Offline TWS'. They will not update automatically.

Josh


TWS that does not update

Alice Meade
 

¿ªÔÆÌåÓý

Hi,

Is there a build of TWS that does not attempt to update every time you launch? ?I went online to ?but it looked like all the builds available for download all said they updated to the latest release if available.

Thanks,
Alice


Re: Higher Price Resolution on U.S. Equities?

 

¿ªÔÆÌåÓý

Thanks for the clarification, I'd been thinking order types like Edge's "Hide Not Slide" were facilitating sub penny pricing on lit venues, but was forgetting this was to adjust or hide the price of orders that would have caused a locked market. My bad.

Stew

On 08/06/16 00:18, rholowczak wrote:
In the US we have SEC Rule 612. Here is a decent FAQ about what the rule covers:

?


So clearly market makers can not post quotes (or brokers post limit orders) on Reg NMS securities below a penny increment when the price quote is over $1.00. However it is perfectly legal for a dark pool?to cross orders?or a broker / dealer to internalize two orders at sub-penny increments. You can easily observe this by looking at last trade prices as they come over the tape. You will see many sub-penny prints.

Various US Equity exchanges have been fighting this rule for some time since internalization and dark pool take revenue away from them. so far none have been successful in making a compelling case to the SEC. Although Nasdaq has some price improvement mechanism whereby certain participants (RMO's) can submit orders eligible for price improvement at sub-penny increment ?()


-- 
Stewart Douglas
sdouglas@...


Re: IBDividends feed

 

Works perfectly, thanks!

Andrew


Re: Anyway to load symbols and dates into IB charts using code (not manually) from Excel?

 

Analyzing dates is more for strategy optimization, not replacing backtesting. ?For example, when analyzing a sample, you want to look or all the times the algorithm lost money. You then compare it to the ones it made money, and then try optimize your factors (doing it graphically). A backtest would only tell you if the algorithm is net positive/negative.?

Just wondering if IB charts save the date and symbol you saved it as. (i.e.: if you save a chart with the ticker "C" and date "12/21/2015, would it be able to load both if you open up the chart?) Learning code right now, so haven't had the chance to pay for IB data fees. . ?



Re: FAPercentage and order size

 

Josh and all,

Thanks a lot for your help. Yes I tried the code for both demo and real accounts. It gives the same message about zero. I also tried to specify 0 in the TotalQuantity and tried not to set the TotalQuantity at all. The former seems to have no effect on the result as I see that the Order constructor by default initializes that field to 0 anyway.

I think for now I'll give up on this allocation method as I'm not yet sure if I'm going to use it anyway in the foreseen future - just attempted to make sure my code supports all options. If one day I'll get back to this method I'll contact IB API support.



On Wed, Jun 8, 2016 at 4:38 AM, jb201448@... [TWSAPI] <TWSAPI@...> wrote:
?

Hi Ed,


Are you testing this in an FA paper account? If you try to place this order in an individual account (account number starting with 'U' or 'DU') you will receive the error message:

Error 100000 321 Error validating request:-'a8' : cause - The size value cannot be zero:


Otherwise in an FA account (starting with 'F' or 'DF') the following code from the sample will execute correctly:


? ? Order faOrderGroupPC = new Order();

? ? faOrderGroupPC.action("BUY");

? ? faOrderGroupPC.orderType("MKT");

? ? // You should not specify any order quantity for PctChange allocation method

? ? faOrderGroupPC.faGroup("All");

? ? faOrderGroupPC.faMethod("PctChange");

? ? faOrderGroupPC.faPercentage("100");

? ??m_s.placeOrder(NextValidId++, contract, faOrderGroupPC);


-Josh




Re: FAPercentage and order size

 

Hi Ed,

Are you testing this in an FA paper account? If you try to place this order in an individual account (account number starting with 'U' or 'DU') you will receive the error message:

Error 100000 321 Error validating request:-'a8' : cause - The size value cannot be zero:


Otherwise in an FA account (starting with 'F' or 'DF') the following code from the sample will execute correctly:


? ? Order faOrderGroupPC = new Order();

? ? faOrderGroupPC.action("BUY");

? ? faOrderGroupPC.orderType("MKT");

? ? // You should not specify any order quantity for PctChange allocation method

? ? faOrderGroupPC.faGroup("All");

? ? faOrderGroupPC.faMethod("PctChange");

? ? faOrderGroupPC.faPercentage("100");

? ??m_s.placeOrder(NextValidId++, contract, faOrderGroupPC);


-Josh



Re: Anyway to load symbols and dates into IB charts using code (not manually) from Excel?

 

I think more typically a backtesting engine would simply extract data from the Tws API and not using its charting capabilities, since there would is no way to plot arbitrary graphs in Tws- for instance showing the performance of a customized strategies over time. However with the IB API however because of the historical data limitations more commonly the data would have to be stored externally anyway, in a database or some other structure.

Its possible to save charts and chart templates in Tws but there isn't a generalized way to automate this.?

Josh


Re: IBDividends feed

 

Hi Andrew,

Try to smart-route rather than direct-route the request, i.e.

Contract contract = new Contract();

contract.symbol("RIO");

contract.secType("STK");

contract.currency("GBP");

contract.exchange("SMART");

contract.primaryExch("LSE");


m_s.reqMktData(101, contract, "456", false, null);


Then the dividend information will be returned.



Josh


Re: Higher Price Resolution on U.S. Equities?

rholowczak
 

In the US we have SEC Rule 612. Here is a decent FAQ about what the rule covers:

?


So clearly market makers can not post quotes (or brokers post limit orders) on Reg NMS securities below a penny increment when the price quote is over $1.00. However it is perfectly legal for a dark pool?to cross orders?or a broker / dealer to internalize two orders at sub-penny increments. You can easily observe this by looking at last trade prices as they come over the tape. You will see many sub-penny prints.

Various US Equity exchanges have been fighting this rule for some time since internalization and dark pool take revenue away from them. so far none have been successful in making a compelling case to the SEC. Although Nasdaq has some price improvement mechanism whereby certain participants (RMO's) can submit orders eligible for price improvement at sub-penny increment ?(http://nasdaq.cchwallstreet.com/NASDAQ/pdf/nasdaq-filings/2012/SR-NASDAQ-2012-129_Approval.pdf)


Re: Higher Price Resolution on U.S. Equities?

 

¿ªÔÆÌåÓý

It is possible for market makers etc to quote improved prices in fractions of a cent on some venues but they're not shown in the NBBO AFAIK. For retail traders luck us, as Nick said, I don't think there is any way to access those quotes reliably.

On 07/06/16 18:24, Nick news1000@... [TWSAPI] wrote:
Tick size means the smallest amount the price can change, as defined by the exchange. There is no point in a higher resolution as the extra digits will always be zero.

I don't trade stocks but I believe sub-penny pricing is not available to retail traders. You should verify the tick size of all instruments you trade.

On 6/7/2016 1:14 PM, keithjmiklas@... [TWSAPI] wrote:
?

Thanks, Stew.


So, are these tick sizes set in stone, or is there some way--in TWS, the API, or otherwise--to lower the tick size?


-- 
Stewart Douglas
sdouglas@...


Re: Higher Price Resolution on U.S. Equities?

Nick
 

¿ªÔÆÌåÓý

Tick size means the smallest amount the price can change, as defined by the exchange. There is no point in a higher resolution as the extra digits will always be zero.

I don't trade stocks but I believe sub-penny pricing is not available to retail traders. You should verify the tick size of all instruments you trade.

On 6/7/2016 1:14 PM, keithjmiklas@... [TWSAPI] wrote:

?

Thanks, Stew.


So, are these tick sizes set in stone, or is there some way--in TWS, the API, or otherwise--to lower the tick size?