开云体育

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

Re: TWS API for FUTURE response 200 No security definition has been found for the request

 

The financial futures trade calendar quarter-end deliveries: March, June, September, December
Commodity futures deliveries coincide with production or consumption cycles (e.g. growing season in agriculture, usage in gold/silver)
[rwk]


TWS API for FUTURE response 200 No security definition has been found for the request

breakout.soul@gmail.com
 

Hi,
I am trying to get the FUTURE data of some indexes like ES,?NQ, so I write the following code:

contract = Contract()
contract.symbol = "ES"
contract.secType = "FUT"
contract.exchange = "GLOBEX"
contract.lastTradeDateOrContractMonth = "202204"
reqMarketDataType(1)
reqMktData(2, contract, "", False, False, [])

But its responses --> 200 No security definition has been found for the request

Can anyone help me to figure out what is the exact reason for my code so it does not return any data?

- Thanks
Ihtesham


Re: Conditions on twsactivex API.... AGAIN :)

 

Just for whoever finds this thread and because they had the same problem as me, to circumvent this issue I had to cancel the order and send it again with a new order Id, every day. Hope there will be a solution to prevent?this from happening again.


El sáb, 2 abr 2022 a las 12:57, joanmarcel119 via (<joanmarcel=gmail.com@groups.io>) escribió:
First of all, I hope this message finds you well.

Here we go again with an issue related to price conditions. It seems that I'm the only one person in the world using these conditions on the TwsActiveX API... I need to be able to send the order changes to the TWS every day at the first hour in the morning, so I'm not keeping the TWS and the excel always connected nor the computer turned on.

I think we have found another bug on IB, because the price condition doesn't get updated if you turn off the TWS and restart it again!

For the tests, I used the Excel sample IB provides:

1) On the sheet "Conditional Orders" and after connecting to TWS I sent a MKT order on IBM stock with price condition:
"last of bid/ask Price of 37018770(SMART) is >= 30" (conid 37018770 is T stock)

After placing the focus on the row and clicking on the "Place /Modify Order" button, the order is sent and the Order Id is set on T column "Id" so we can resend the order and update the price condition. The result was as expected on TWS.

2) Update the price condition to:
"last of bid/ask Price of 37018770(SMART) is >= 32"

again after clicking on the button to send this modification, the result was right on TWS.

3) Now turn off the TWS and the excel

4) turn on again the TWS and the excel

5) Update the price condition to:
"last of bid/ask Price of 37018770(SMART) is >= 30"
?
After clicking on the button the modification is not sent, well I've taken a look at the API log and it is sent but the order is not modified on TWS and no error returned, so it is not working as expected.

Any clues on this? What can I do or?test?

I attach the excel demo workbook with the test row as explained here and the api log which shows the order is sent to the TWS and an answer comes from it with the price unchanged

Thank you very much


Conditions on twsactivex API.... AGAIN :)

 

First of all, I hope this message finds you well.

Here we go again with an issue related to price conditions. It seems that I'm the only one person in the world using these conditions on the TwsActiveX API... I need to be able to send the order changes to the TWS every day at the first hour in the morning, so I'm not keeping the TWS and the excel always connected nor the computer turned on.

I think we have found another bug on IB, because the price condition doesn't get updated if you turn off the TWS and restart it again!

For the tests, I used the Excel sample IB provides:

1) On the sheet "Conditional Orders" and after connecting to TWS I sent a MKT order on IBM stock with price condition:
"last of bid/ask Price of 37018770(SMART) is >= 30" (conid 37018770 is T stock)

After placing the focus on the row and clicking on the "Place /Modify Order" button, the order is sent and the Order Id is set on T column "Id" so we can resend the order and update the price condition. The result was as expected on TWS.

2) Update the price condition to:
"last of bid/ask Price of 37018770(SMART) is >= 32"

again after clicking on the button to send this modification, the result was right on TWS.

3) Now turn off the TWS and the excel

4) turn on again the TWS and the excel

5) Update the price condition to:
"last of bid/ask Price of 37018770(SMART) is >= 30"
?
After clicking on the button the modification is not sent, well I've taken a look at the API log and it is sent but the order is not modified on TWS and no error returned, so it is not working as expected.

Any clues on this? What can I do or?test?

I attach the excel demo workbook with the test row as explained here and the api log which shows the order is sent to the TWS and an answer comes from it with the price unchanged

Thank you very much


Re: Pairs trading: Parent vs Child order placement

 

I want to add my experience with combo orders. I also was at the beginning worried because they were not guaranteed. However it happened extremely seldom that not both legs filled almost simultaneously. I was usually satisfied with the executions I got. It might be different if one side is illiquid.


