¿ªÔÆÌåÓý

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

Re: 4AM opening price (not official one) but real one in timestamp

 

U made my day, mate! i been looking that for ages...Thats exctly i needed:
? "1658908800" : [ {
??? "tsInS" : 1658908800,
??? "type" : "AllLast",
??? "price" : 128.96,
??? "size" : 20,
??? "attr" : 8,
??? "exch" : "ARCA",
??? "spCond" : "? TI"

?

what request did u use to get it. Can u give me exactly how u wrote. Thanks a lot! Sorry i am not dev, just want to pass that information to my dev.


Re: 4AM opening price (not official one) but real one in timestamp

 

Don't use RT Volume ticks since they are aggregated (several trades reported in one tick). Please go ahead and read up on as I had suggested.

You get every individual trade from all exchanges with detailed attributes and conditions about the trade. You can then inspect the trades and pick the very first one that meets your needs.

For your reference, below the first three trades today at 4AM Eastern/3AM Central for IBM.

´³¨¹°ù²µ±ð²Ô

{
? "1658908800" : [ {
??? "tsInS" : 1658908800,
??? "type" : "AllLast",
??? "price" : 128.96,
??? "size" : 20,
??? "attr" : 8,
??? "exch" : "ARCA",
??? "spCond" : "? TI"
? } ],
? "1658908802" : [ {
??? "tsInS" : 1658908802,
??? "type" : "AllLast",
??? "price" : 128.39,
??? "size" : 3,
??? "attr" : 8,
??? "exch" : "DRCTEDGE",
??? "spCond" : "? TI"
? } ],
? "1658909573" : [ {
??? "tsInS" : 1658909573,
??? "type" : "AllLast",
??? "price" : 128.42,
??? "size" : 15,
??? "attr" : 8,
??? "exch" : "ARCA",
??? "spCond" : " FTI"
? },? ...


Re: 4AM opening price (not official one) but real one in timestamp

 

Hmm, the problem that if i get FIRST day trade (premarket from 4am or later) it brings me official one from SIP and its wrong because they show block for 100 shares or more.. but if first trade was 1 share.. API ignore it. So i asking how i can get that one which is ignored.
Sorry for my egnlish. I bilieve it is:

RT Volume (Time & Sales) 48 Last trade details (Including both "Last" and "Unreportable Last" trades) ?


Re: 4AM opening price (not official one) but real one in timestamp

 

You would probably want to look at and specifically for the various data options for trades at 4am.You'd have to set useRth=false, to get values for those early hours (outside of Regular Trading Hours).

Not all instruments may have trades at exactly 4am every day, so you might want to request data for the first hour or so to catch the earliest trade.

´³¨¹°ù²µ±ð²Ô


Re: Delayed TickByTick streaming data

 

I am not sure that data is available as delayed data. Where did you see that mentioned? You will always need a subscription and you will be limited to just a few parallel streams.

The API Reference Guide chapter only mentions that a few TickTypes.

´³¨¹°ù²µ±ð²Ô


Delayed TickByTick streaming data

 

From what I understand delayed TickByTick streaming data requires no subscription (besides snapshot and is subject to volume limitations). So I wonder why I get the following error message:

My code:?

from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.ticktype import TickTypeEnum
import time
from datetime import datetime
import threading
?
?
class TestApp(EWrapper, EClient):
? ? def __init__(self):
? ? ? ? EClient.__init__(self, self)
? ? ? ? self.last_price_list = []
?
? ? def error(self, reqId, errorCode, errorString):
? ? ? ? print("Error: ", reqId, " ", errorCode, " ", errorString)
?
? ? def tickByTickAllLast(self, reqId, tickType, time, price, size, tickAtrribLast, exchange, specialConditions):
? ? ? ? print("Tick Price. Ticker Id:", reqId, "tickType:", TickTypeEnum.to_str(tickType), "Price:", price,?
? ? ? ? ? ? ? ? "tickAtrribLast:", tickAtrribLast, "specialConditions:", specialConditions,? end=' ')
? ? ? ? print("_______________________")
? ??

app = TestApp()
?
app.connect("127.0.0.1", 4002, 0)
? ??
? ? # allow time to connect to server
time.sleep(1)
? ??
contract = Contract()
contract.symbol = "AAPL"
contract.secType = "STK"
contract.exchange = "SMART"
contract.currency = "USD"
contract.primaryExchange = "NASDAQ"
?
app.reqMarketDataType(4)? # switch to delayed-frozen data if live is not available
app.reqTickByTickData(1 ,contract, "Last", 0, True)
#app.reqMktData(1, contract, "", False, False, [])
?
api_thread = threading.Thread(target=app.run)
api_thread.start()
?

Error message:

Error:? -1? ?2104? ?Market data farm connection is OK:usfarm
Error:? -1? ?2106? ?HMDS data farm connection is OK:ushmds
Error:? -1? ?2158? ?Sec-def data farm connection is OK:secdefil
Error:? 1? ?10189? ?Failed to request tick-by-tick data.No market data permissions for ISLAND STK. Requested market data requires additional subscription for API. See link in 'Market Data Connections' dialog for more details.


Re: Flushing the Incoming Message Buffer - C++ Multi-threading

 

Thanks Hilmar.

After digging into the API code and seeing how the messages were handled I realised the answer to my question was "NO" it is not possible. Also, as you mention, checking/clearing the message deque would not be sufficient if the messages hadn't even arrived yet.


I have modified my model to cater for such "late" data and so far so good. It meant adding a mutex around the display buffer (separating updates from clearing) which might impact code speed but doesn't really matter since this is all user interface stuff.


4AM opening price (not official one) but real one in timestamp

 

Anyone can tell me what tick i need to use to get 4 AM opening price in IBKR api. IB providing official price which has atleast 100 shares and i need the one which first in time stamp and can be any size.
I making scirpt which need find 4 am opening price for 1 year. .can anyone give me right command.. and how to get that in live?

Thanks


Re: About commissionReport.realizedPNL

 

¿ªÔÆÌåÓý

There is a ¡®realizedPNL¡¯ column you can view in TWS as well to see how it works. Basically yes I believe it is calculated for each closing trade, but not necessarily based on the average cost: if you specify ¡¯tax lots¡¯ it is based on the opening cost of the lot you matched the closing trade with. In absence of specifying lots, it will be based on your default setting (which is most likely FIFO if you didn¡¯t change it in the config).

RealizedPNL does get reset every day. Unrealized PNL is your PNL to date on all open positions. So as you make dailyPNL (also reported in TWS) that adds to your unrealizedPNL. Then once you close the trade it goes from unrealizedPNL to realizedPNL but stays in your dailyPNL. ?RealizedPNL and obviously also dialyPNL get reset every day.?

Bart


On Jul 26, 2022, at 2:54 PM, ´³¨¹°ù²µ±ð²Ô Reinold via groups.io <TwsApiOnGroupsIo@...> wrote:

The short answer is yes, realizedPNL in commissionReports for trades that reduce a position include (the loss from) commissions.

We do not use the realizedPNL field from comission reports so we have no practical experience of exactly how realizedPNL is calculated, especially if you have scenarios with multiple entry trades at different prices and an overlapping partial exit trade. But I assume it is based upon the "average cost" as reported by which does get adjusted at every trade. I also cannot say for sure whether the daily PNL reset applies to realizedPNL reported in commission reports.

I grabbed a quick example from our object log that shows trading one ES future contract each. Exit trades were made with 1 tick profit or loss (e.g. $12.50 profit or loss from price differences). Below the relevant commissionReport fields tor those? four trades.

´³¨¹°ù²µ±ð²Ô

Action Quantity Commission RealizedPNL
Entry 1 contract $2.15 UNSET
Exit with 1 tick profit 1 contract $2.15 $8.20
Entry 1 contract $2.15 UNSET
Exit with 1 tick loss 1 contract $2.15 -$16.80


Re: About commissionReport.realizedPNL

 

The short answer is yes, realizedPNL in commissionReports for trades that reduce a position include (the loss from) commissions.

We do not use the realizedPNL field from comission reports so we have no practical experience of exactly how realizedPNL is calculated, especially if you have scenarios with multiple entry trades at different prices and an overlapping partial exit trade. But I assume it is based upon the "average cost" as reported by which does get adjusted at every trade. I also cannot say for sure whether the daily PNL reset applies to realizedPNL reported in commission reports.

I grabbed a quick example from our object log that shows trading one ES future contract each. Exit trades were made with 1 tick profit or loss (e.g. $12.50 profit or loss from price differences). Below the relevant commissionReport fields tor those? four trades.

´³¨¹°ù²µ±ð²Ô

Action Quantity Commission RealizedPNL
Entry 1 contract $2.15 UNSET
Exit with 1 tick profit 1 contract $2.15 $8.20
Entry 1 contract $2.15 UNSET
Exit with 1 tick loss 1 contract $2.15 -$16.80


Re: DAX data feed via API

Matthias Frener
 

Exchange field on the contract as changed from DTB to EUREX.
Not sure how this works via najatrader, but if you need an exchange code this might be the reason (haven't checked if they also got new conId)


Re: About commissionReport.realizedPNL

 

Thanks for your help.

I think?"realizedPNL = -commission" is exactly what I want.It's a great idea.
when the actual PNL shows, is it with or without commission?


--

------
Forex trader
David Liao


Re: About commissionReport.realizedPNL

 

Thanks for your help.
As to UNSET_DOUBLE constant, is it a double if I use ' If type(commissionReport.realizedPNL)==double:


------
Forex trader
David Liao


Re: Flushing the Incoming Message Buffer - C++ Multi-threading

 

Even after you cancel a request there may be messages wandering around the Internet that may appear many seconds later.

You need to accept any message at any time. If you receive tick data you're no longer interested in then you need to ignore.it.


DAX data feed via API

 

¿ªÔÆÌåÓý

Hi,

?

I trade DAX with Ninjatrader connected to Interactive Brokers via TWS (connect to API).

?

Since Monday, no data is available for DAX futures when I connect Ninjatrader to TWS to get data feed.

?

DAX futures cannot be traded as if the instrument is not known.

?

Have someone heard of any problem ? Any solution ?

?

Thanks

?

David G


Re: Flushing the Incoming Message Buffer - C++ Multi-threading

 

On Tue, Jul 26, 2022 at 06:09 PM, David Armour wrote:
after the display and buffer are cleared.
...this means that this is also after all the market data subscriptions have been cancelled.


Flushing the Incoming Message Buffer - C++ Multi-threading

 

I have a C++ GUI application which on which at a user request, the list of symbols will be cleared and all the market data requests will be cancelled, and ultimately the buffer holding the records for the GUI display is cleared.

The issue I have is that every now and again I get a crash because there are still incoming tick messages (price, volume, etc.) in the queue after the display and buffer are cleared.

Is there any way I can test the incoming message queue to see if there are any messages to process? Is there a way to clear that queue to prevent further GUI update calls from the reader thread?


Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows

 

Great! Here you have tha API reference guide, and also the function which gets the account information:



it displays an important?message: "Important:?only?two?active summary subscriptions are allowed at a time!" So if you press the button more times maybe you will get unexpected behaviour or no data sent from TWS.?

Hope this helps

El lun, 25 jul 2022 a las 14:59, <redcorolla95@...> escribi¨®:
Here's the screenshot of what I just downloaded today.
I realized the problem goes away if I don't change to an xlsx file and leave it in xls - then its like all the lines are populated at once instead of waiting for a few seconds each line like this.


Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows

 

Here's the screenshot of what I just downloaded today.
I realized the problem goes away if I don't change to an xlsx file and leave it in xls - then its like all the lines are populated at once instead of waiting for a few seconds each line like this.


Re: TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows

 

Sorry I do not understand your problem, you downloaded?your account info and it sends you 5/10/40 rows? Could you explain please? And also an image of the issue would help.


El dom, 24 jul 2022 a las 10:04, <redcorolla95@...> escribi¨®:
Hi all, new to this forum and ActiveX API here.
Started using the standard sample TwsActiveX.xls and trying to get it download my account info.
But after downloading about 5/10/40 rows it stops downloading anymore rows.? (This seemed to work on Wed, but yesterday and today it's not working).
Am I missing something on my configurations??