Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
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.
|
||||||||||||||||||||
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
|
||||||||||||||||||||
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. 闯ü谤驳别苍
|
||||||||||||||||||||
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 |
||||||||||||||||||||
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. |
||||||||||||||||||||
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. |
||||||||||||||||||||
TwsActiveX - downloading Account info on sample worksheet stuck after 1-2 dozen rows
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?? |
||||||||||||||||||||
Re: About commissionReport.realizedPNL
Brendan is correct about the UNSET_DOUBLE or Double.MAX_VALUE the various languages use to indicate "undefined value". The same is true for integer fields where the Integer.MAX_VALUE (2^31)-1 = 2,147,483,647 is used as the UNSET_INTEGER indicator. You should get "undefined realizedPNL" only for commission reports of entry trades, since there is no PNL from price changes yet. Commission reports for exit trades will show the actual realized PNL for that trade. Depending on how you think about PNL, you could set "realizedPNL = -commission" for entry positions (when realizedPNL is undefined) since the commission you pay for entering into the position is a small loss right from the start. 闯ü谤驳别苍 On Thu, Jul 21, 2022 at 12:37 PM, Brendan Caffrey wrote:
|
||||||||||||||||||||
Re: SPX Betas?
I'm afraid unless someone here is feeling generous you are going to have to 1) get the price feeds, 2) do the maths according to your own flavouring and 3) make it robust to all the errors, data failures and other issues that are part of real trading. If you have problems with 1) or 3) we are definitely the right place to ask. 2) is more of a personal choice. Best of luck with it all, M On Thu, 21 Jul 2022, 16:47 , <jthechu365@...> wrote: Hi all - new to this forum, hoping to learn a lot here!? |
||||||||||||||||||||
Re: About commissionReport.realizedPNL
That value (1.797...e+308) is the maximum value a double can hold. IB uses that to indicate the value is unset. In the C++ API code, they have an UNSET_DOUBLE constant that you can compare against, there may be something similar in the python code. Also, my python is a little rusty, but I think you need to pass an array to writerow, something like: writer.writerow([commissionReport.realizedPNL]) On Thu, Jul 21, 2022 at 10:01 AM <david03kimo@...> wrote: When I execute an order I get the?commissionReport.But I cannot read the?commissionReport.realizedPNL such like?1.7976931348623157e+308. |