Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: TWS Closing
I recently experienced the exact same problem as Yilin Qin described, however it is with IB Gateway, not TWS. I ended up changing from IB Gateway to TWS (reluctantly).
As Yilin rightly pointed out, there is no good solution. IB have been through all my logs, good days and bad, and all they can suggest is to change to a different internet connection. That, for me, isn't an alternative. I restart TWS at least once during the week, and that seems to make the problem go away. KH |
Re: Duplicate Order ID
开云体育Ok, I’ll take your word for the ‘whatif’ aspect. ? If I use the contract parameters you specify in my platform, it works fine. If it doesn’t work for you, you must get an error message (assuming your request is actually being actioned by the API). So what is the error message? ? I don’t normally use FDXM but I just pushed an order through on the paper trading system and it executed immediately. For what it’s worth, here’s the log entry that shows the order API message (I have my own API implementation that can log all API messages, similar to the TWS API logfile but rather easier to use). It may not be much use to you in this context: ? 2022-07-29 19:35:37.819 S [IBAPIV100.BufferedWriter:logSocketOutputMessage] OUT: Msg Id (PLACE_ORDER)=3;Version=45;Order id=268445460;ConId=534005999;Symbol=DAX;Sec type=FUT;Expiry=20220916;Strike=0;Multiplier=5;Exchange=EUREX;Currency=EUR;Local Symbol=FDXM SEP 22;Action=BUY;Quantity=1;Order type=MKT;TIF=DAY;OpenClose=O;Origin=0;Transmit=1;Parent id=0;Block Order=0;Sweep to fill=0;Display Size=0;Trigger method=0;Outside RTH=0;Hidden=0;Discretionary amount=0.0; Short Sale Slot=0;Exempt Code=-1;Oca type=0;All or none=0;E-trade only=0;Firm quote only=0;Auction strategy=0;Override percentage constraints=0;Continuous update=0;Opt Out Smart Routing=0;Not held=0;Delta Neutral=0;WhatIf=0;Solicited=0;Randomize size=0;Randomize price=0;Conditions Count=0;AdjustableTrailingUnit=0;DontUseAutoPriceForHedge=0; ? And here’s the resulting execution: ? 2022-07-29 19:35:38.187 S [IBAPIV100.BufferedReader:EndLogMessage] IN: Msg id (EXECUTIONDATA)=11;ReqId=-1;OrderId=268445460;Con Id=534005999;Symbol=DAX;Sec type=FUT;Expiry=20220916;Strike=0.0;Right=;Multiplier=5;Exchange=EUREX;Currency=EUR;Local Symbol=FDXM SEP 22;TradingClass=FDXM;Exec id=0000e9b5.62e36263.01.01;Exec Time=20220729? 19:35:38;Account id=DU5263;Exchange=EUREX;Side=BOT;Shares=1;Price=13508.00;Perm Id=2048695160;Client id=194362192;Liquidation=0;Cum Qty=1;Avg Price=13508.00;OrderRef=;EvRule=;EvMultiplier=;Model Code=;Last Liquidity=1; ? Richard ? From: [email protected] <[email protected]> On Behalf Of Metrodus79
Sent: 29 July 2022 19:29 To: [email protected] Subject: Re: [TWS API] Duplicate Order ID ? Hello Richard, |
Re: TWS Closing
Hi, This may be related to Mike's case. It happens during the reboot in 闯ü谤驳别苍's post.? But IBKR TWS server remain?offline long enough during midnight reboot. What happens to the TWS workstation is that it will automatically reconnect every some?seconds until it reaches the maximum attempts/time without success. Then it seems to?lose?the authentication setup/token on the application side and I get an 'Invalid User or Password' error message in the TWS workstation and hangs there waiting for?input. Some older posts mentioned this behavior but there is no good solution. Thank you. Best, Yilin On Fri, Jul 29, 2022 at 1:53 PM 闯ü谤驳别苍 Reinold via <TwsApiOnGroupsIo=[email protected]> wrote: Are you getting any error messages, such as code 1100 before TWS closes? |
Re: Duplicate Order ID
Hello Richard,
you can use this object with this parameters without any problems when you set the ".whatIf = 1" because it gives you only information back like your margin conditions and your equityWithLoan before and after this order will be set. I had never a problem with this. Of course you cant use this parameters to set an real order. With objTWSControl.m_orderInfo ???? .Action =? "BUY" ???? .totalQuantity = 1 ???? .orderType = "STP" ???? .auxPrice = 1 ???? .timeInForce = "DAY" ???? .whatIf = 1 End With Public Sub M_REAL_ORDER_MARGIN_AKTUALISIERUNG(orderid As Long, contract As TWSLib.IContract, order As TWSLib.IOrder, orderState As TWSLib.IOrderState) ????????? =orderState.warningText ??????? ? =orderState.equityWithLoanAfter ????????? =orderState.initMarginChange ????????? =orderState.maintMarginChange ????????? =orderState.equityWithLoanAfter end sub Do you maybe trade FDXM from Eurex? Thanks a lot too for your reply. Everything could help me to figure out that problem. |
Re: opt out from: Secure Login required for trading
toggle quoted message
Show quoted text
|
Horizontal / Vertical Trendline on IB Charts using API
Hello
Long time lurker & my first post here. I must say this group is a wealth of knowledge and I really appreciate all the insights / knowledge I have gained browsing. Still early in my IB API journey but making slow & steady progress. I am wondering if there is way using the TWS API to add vertical / horizontal trendline to an IB Chart. I did go thru the IB API documentation online and also the history here and it does not appear this is possible. Nevertheless, I thought I would check and confirm in case I have missed out some fork in the road. My inquiry is specifically related to native IB charting in TWS and not any third party app. Cheers L |
Re: opt out from: Secure Login required for trading
IBKR has several standard and custom integration options for institutions and large clients and you can even co-locate your servers with them. Some of the more common options What you describe very likely does not use TWS API. Maybe they use FIX CTCI or even a much tighter custom integration. 闯ü谤驳别苍 |
Re: opt out from: Secure Login required for trading
开云体育Thank you for the info.There are some websites that claim they can connect to an IB account without PW/2FA, by providing a photoID+IB account#+form signed by the account holder, and then the connection would happen without supplying PW/2FA. eg
?claims this.?
I verified with IB in the past as I was suspicious and IB confirmed they indeed have a ‘backend integration’ with that site (they didn’t say more or how it is done, likely for security purposes). I didn’t understand how this was possible since all IB APIs
require the auth, but it might be the ‘account of accounts’ approach you mention.?
Anyone has any insight if IB would add an existing account you don’t own under your master account to allow trading in it by providing this information, likely only for certain ‘approved’ entities?
|
Re: TWS Closing
Are you getting any error messages, such as code 1100 before TWS closes?
toggle quoted message
Show quoted text
Any clues in the TWS logs? Could there be network disruptions between TWS and IBKR (such as router/modem restarts, DHCP IP renewals, ...)? Is it possible you experience Java JVM crashes? We see brief TWS disconnects every night during the , which is at 23:45 - 00:45 ET during the week for US based IBKR systems. These are always brief enough so that TWS never closes and stays authenticated without causing client disconnects. This week they took place at (Central Time) SUN??? 2022-07-24 23:16:37.843-0500 闯ü谤驳别苍 On Fri, Jul 29, 2022 at 08:43 AM, Mike wrote:
All, |
Re: opt out from: Secure Login required for trading
开云体育Just to add to what 闯ü谤驳别苍 said, you can get IBC from its GitHub repository at: ? ? Richard ? From: [email protected] <[email protected]> On Behalf Of 闯ü谤驳别苍 Reinold via groups.io
Sent: 29 July 2022 18:27 To: [email protected] Subject: Re: [TWS API] opt out from: Secure Login required for trading ? We don't have a need for "other users" to connect to our back-end and it would probably be quite a challenge to make that secure. While each TWS/IBGW instance can only log into one account, that can be an "account of accounts" in case the various accounts are linked together. That does not necessarily mean all accounts have to have the same owner. In that case, a single client can trade for all linked accounts by simply adding the relevant account number when placing orders. And during login, 2FA is only required for that "account of accounts". If the accounts are not linked, individual instances of TWS/IBGW plus client application have to be started. You can automate that with Richard King's IBC and there are several discussions over at /g/ibcalpha/topics how to setup IBC such that 2FA during login takes place on a mobile device that can be far away from where IBC/TWS/IBGW run. 闯ü谤驳别苍 On Fri, Jul 29, 2022 at 11:29 AM, bart decanne.com wrote:
|
Re: Duplicate Order ID
开云体育Robert ? You have set .auxPrice = 1 for the DAX contract. The auxPrice field is the trigger price for your stop order. For EUR.USD that is a possible value since the current price for this contract is around 1.019. But the current DAX price is around 13486, so your trigger price of 1 is completely unreasonable and is almost certainly being rejected with an error message. ? You are handling errorMsg events, presumably? If not, you stand no chance of getting the API to do anything useful… ? Richard ? ? From: [email protected] <[email protected]> On Behalf Of Metrodus79
Sent: 29 July 2022 13:27 To: [email protected] Subject: Re: [TWS API] Duplicate Order ID ? Hello 闯ü谤驳别苍, |
Re: opt out from: Secure Login required for trading
We don't have a need for "other users" to connect to our back-end and it would probably be quite a challenge to make that secure. While each TWS/IBGW instance can only log into one account, that can be an "account of accounts" in case the various accounts are linked together. That does not necessarily mean all accounts have to have the same owner. In that case, a single client can trade for all linked accounts by simply adding the relevant account number when placing orders. And during login, 2FA is only required for that "account of accounts". If the accounts are not linked, individual instances of TWS/IBGW plus client application have to be started. You can automate that with Richard King's IBC and there are several discussions over at /g/ibcalpha/topics how to setup IBC such that 2FA during login takes place on a mobile device that can be far away from where IBC/TWS/IBGW run. 闯ü谤驳别苍 On Fri, Jul 29, 2022 at 11:29 AM, bart decanne.com wrote:Jurgen, I totally agree with your assessment about the need for 2FA.? |
Re: Duplicate Order ID
Glad the duplicate order is gone now, Robert. I was not suggesting a multi-threaded design to avoid "sleep" between requests and responses. Just an event-oriented design. I am not a VBA/Excel macro practitioner, but I believe they do have an event model that supports an event oriented/reactive application design that entirely removes the need for blocking/wait/sleep between request and response. Not sure what to tell you about the DAX order not working other than the standard checklist. Are you sure your code properly catches and reports all API errors? If you can't get an error to display, this would be a good case for the TWS log, since you'd want to know what TWS thinks you have sent and what the response is. On Fri, Jul 29, 2022 at 07:26 AM, Metrodus79 wrote:
|
Re: opt out from: Secure Login required for trading
开云体育Jurgen, I totally agree with your assessment about the need for 2FA.?One question: is your system allowing other users to connect to your backend? If so how do you handle them entering their PW/2FA code securely so your backend can connect to their accounts? There are some robotrading sites that do that and just wonder
how it is implemented.? On Jul 29, 2022, at 8:33 AM, 闯ü谤驳别苍 Reinold via groups.io <TwsApiOnGroupsIo@...> wrote:
|
Re: opt out from: Secure Login required for trading
Not sure why you even want to opt out of 2FA for login. Remember, we are talking about brokerage accounts with real money and possibly significant balances. Simple password-only authentication is way too vulnerable and 2FA is pretty much the standard all over the WEB even for sites with negligible significance compared to brokerage accounts. We use 2FA for years and the only impact is that we have to type a few numbers during login once a week when we start TWS. After that, TWS restarts automatically once a day and no password nor 2FA is required. Client applications trade via TWS API without any need for 2FA since that is a login-only activity. You obviously want to make sure the systems that run TWS/IBGW and your client applications have adequate security measures while TWS/IBGW is authenticated with IBKR. 闯ü谤驳别苍 On Fri, Jul 29, 2022 at 09:38 AM, ajn wrote:
|
Re: opt out from: Secure Login required for trading
I think being?forced to use 2FA for logging in to TWS is coming to North America as well. I use IB through another introducing broker, and they sent an email last week stating that due to a policy change, everyone had to enable 2FA for logging in to TWS. Maybe if enough people complain IB will reverse course? On Fri, Jul 29, 2022 at 10:38 AM ajn <andrei.jefremov@...> wrote:
|
opt out from: Secure Login required for trading
I cannot opt out from 2fa for trading in one of my accounts (and my relative has same issue). Note, I am not talking about disabling 2fa altogether, just for trading. aj ? |
Re: TWS Closing
toggle quoted message
Show quoted text
On Jul 29, 2022, at 9:54 AM, mark collins <mark.collins@...> wrote:
|
Re: TWS Closing
Tws will restart automatically every day. It's a legacy thing that's been in tws for as long as I can remember. There are settings for selecting when and how it restarts in the preferences menu Best wishes, M On Fri, 29 Jul 2022, 14:43 Mike via , <m_saracena=[email protected]> wrote: All, |