Re: Pairs trading: Parent vs Child order placement

 

Thank you for your support, I had a read at this page:??
which enlightened me a bit; essentially pairs are what I am looking after, however for the two stocks I am after, it cannot be guaranteed, therefore I do not see any interest in using this.
Moreover it only allows a diff trading for convenience, but say you have a stock priced $1 and the other 9$, your pair is co-integrated, you want to buy 9 shared of the first type and sell 1 of the second type.
Well with this tool you only know that you will take a $10 position for your pair, but if you had the 9$ one at a fair price, and the 1$ one you paid a disgusting spread, well your pairs trade is worth much less now because you will have to pay that spread 9 times as opposed to 1 time for the $9 one.

Not sure if the above makes sense, but anyways I will stick to submitting orders 1 after the other, first take position on the $1 at a good limit price, then hedge it immediately with the $9 at any price.


Re: Pairs trading: Parent vs Child order placement

 

I do use this type of orders for one special effect, which excludes trading in different securities (it's more of a simpler reversion trade). There are a some quirks to all of varieties of IB's bracket order, this one being no exception. Although my code for managing this was hacked a long time ago and I couldn't find any clear comments or side notes, I found in my code a check giving a strong warning which concerns automatically assigning the calculated values of 'hedgeParam' below 1.0. In particular the only accepted values for the apper to be 0.1, 0.2 and 0.5, which I probably found experientially. Other than that it likely should work.

Hope that helps.

вт, 29 мар. 2022 г., 19:09 John <serorjb@...>:

For context, the goal is pairs trading, but one of the two securities is somewhat less liquid than the other,
hence the desired prioritization/conditionality of the most liquid order on the execution of the least liquid one first.


Problem with specific symbols

cohenkobi1@gmail.com
 

Hi all,

I am using ib_insync to buy/sell NYSE stocks, and generally the script works fine.

In some cases, when I buy or sell specific symbols - orders are not filled.
This happens with those symbols evey single time.
When using TWS GUI- there is no issue, orders are carried out the same as any other symbol.

Can you help understnading what makes those symbols 'special'??
Any idea how to handle this?

Examples for problematic symbols: SOFI, ABEV
Symbol with correct functioning: PLUG, AAPL

Thanks,
Kobi


Re: TWS order has reqId=0; how to cancel it from API?

 

This is weird for sure.? I just call reqAllOpenOrders() and reqOpenOrders() and store everything that gets returned in the callbacks.? That seems to grab them all and I then have the correct orderId.

Mike


Re: Pairs trading: Parent vs Child order placement

 

For context, the goal is pairs trading, but one of the two securities is somewhat less liquid than the other,
hence the desired prioritization/conditionality of the most liquid order on the execution of the least liquid one first.


Re: Pairs trading: Parent vs Child order placement

 

Thank you very much both.

With trial and error, I found that Transmit=False is of no use in this case, as I need the orders transmitted; the child order got blocked in the current format as not on the same contract.
I did not manage to use?hedgeType='P', hedgeParams=f'ratio = {self.ratio}', it seems like whatever I put in hedgeParam(s?) I get an "invalid ratio" error in return.

How would I place these conditional orders manually, that's an excellent question and I honestly don't know.
Algos seem interesting and I would love to do some profiling with them at a later stage, but these are not available for testing on paper money as I understand, so no use at this time for me.
Execution Conditions seem to offer every possible condition, except the condition of another order getting executed, or maybe I am missing something.

Combo orders might be closest to what I am looking for, but I spent a few hours on it thus far without understanding the concept..
Apparently I need to define a "BAG" contract like "AAPL, AMZN", put an action "BUY"/"SELL" and a ratio on each leg, and then append both legs to a?contract.comboLegs object.
What is not clear at all from?
is what to do next with this contract.comboLegs object?

According to??I need to define an order with the orderComboLegs properties in there,
but it suggests that this order must also have an action, and orderType e.g. "LMT", a quantity and/or a limit price? what does that mean? the quantity of what? the limit price of what exactly?

Also how does the guaranteed flag work? if I need both legs or nothing, I should simply not mention it?


Re: TWS order has reqId=0; how to cancel it from API?

 

开云体育

Thanks for the reply. I found the root cause of this.
I used ‘reqAllOpenOrders’ instead of ‘reqOpenOrders’ and that does not receive the ‘orderBound’ callback.

The confusing thing is that it seems that only on new orders that were submitted in TWS after a last API call to ‘reqOpenOrders’ the orderId is 0 when you retrieve via ‘reqAllOpenOrders’ later. On orders that were submitted before a last call to ‘reqOpenOrders’, even when you retrieve them via ‘reqAllOpenOrders’ later, still a valid (negative) orderId is returned.?

The API doc indeed only mentions the orderBound callback for ‘reqOpenOrders’ and says to use ‘reqAllOpenOrders’ to ‘obtain those orders created via the API regardless of client application’. So while it does retrieve orders from TWS also, their orderId will be zero if not bound prior.

Bart
On Mar 27, 2022, 1:28 PM -0700, 闯ü谤驳别苍 Reinold via groups.io <TwsApiOnGroupsIo@...>, wrote:

What does it mean when you say "I can see this order in the API"?

The section of the API reference describes the various options you have When client 0 calls or callbacks will provide mappings of permIds to orderIds client 0 can use to manipulate orders that were placed by other clients or manually in TWS. You can configure TWS such that negative orderIds are used to better separate these orders them from orders your API client places.

For this to work, orders must be "open" from the TWS point of view. I am not sure whether simulated orders with status "pre-submitted" are considered "open" for the purpose of order binding, but you should be able to quickly try and and see whether you get an callback.

闯ü谤驳别苍


Re: Pairs trading: Parent vs Child order placement

 

When I was still pairs trading I submitted my orders as combo orders (REL+LMT). This worked well.


Re: no volume / no count / no vwap on TLSA market data

 

seems there are more outages last week and now - pretty mysterious - looks like related to major changes in the market

Since?2022-03-20T00:03:31.540?till?2022-03-24T15:37:02.287

Since?2022-03-27T10:19:22.631?


Re: Pairs trading: Parent vs Child order placement

 

A few quick thoughts, John:
  • The last order in a series of orders with transmit=false must have transmit=true or all orders of the series are held in TWS and are not transmitted to IBKR for processing (as you experience with the transmit button).
  • The IBKR APi documentation mentions in a couple places that TWS may need a brief period of time to process parent orders and that "missing parent order" errors may occur. when child orders are placed too quickly. IBKR suggests pacing the first child order by 50ms in these cases, but I would expect error code 10006, not error 320 that you receive.
  • How would you place the kind of orders you are looking for manually in TWS? You should be able to model that process via the API.
  • You mentioned a couple approaches you tried, but how about , , or for the second order?
闯ü谤驳别苍


Re: Pairs trading: Parent vs Child order placement

 

Actually regarding the missing parent order, I believe I need to add transmit =False on the child order too,
unlike the example given in?

It then appears to work, at least it populated the orders correctly as conditionals in TWS,
but then it give me the button "Transmit" and it seems like the orders are just parked there waiting for me to manually click "Transmit" ?


Pairs trading: Parent vs Child order placement

 

Hello Group,

Currently implementing mean reverting pairs trading (e.g. long SLV, short SSLN), would like to have the second leg order conditional on the execution of the first leg order.

Tried an approach similar to the??hedging one (with hedgeType='P'),
but I get the below "missing parent order" error despite giving it a few seconds between the two.
  • ERROR 2001 320 Error reading request. Missing parent order: server: 0 order: 2001 parent: 2000 hedge:[P]

Then I tried to attach the order?? ,
which is essentially a regular order with the parentId specified, but then it gives me the absurd:
  • Child must have the same contract as parent order
Can you please enlighten me? All I need is to execute an order properly and quickly, ideally limit at the last price,
then once that one is completed, trigger another one which deals with the hedging leg asap, on another contract/instrument.
Should I track the order execution via?execDetails? or is there a simpler way to attach them that works?

Thanks,
Jonathan


Re: Install TWS or IB gateway on Ubuntu and ARM64 bit processor

 

I last tried to do this a year ago on a Raspberry Pi 4B (4GB) running Ubuntu 21.04 64 bit.
The critical factor was obtaining a JVM with Javafx for this platform (Oracle dropped support for this after 8U6).
I tried various different JVMs, Bellsoft looked the most promising.?
I could run up Gateway, login to my paper account.? But was unable to get the settings dialog to appear (to configure ports etc).? The logs showed numerous UI errors, so Gateway was not happy.
Having spent too many hours on this I decided I had more pressing tasks and put the whole project on ice.
Doubtless a more determined effort could yield success.

Andy


Re: TWS API GUI

 

This is a pretty straightforward task that is not specific to TWS. Just search Google for how to create C# charts, populate them with data, and how to interact with them.


TWS API GUI

 

Hello All,

I have a C# application working for years.
I am considering using the GUI features to see if I can plot / create my own charts. Is that possible? Does anyone have experience doing / attempting this?

I am considering using 1-2 symbols to create custom charts using?tick data.

Cheers,

TraderAPI