开云体育

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

Retrieve trailing stop level

 

If I have an open position with an attached trailing stop order, can I somehow retrieve the price where the stop is sitting at the moment?


Re: Order field to identify a strategy

 

I have used permID and stored it locally to identify strategy mapping. It works seamlessly across sessions and days. So as everyone else already said, I think, using permID with local mapping in your program should be able to do the trick.


CUSIP/ISIN in ActiveX API using VBA in Excel

 

Hello,

I have been trying to get ISIN and CUSIP from ActiveX API and failed everytime. I am using reqContractDetails and trying to read secIdList.?

I have successfully received the required info while using python API (So my account has necessary subscription). However, how exactly do I read secIdList in VBA while using ActiveX client?

I tried to assign the secIdList to TwsLib.ComTagValueList and also checking if secIdList is Null. Everytime I receive error in bold statements.?

Function writeContractName(contractDetails As TWSLib.IContractDetails, reqid As Long)
? ? Dim rowNum As Long
? ??
? ? contractName = contractDetails.longName
? ??
? ? Debug.Print IsNull(contractDetails.secIdList)
? ??
? ??
? ? If IsNull(contractDetails.secIdList) = False Then
? ? ? ? Debug.Print contractDetails.secIdList(0).tag
? ? End If
End Function


I tried looking everywhere and could not arrive at a satisfactory explanation for this issue!

Thanks and Regards,
Pratik


How place orders before AND after market hours?

 

What is the magic combination of settings that lets you place orders through the API both before and after market hours?? I can use outsideRth(true) on an order and place it after market hours, but not before market hours.? If I set this to false then I can place it before market hours but not after market hours. In TWS -> Global Settings -> Presets -> Stocks I can set either "Allow order to be activated, triggered, or filled outside RTH" or I can set "Allow order to be routed and executed during pre-open session".? But I cannot check both.? They are apparently mutually exclusive.

So what is the combination of parameters that let you place an order anytime from 4:00 am to 8:00 pm?

Thanks!


Re: Order field to identify a strategy

 

Hi all,

I use trade references stored in the order reference field, it usually works without problem. Track the order id, order reference and your internal tracking identifier, and you should be able to piece it all together.
What I have experienced is position reports being lagged by many minutes, and execution reports arrive in an arbitrary order, but the order references do seem to be stable.

Best wishes,

M?


On Thu, 18 Feb 2021 at 03:04, Bruce B <bruceb444@...> wrote:
Tracking within your own process is not working why?

If these are LMT orders can you not track them by LMT price you set, quantity of shares, and time? Time is of course always after you submitted but at least order one was maybe executed before order four was placed even if they have same amount of share and LMT price so not a certain certain way but some certainty...?

- Bruce

On Wed, Feb 17, 2021, 3:33 PM corneliu maftuleac <corneliu.maftuleac@...> wrote:
Thank you very much. Will investigate.



--
+44 (0) 7528 551604?
Gulfstream Software - Winner Risk Management Awards 2010
This message is subject to :


How can I get yesterday's volume at some moment of time for a stock?

 

I want to compare the current volume of a stock with yesterday's volume at the same time.

Thank you.


Re: Has anyone done a stock gap scanner

 

You can do this with the API function reqScannerSubscription.

https://interactivebrokers.github.io/tws-api/market_scanners.html


Re: How to pull all strikes for a given expiration?

 

See some useful hints here:


On Thu, Feb 18, 2021 at 1:08 AM Crow <aaroncook394@...> wrote:
How do I pull all strikes for a given expiration?? I found this API:



Which gives me all combinations of expirations and strikes, but the documentation notes:?

"?returns a list of expiries and a list of strike prices. In some cases it is possible there are combinations of strike and expiry that would not give a valid option contract."

Instead, I'd simply like the list of strikes available for a particular expiration.? Any way to get that?




How to pull all strikes for a given expiration?

 

开云体育

How do I pull all strikes for a given expiration?? I found this API:



Which gives me all combinations of expirations and strikes, but the documentation notes:?

"?returns a list of expiries and a list of strike prices. In some cases it is possible there are combinations of strike and expiry that would not give a valid option contract."

Instead, I'd simply like the list of strikes available for a particular expiration.? Any way to get that?




Re: Order field to identify a strategy

 

Tracking within your own process is not working why?

If these are LMT orders can you not track them by LMT price you set, quantity of shares, and time? Time is of course always after you submitted but at least order one was maybe executed before order four was placed even if they have same amount of share and LMT price so not a certain certain way but some certainty...?

- Bruce

On Wed, Feb 17, 2021, 3:33 PM corneliu maftuleac <corneliu.maftuleac@...> wrote:
Thank you very much. Will investigate.


Re: Is there a good reason to not use LATEST API vs Stable?

 

Hey Bruce,?

I'm not even counting the things I have to wrap/fix with the API..? just the fact that on occasion portions will stop working.. Maybe with an undocumented error code if you're lucky..? FA accounts stopped giving me positions one day, but only in prod, not paper. Took them 3 weeks to figure that one out.??

If you want to fix the API itself.. Why not start with the fact ID in Contract isn't readonly.? Absolutely love it when my hash/equals methods aren't deterministic.??

And then there is their object names, er Interfaces which don't start with I..? etc..? ?I'll literally start twitching if I keep thinking about the OO Anti patterns they stuck themselves with..

