Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Locked
Re: Like to create my own stripped down API using current C# sockets version
Thank you!!..? Yes, I would like to see both examples.? I have been working on my trading program for close to 20 years, and
I live in fear of having a new version of API, or even a glitch, that stops me dead because I am not familiar with a different language or some new approach to the API. I suspect having? what you are offering posted on this site would be a great help to others who are stronger in their preferred language but forced to? deal with something very new to them to get out of the starting gate!! |
Locked
Re: Like to create my own stripped down API using current C# sockets version
¿ªÔÆÌåÓýYou can use the ActiveX API with VB.Net. It¡¯s now primarily provided for use in VBA (eg in Excel), but it¡¯s a bit clumsy and unintuitive. I think IB made some bad decisions doing that particular piece of work, but nevertheless it is usable. ? I have a sample program written in VB.Net that illustrates how to do this. It includes a simple UI for getting market data, placing/modifying orders, displaying market depth and so on, just enough to do something worthwhile but not to be overwhelming. ? I need to bring that up to date with the latest API updates. It shouldn¡¯t take too long ¨C but probably not today though. ? If this is not of interest to you, let me know, but I think you¡¯d find it helpful. ? I also have a version of this program somewhere that works with the C# API, which could also be helpful because a comparison between the two shows you the differences in approach. And in fact it might be enough to enable you to just use the C# API rather than the ActiveX ¨C the C# one is definitely preferable. ? Richard ? ? ? From: [email protected] <[email protected]> On Behalf Of mmussel2000 via groups.io
Sent: 08 December 2022 16:59 To: [email protected] Subject: [TWS API] Like to create my own stripped down API using current C# sockets version ? I find the IB VB.Net Sample program to be too involved for my use.? I have tried starting from zero to create what I want to call my IB_Host |
Locked
Like to create my own stripped down API using current C# sockets version
I find the IB VB.Net Sample program to be too involved for my use.? I have tried starting from zero to create what I want to call my IB_Host
program, without all of the dialogs etc that are in their sample program. If anyone has already done this, I would like to see your code as well as how to set up the dual projects ( VB and C#) within a single project so it compiles clean and I can add my mature VB.NET trading code in seamlessly.? I have tried approaching this from both ends, first deleting most of their dialogs and dealing with the errors that build up.? I have also tried starting off from zero, referencing the CSharpAPI.dll, and trying to create a new VB.Net project but not able as yet to make the pieces all play together.? I suspect this is not that difficult, but my 75 year old mind does not yet comprehend. To me the Sockets and Wrapper are of little value functionally.? I would prefer the old ActiveX where I can get access to the TWS events and methods.? If an ActiveX model will still work, I would like to see that as well. Appreciate any help...PLEASE!!! |
1min historical data availability
Hello,
From the TWS documentation: However, I tried to source 1 min bars historically backwards from today, and got only up to August 9th (~4 months) on EUR.CAD and EUR.AUD then faced the issue below; why? Note I am able to source? beyond that date on other contracts like EUR.NZD with the same code. reqHistoricalData(request.reqId, contract, end, '1 D', '1 min', 'BID', 1, 2, False, []) ? request_historical_bars EUR CAD 20220809 22:23:00 UTC
request_historical_bars EUR AUD 20220809 22:23:00 UTC
...
ERROR 7 162 Historical Market Data Service error message:HMDS query returned no data: EUR.CAD@IDEALPRO Bid Error. Id: 7 Code: 162 Msg: Historical Market Data Service error message:HMDS query returned no data: EUR.CAD@IDEALPRO Bid
ERROR 8 162 Historical Market Data Service error message:HMDS query returned no data: EUR.AUD@IDEALPRO Bid
Error. Id: 8 Code: 162 Msg: Historical Market Data Service error message:HMDS query returned no data: EUR.AUD@IDEALPRO Bid |
Tick time -- what does it represent?
reqTickByTickAllLast returns a time field with each tick. Which of the following does it represent?
1) The time at which the TWS server received the tick from the exchange 2) The time at which the trade executed at the exchange 3) The time at which the tick arrived at the client (our code) Thank you. |
how do I get the asset details on an option currently held
hi there,?
so I am able to get my held positions, but I can¡¯t figure out how to get the asset details , put/call/strike/expirey/quantity on the held position. I then want to use this info to get the last 5 bars of data on the option. any suggestions? ?I¡¯m doing this in Python. thanks, -- Allan in Toronto. |
Amending LOO orders within 3 seconds of open cut off not being acknowledged by exchange in time
Sydney_dude
Hi, my algo occasionally amends LOO orders (tif=OPG) going to NYSE within 3 seconds of the cut off (which is 5 seconds before open auction). I am regularly getting a situation where these amends are not being acknowledged by the exchange in time and are hence cancelled. Does anyone know if this is just too close to the open cut off for TWS to cope with (should i have a larger time buffer)? Sometimes the orders are in status = presubmit when the algo tries to amend them.....Is amending an order that is still in status = PreSubmit problematic? Am i better off cancel/resubmitting rather than amending? Should i wait for status = submitted before allowing algo to attempt amending it?
Thanks for your help Brendan |
Re: Some responses for multiple, successive reqCurrentTime calls does not get returned
I don't have the documentation reference handy (but will add it once I find it again) but TWS/IBGW will not respond to reqCurrentTime() unless they are at least 1 second apart.
Also, if you think about it, it makes no sense to call reqCurrentTime() a second time until the currentTime() response callback comes in from the first call. reqCurrentTime() does not take a requestId, so how would a client correlate the responses to the requests? ´³¨¹°ù²µ±ð²Ô |
Some responses for multiple, successive reqCurrentTime calls does not get returned
In this simple Python example, the time gets printed only once even though I called
reqCurrentTime twice:from threading import Timer from ibapi.client import EClient from ibapi.wrapper import EWrapper class App(EWrapper, EClient): def __init__(self): EClient.__init__(self, self) def error(self, req_id, code, msg, advanced_order_reject_json=None): print(req_id, code, msg, advanced_order_reject_json) def currentTime(self, time_): print(time_) def main(): app = App() app.connect('127.0.0.1', 4002, 0) app.reqCurrentTime() app.reqCurrentTime() Timer(10, app.disconnect).start() app.run() if __name__ == '__main__': main()However, if I insert time.sleep(1) in between the successive reqCurrent() calls, then the time gets printed twice.In the IB gateway log, it appears the request is sent twice but only one response is returned. Why does this happen? Is it a threading issue? How can I fix this? python ibapi version: 10.19.1 ib gateway version: 10.19.1g |
Re: How to get a list of symbols of all product available?
I realize this is an old thread, but in case anyone is interested, I compiled a database table of?113,728 contracts available through IBAPI's reqMatchingSymbols, dumped it to an SQL file and put it up on gitlab. It can be downloaded here:
https://gitlab.com/jwbwater/ib-contracts |
Re: IB Java API throws "Bad message length null"
That is too early for requests and will definitely invite trouble. As you can see from you should refrain from making any requests until you have received the nextValidID callback:
toggle quoted message
Show quoted text
Important: The IBApi.EWrapper.nextValidID callback is commonly used to indicate that the connection is completed and other messages can be sent from the API client to TWS. There is the possibility that function calls made prior to this time could be dropped by TWS.
´³¨¹°ù²µ±ð²Ô On Mon, Dec 5, 2022 at 03:03 AM, kashyap thakkar wrote: Thank you so much for the in-depth analysis of the issue and suggestions. |
Re: IB Java API throws "Bad message length null"
Thank you so much for the in-depth analysis of the issue and suggestions.
I have found the cause. When we receive a callback "connectAck()" I am requesting "reqPositions" from connectAck() itself.? Once I stopped requesting "reqPositions()"?it stopped throwing the "Bad message length null" error. |
Limit orders, placing limit orders with a certain distance from market price
Hi! I'm developing using the TWS APIs an application to manage/input orders from Excel.
The problem I have now is that inputting orders manually via official TWS? dashboard seems to work "fine" for limit orders: I can, for instance, enter a limit price 10% lower than current best bid price. Using the APIs it seems I cannot and I have to enter prices much closer to the actual market price? ( best current bid for instance) Any help on what could be I am missing?? Thanks |
MOO order "slippage"
I have a strategy that was backtested on daily data from Yahoo Finance, Tiingo, etc. It open/closes positions only at the market open and close.
However, this daily data represents the "consolidated" price across multiple exchanges and not that of the single primary exchange that a MOO order would be routed to. From my research, MOC orders do not have this issue--the closing auction price is almost always the same as the consolidated closing price. 1) In my backtests, I would like model the opening price "slippage", i.e. the difference in consolidated opening price vs. primary exchange opening price.?How should I go about doing this? Is 0.04% of "slippage" reasonable?? Or where can I get historical data for primary exchanges such as ARCA for backtesting purposes? 2) How should I go about reducing this "slippage" in practice? One idea I have is monitoring the ticks across multiple exchanges for the first 5 seconds at market open and then very shortly after 9:30, place a limit order for the average price of those ticks. But this has the the risk of adverse selection and the order never getting filled. Would this risk be decreased for highly liquid stocks? Thank you. |