Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: Timestamp is missing milliseconds in tickByTickAllLast
It does take a bit of time for the server to take a snapshot of the time to the closest millisecond, compose the message, send it down the pipe to your computer. By the time is does all of this, time has passed by.
On Wednesday, August 10, 2022 at 07:37:25 p.m. PDT, Millie Joyner <mdavis00@...> wrote:
I'm comparing the ms timestamp that IB sends in RT_TRD_VOLUME (presumably exchange time) to the time my computer receives that message from the API.? IB's timestamp is always earlier than my computer's time but the difference varies systematically from approx 50ms to 1000ms, which makes me very suspicious of the accuracy of that timestamp. Here's an example of some typical timing observations from this evening Local=21:53:14.690? RT_TRD_VOLUME=21:53:14.569? Delay=0.121 sec
Local=21:53:37.439? RT_TRD_VOLUME=21:53:37.310? Delay=0.130 sec
Local=21:53:55.157? RT_TRD_VOLUME=21:53:54.935? Delay=0.223 sec
Local=21:54:32.918? RT_TRD_VOLUME=21:54:32.598? Delay=0.321 sec
Local=21:55:12.783? RT_TRD_VOLUME=21:55:12.355? Delay=0.429 sec
Local=21:55:44.538? RT_TRD_VOLUME=21:55:44.003? Delay=0.536 sec
Local=21:56:33.214? RT_TRD_VOLUME=21:56:32.559? Delay=0.655 sec
Local=21:56:33.222? RT_TRD_VOLUME=21:56:32.559? Delay=0.663 sec
Local=21:57:17.301? RT_TRD_VOLUME=21:57:16.536? Delay=0.765 sec
Local=21:57:53.561? RT_TRD_VOLUME=21:57:52.696? Delay=0.865 sec
Local=21:58:52.949? RT_TRD_VOLUME=21:58:51.983? Delay=0.966 sec
Local=21:59:10.079? RT_TRD_VOLUME=21:59:09.106? Delay=0.973 sec?
Local=21:59:44.829? RT_TRD_VOLUME=21:59:44.753? Delay=0.076 sec? <-- resets back to 76ms
Local=21:59:51.043? RT_TRD_VOLUME=21:59:50.963? Delay=0.080 sec
Local=21:59:59.960? RT_TRD_VOLUME=21:59:59.779? Delay=0.181 sec
Local=22:00:04.979? RT_TRD_VOLUME=22:00:04.789? Delay=0.190 sec
Local=22:00:21.766? RT_TRD_VOLUME=22:00:21.517? Delay=0.249 sec |
Re: Timestamp is missing milliseconds in tickByTickAllLast
I'm comparing the ms timestamp that IB sends in RT_TRD_VOLUME (presumably exchange time) to the time my computer receives that message from the API.? IB's timestamp is always earlier than my computer's time but the difference varies systematically from approx 50ms to 1000ms, which makes me very suspicious of the accuracy of that timestamp.
Here's an example of some typical timing observations from this evening Local=21:53:14.690? RT_TRD_VOLUME=21:53:14.569? Delay=0.121 sec
Local=21:53:37.439? RT_TRD_VOLUME=21:53:37.310? Delay=0.130 sec
Local=21:53:55.157? RT_TRD_VOLUME=21:53:54.935? Delay=0.223 sec
Local=21:54:32.918? RT_TRD_VOLUME=21:54:32.598? Delay=0.321 sec
Local=21:55:12.783? RT_TRD_VOLUME=21:55:12.355? Delay=0.429 sec
Local=21:55:44.538? RT_TRD_VOLUME=21:55:44.003? Delay=0.536 sec
Local=21:56:33.214? RT_TRD_VOLUME=21:56:32.559? Delay=0.655 sec
Local=21:56:33.222? RT_TRD_VOLUME=21:56:32.559? Delay=0.663 sec
Local=21:57:17.301? RT_TRD_VOLUME=21:57:16.536? Delay=0.765 sec
Local=21:57:53.561? RT_TRD_VOLUME=21:57:52.696? Delay=0.865 sec
Local=21:58:52.949? RT_TRD_VOLUME=21:58:51.983? Delay=0.966 sec
Local=21:59:10.079? RT_TRD_VOLUME=21:59:09.106? Delay=0.973 sec?
Local=21:59:44.829? RT_TRD_VOLUME=21:59:44.753? Delay=0.076 sec? <-- resets back to 76ms
Local=21:59:51.043? RT_TRD_VOLUME=21:59:50.963? Delay=0.080 sec
Local=21:59:59.960? RT_TRD_VOLUME=21:59:59.779? Delay=0.181 sec
Local=22:00:04.979? RT_TRD_VOLUME=22:00:04.789? Delay=0.190 sec
Local=22:00:21.766? RT_TRD_VOLUME=22:00:21.517? Delay=0.249 sec |
Re: How to check connection to TWS?
开云体育The specific issue in your code below is that nextValidID() is a function called by EWrapper with the next valid orderId as a parameter – it is not a variable that holds the orderId, and it is not a function that your code should ever need to directly call.? You trigger the nextValidId() function (and therefore can retrieve the orderId it contains as a parameter) by using the reqIds() function.? It’s in the documentation here: ? On the bigger question of checking connections there are several issues to consider, covered in various questions in the archive. ?Some quick (incomplete) thoughts are:
? ? Dave ? ? ? ? From: [email protected] <[email protected]> On Behalf Of GreenGreen via groups.io
Sent: Wednesday, 10 August 2022 12:51 AM To: [email protected] Subject: [TWS API] How to check connection to TWS? ? Since TWS restarts daily, I assume we need to reconnect our API clients or at least check for connection. Here is my code to check for connection (Python): from ibapi.client import EClient from ibapi.wrapper import EWrapper import threading ? class TestApp(EWrapper, EClient): ? ? def __init__(self): ? ? ? ? EClient.__init__(self, self) ? ? ? ?? ? ? ? def error(self, reqId, errorCode, errorString): ? ? ? ? print("Error: ", reqId, " ", errorCode, " ", errorString) ? app = TestApp() app.connect("127.0.0.1", 4002, 0) api_thread = threading.Thread(target=app.run) api_thread.start() -------------------------------------------------------------------------- AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last) Input In [2], in <cell line: 1>() ----> 1 app.nextValidID ? AttributeError: 'TestApp' object has no attribute 'nextValidID' --------------------------------------------------------------------------- AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last) Input In [3], in <cell line: 1>() ----> 1 app.nextorderId ? AttributeError: 'TestApp' object has no attribute 'nextorderId'
|
Re: Invalid value in field # 541
TWS talks with IBKR with the Financial Information Exchange protocol (FIX). Field #541 in that protocol is defined as "MaturityDate" and needs to have the format "yyyymmdd". Any chance you are placing an order for a Future, Option, or Warrant? In that case, make sure the in the Contact object is formed correctly. 闯ü谤驳别苍
|
Re: How do I run my code on while closing TWS application?
Hello, Tws is the most common interface to IB, and most people will use it or the gateway (no UI version) for connecting. You'll need something running to connect to IB from. As for jupyter I expect you'll want to run that code every now and then and you'll probably find that easier in a script rather than a work book.? IBC is a method for controlling the tws instances and helping navigate past the bits that usually require human intervention. Lastly, you may want to think about running a dockerised container solution if your objective is to not be running on your own machine, this would make it much easier to use someone else's hardware like aws. Best of luck with it, M On Tue, 9 Aug 2022, 18:45 , <taikilazos@...> wrote: Hello. I am new to this field and I wrote my code in jupyter notebook (for better readability for myself). The code is working but I want to run my code while I am sleeping/closing my computer. I see that IBController by Richard L King is recommended by Dmitry but I wonder whether there are other methods to run my code 24/7 without starting my computer or TWS app. |
Re: Software version upgrade, recommendations?
While we use the direct links for automated downloads of TWS and IBGW installers, we check this site for the current official version numbers for the "stable", "latest", and "beta" tracks: The "stable" version recently changed from the 981 to the 10.12 series and is, at this very moment, 10.12.2q, as you experienced. I am not aware of an official link for prior versions of TWS/IBGW. Significant changes took place between the 981 and 10.12 versions in support of crypto currency trading, for UI feature updates in TWS (JxBrowser with Google Chromium integration), and others. We have problems with certain market data items in TWS 10.12 in our (remote Linux) environment and I was a little surprised that 10.12 became the "stable track". We had filed tickets for those issues a while back but they still exist in 10.12.2q. But is looks like they are gone in 10.16.1n, which was the "latest" version just a couple weeks ago. 闯ü谤驳别苍 |
How do I run my code on while closing TWS application?
Hello. I am new to this field and I wrote my code in jupyter notebook (for better readability for myself). The code is working but I want to run my code while I am sleeping/closing my computer. I see that IBController by Richard L King is recommended by Dmitry but I wonder whether there are other methods to run my code 24/7 without starting my computer or TWS app.
thanks in advance TP |
Re: Software version upgrade, recommendations?
I'm trying to download the 981.3 version of IB Gateway using this link but it currently offers Version 10.12.2q instead.
WINDOWS Is it ok to use this version or is 981.3 still considered the stable version? If so, is there a link to download that version? Thanks in advance for any input! |
Re: Timestamp is missing milliseconds in tickByTickAllLast
IB's timestamps are likely generated from IB's server and not the exchange's timestamp.? I've watched IB server time via reqCurrentTime() and usually observe the server time drifting slower over the course of 4-5 minutes until its about 1 sec behind.? Then it resets back to the correct time and the process repeats.?
While not tick-by-tick, reqMktData will return a timestamp with milliseconds but it has the same time drift problem.? Millisecond precision isn't very useful if the accuracy is only 1000 ms. |
How to check connection to TWS?
Since TWS restarts daily, I assume we need to reconnect our API clients or at least check for connection. Here is my code to check for connection (Python):
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
import threading
?
class TestApp(EWrapper, EClient):
? ? def __init__(self):
? ? ? ? EClient.__init__(self, self)
? ? ? ??
?
? ? def error(self, reqId, errorCode, errorString):
? ? ? ? print("Error: ", reqId, " ", errorCode, " ", errorString)
?
app = TestApp()
app.connect("127.0.0.1", 4002, 0)
api_thread = threading.Thread(target=app.run)
api_thread.start() Then I try:? app.nextValidID it returns the following error:? --------------------------------------------------------------------------
AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last)
Input In [2], in <cell line: 1>()
----> 1 app.nextValidID
?
AttributeError: 'TestApp' object has no attribute 'nextValidID'
I also tried:? app.nextorderId Here is error message again. ---------------------------------------------------------------------------
AttributeError? ? ? ? ? ? ? ? ? ? ? ? ? ? Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 app.nextorderId
?
AttributeError: 'TestApp' object has no attribute 'nextorderId'
What is the proper way to check for connection? |
How to get delayed market data for Req-tick-by-tick
I'm starting to get familiar with the TWS Java API with the help of the sample TestJavaClient.
However when I attempt to request tick by tick data I get an error:
I enabled delayed market data so am unsure why this is. Is it possible to get delayed tick by tick data or is there something I'm missing. Any help would be appreciated. |
Re: Live trading account did not sent PRE_SUBMITTED and instead sent SUBMITTED for non triggered stop limit orders as opposed to Paper Trading Account which sent PRE-SUBMITTED for non triggered orders
You may want to review three documents that relate to your question:
You would only see the PreSubmitted state if IBKR simulates Stop-Limit orders for the instrument and exchange you trade. 闯ü谤驳别苍 |