Thankfully, I wrapped the whole thing and get an "ObservableCollection<Position> Positions"? type interface for the rest of my app to use..?

Cheers


Re: Historical bars and WAP

 

So I probably answered my own question via an experiment - getting the same 5 secs bars as real-time and as historical.
They seem to match exactly except for field naming and precision.

Docs here are basically wrong -?.

"average" and "barCount" fields of historical bars are the same as "wap" and "count" fields of real-time bars except that "wap" in real-time bars has decimal precision of 3 digits after period and "average" of historical bars seem to have only 2 digits precision.
I checked just for one symbol of stocks and options and it seems to hold true. Perhaps, there are occasional discrepancies - I didn't check at large scale.


On Wed, Feb 17, 2021 at 1:03 AM Alex Gorbachev <ag@...> wrote:
Hi all,

Is WAP available for historical bars?

Looking at the API docs .

WAP is supposed to be present in the historical bars but I don't see it (I'm using ib_insync?Python module if that makes any difference). I can see WAP is returned in real-time bars but not in historical. I can see average. I wonder if that's basically WAP and just named differently than in the docs. I'm using IB Gateway?978.

{'average': 801.119,
?'barCount': 13,
?'close': 801.26,
?'date': datetime.datetime(2021, 2, 16, 16, 42, 30, tzinfo=datetime.timezone.utc),
?'high': 801.3,
?'low': 800.92,
?'open': 801.0,
?'volume': 20}


Also, I'm using 5 seconds bars in both cases (real-time and historical) and whatToShow='TRADES'.

Thanks in advance,
Alex


Re: Order field to identify a strategy

corneliu maftuleac
 

Thank you very much. Will investigate.


Re: Order field to identify a strategy

Nick
 

开云体育

Except for forex, markets are open for only part of a day as opposed to continuous 24/7 trading.

The general idea is markets open at a specific time and then close at a specific time and that is one trading session. Trading on the next day is a different session.

Different financial instruments have different rules for when a session starts and ends. A single session on the major futures exchanges spans calendar days - opening in the evening one day, going past midnight until the afternoon or the next day. Can make you crazy since a trade can occur on Monday evening but counts as the Tuesday trading day.

Back to the OrderRef, people have observed that the field is returned for executions in the same session as the order was placed but is empty if the order executed in a subsequent session.


On 2/17/2021 2:40 PM, corneliu maftuleac wrote:

Thanks Nick.
What is a session definition?


Re: Is there a wrapper api/sdk around that abstracts core trading functionality on top of the base ibkr api?

Nick
 

开云体育

The IB libraries are needlessly complicated and convoluted in my view.

My plain C library gets the job of reading messages done with a single function twsGetMsg() which returns a union with the message filled in. That's it. A message is physically just a bunch of fields read from the socket - how complicated can they make such a simple thing?


On 2/17/2021 2:49 PM, Ajay Joglekar wrote:

You described exactly my own physiological reaction after reading tws api :-)

On Wed, Feb 17, 2021, 9:39 AM Alex Gorbachev <ag@...> wrote:
I looked around and my head started to hurt from the design of the TWS API. :) So I went directly to ib_insync which seems to be somewhat well maintained.
It's actually not too dissimilar from TWS API but just removes some annoying plumbing.


Has anyone done a stock gap scanner

 

开云体育

Where I specify a criteria like price in the range of $5 - $15
or market cap of 200 Mill etc.


Re: Is there a wrapper api/sdk around that abstracts core trading functionality on top of the base ibkr api?

 

You described exactly my own physiological reaction after reading tws api :-)


On Wed, Feb 17, 2021, 9:39 AM Alex Gorbachev <ag@...> wrote:
I looked around and my head started to hurt from the design of the TWS API. :) So I went directly to ib_insync which seems to be somewhat well maintained.
It's actually not too dissimilar from TWS API but just removes some annoying plumbing.

On Wed, Feb 17, 2021 at 1:12 AM Joel Gross <joelrgross@...> wrote:
Alex - how do you like it? Have you ever just used the plain TWS API?

On Tue, Feb 16, 2021, 8:08 PM Alex Gorbachev <ag@...> wrote:
I've been using ib_insync.

On Fri, Feb 12, 2021 at 6:20 PM Ajay Joglekar <ajay.joglekar@...> wrote:
I have been lurking here for a couple+ weeks now and the one thing clear to me is that there is a lack of a maintained wrapper api/sdk which abstracts all the nitty gritty details from the average lay person who just wants to code up a goddamn system and not worry about byte endings and distinguishing trade and order entries.

So maybe its out there and if someone who already knows cares to answer - is there a wrapper api/sdk somewhere that gives abstract common-sense functionalities to interact with the really base ibkr api set?


Re: Order field to identify a strategy

corneliu maftuleac
 

Thanks Nick.
What is a session definition?


Re: Order field to identify a strategy

Nick
 

开云体育

There is OrderRef but it might not persist across sessions, you would have to make sure it meets your needs.


On 2/17/2021 1:30 PM, corneliu maftuleac wrote:

I have multiple strategies running on the same account/sub-account.
I want to distinguish which orders were placed by who.
Is there a field in the Order class that I can assign a custom value, and that value to be persistent so I later can identify who placed the order?


Re: Order field to identify a strategy

corneliu maftuleac
 

Update: someone suggested to use OrderRef field