Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
- Twsapi
- Messages
Search
Re: OCA order types and place in order queue
Ed
Limit orders are native to globex so your profit exit will be at the
toggle quoted message
Show quoted text
exchange. This has nothing to do with oca. The stop is not native so it must be simulated by ib. If you mouse over the profit limit you should see a popup messsage saying the order is at the exchange. On 7/19/2013 11:05 AM, Davqe wrote:
|
OCA order types and place in order queue
Davqe
I'm working on using OCA for my profit and loss orders. It appears that once I set the orders up with an OCA group, they aren't actually sitting at the exchange but rather are on an IB server waiting to be triggered. I'm using ocaType of 1 (Cancel with Block). It is possible to get the orders actually sitting in the queue at the exchange? For futures contracts with a lot of market depth (S&P e-minis for example), I want my profit limit order in the queue as early as possible. If it waits until the price is touched, I'm at the back of the queue at my limit price.
Am I misunderstanding the manner in which this works? Or is there another way to specify the ocaType that will place the order at the exchange and still handle the cancel once one is triggered. |
Re: TwsActivex.xls cannot "request account updates"??
jpgarciaa
This is the method you should call to request account updates
toggle quoted message
Show quoted text
objTWSControl.m_TWSControl.reqAccountUpdates(True, accountName) If you are managing more than one account, make sure to use the right one. Change to False if you want to cancel the updates. JP --- In TWSAPI@..., virusnme <no_reply@...> wrote:
|
Re: Connect to TWS in main not in Thread (Java)
I mainly suggested you choose wisely for your own needs.
toggle quoted message
Show quoted text
If synchronization *is* a bitch and you are using 2 threads and one handles incoming socket messages and the other is handling incoming GUI message, then you may already have some issues on your hands if your have a user interface that initiates socket events and displays results, if not for other reasons. That's why for my preferences use 1 thread rather than 2, knowing I can change this if it became a problem. OTOH with Java's native threading support, if you know how to use it, maybe it is no issue at all. ASIDE: If btw... is a problem for Brian then "twsapi" could be a confusing name for you to be using here (hint hint). It looks like you may both be using yahoo for posting (with "twsapi" also having the no_reply feature), or even as your email client. If you have an outside email client usually you can just set your name for the From field and yahoo seems to honor it in what it passes through. What you can do if you are fully inside yahoo, I don't know, but no surprise if it is crippled to f'ing hell. If you can't get a decent name through you can always name yourself in your signature. I think "twsapi" is still fully anonymous at this point. -Kurt On 7/19/13 2:20 AM, "twsapi" <no_reply@...> wrote:
Hi Brian :), Kurt, |
Re: Connect to TWS in main not in Thread (Java)
twsapi
Hi Brian :), Kurt,
toggle quoted message
Show quoted text
Thanks so much for your help! I will limit myself to just two threads and actually based on also Kurt's comment synchronization can be a bitch so I rather have two open connections in each thread than fumbling around with thread concurrency :) But guys, thanks so much you really helped me a lot! Regards Call me brian :). I have no idea how to change that login name. |
Re: VB6 TWS ActiveX Vs. IB Gateway
I don't know VB, but think it doesn't matter.
toggle quoted message
Show quoted text
1. In all fundamental ways, Gateway works the same as TWS in terms of connections. Since the Gateway has no purpose except to connect to API clients, there is no need to make it an option. 2. TWS.Connect I don't know but yes you have to set the port appropriately. The default port will be different in gateway than TWS, but if you've looked in API - Settings you should have seen and had the opportunity to set the port number and it should be no mystery. You can make the port number the same as TWS if you like, and your setting will be remembered. 3. I don't use ActiveX but it is all the same socket. The Gateway is no different from TWS in fundamental behavior. The system behavior is different in various well-known ways, such as the fact that the gateway lets you stay connected without your having to fight for it. There are probably also subtle differences owing to the fact that they are different executables and also are not necessarily released at the same time, so that bugs may be different. -Kurt On 7/19/13 12:05 AM, "Edbar" <edbar@...> wrote:
I haven't used the gateway yet, but was wondering a few things: |
VB6 TWS ActiveX Vs. IB Gateway
Edbar
I haven't used the gateway yet, but was wondering a few things:
1. Is any pre-configuration required to connect to the gateway from the VB6 program? For instance with TWS you had to go into tws and check "enable activex and socket clients". But I notice that options isn't even there inte gateway configuaration. 2. Do I have to change the TWS.Connect line to connect to the gateway vs connecting to tws? My connect isn't working and I'm wondering if I have to change the port. I've already got the gateway logged in and running but the program doesn't connect to it. 3. Will all the tws activex methods and events work the same with the gateway as they did with tws? Thanks, Ed |
Re: problem with contract details
It is 7/18, and I just noticed the recently slow contract details behavior
toggle quoted message
Show quoted text
seems to have reverted back to what it was previously. -Kurt On 7/15/13 6:31 AM, "dairen62" <no_reply@...> wrote:
Good news... the problem will be fixed on 7/18. We just need to include the |
Re: C# Option Contract Details
not sure of your problem but getting a full option chain for the underlying was never a problem for my code
toggle quoted message
Show quoted text
the biggest problem was getting all the details and it timing out. nick On 7/18/2013 8:45 PM, andrewcmeier wrote:
Sorry, I've been away. |
C# Option Contract Details
andrewcmeier
Sorry, I've been away.
toggle quoted message
Show quoted text
That looks fine, I'm happy that I've got what I need now to download data, havn't been able to retrieve an option chain but I've come up with a workaround that is quicker. Basically I'm downloading the option details from Yahoo in advance, storing the details in a file, then reading this file to download 100 option prices at a time, works out quicker because I can filter it ahead of time and be downloading 100 options at a time rather than 1 stock at a time. The programming to split the 100 options into their stocks is a bit of a pain though. Thanks for your input. --- In TWSAPI@..., "t0ksik" <seventhpoint@...> wrote:
|
Re: problem with contract details
This has indeed been fixed for live and paper trading accounts, but not for edemo
toggle quoted message
Show quoted text
--- In TWSAPI@..., dairen62 <no_reply@...> wrote:
|
TwsActivex.xls cannot "request account updates"??
virusnme
I use TwsActiveX.xls excel sheet to connect to IB Gateway. The connection between IB Gateway and TwsActiveX.xls is fairly stable. However, on occasions when IB Gateway loses connection to IB Server, TwsActiveX.xls loses connection to IB Gateway. Eventually, IB Gateway reinstates a connection to IB server. And I will have to ensure that TwsActivex.xls reconnects to IB Gateway (via VBA).
I have figured out how to re-connect the TwsActivex.xls to IB Gateway but I am not able to "request account updates" via VBA! If anyone has figured out how to do it please do let me know. |
Re: Connect to TWS in main not in Thread (Java)
btw12342001
--- In TWSAPI@..., twsapi <no_reply@...> wrote:
Call me brian :). I have no idea how to change that login name. thanks so much for the tip! That actually helps me a lot. I still did not completely understood your earlier reply on how to handle returned data. In which method is the returned data handled?If you scroll down in Example1.java you will see the tickPrice method. This is overriding the method of the same name in ExampleBase. All data from the TWS socket gets sent to those methods in ExampleBase unless they are overridden. If you want more than one symbol you have to assign an separate id in the request and then do something in tickPrice based on the returned tickerId. I guess if the connection is not limited to just one thread you also run into synchronization issues between the threads. But as far as I understood you can initiate 6 or 8 connections but IB recommends to use as little as possible, is that correct?Yes, only use one connection. You don't even need the thread part, you could delete the "extends thread" part in ExampleBase and then just call run, however there's a thread.sleep in the run method and you would have to fix the logic. I don't know what your purpose is so it's hard to tell you what to do. I wrote a very simple 1 file, console based program in the files section under java. Maybe that will be easier to understand, it's also a netbeans project. |
Re: Connect to TWS in main not in Thread (Java)
Hi,
toggle quoted message
Show quoted text
Breaking in, I have a vague memory there may be people who said they open multiple connections in order to have a dedicated thread for each, but it is highly unusual and probably not necessary. Bottom line is if you do not have specific reason to make your life complicated, don't make your threading model more complex than it needs to be for your well-understood purposes. This certainly does not require multiple connections and you can still spawn threads to handle computations that can be factored in that way, if you like. I suggest you start with a fewest-thread-possible approach. Personally I choose 1 thread and do not use a separate reader thread. Sometimes the environment may present you with a separate reader thread and you can write some code to funnel the results from that back to the main thread. There have been endless arguments here about the incredible importance or incredible unnecessity of having additional threads for this or that. It is a big topic and has been discussed for weeks on end numerous times. If you want to learn about it I suggest your read the archives, but in the meantime stick with 1 thread, or 2 if that comes naturally in your context and you can manage it. A common suggestion is to use a single thread to dispatch data *quickly* to other threads so the main thread is close enough to always available to handle the next incoming message. Anything processed quickly can be handled on that thread and anything not can be put in a queue and handled elsewhere. (Meanwhile just start coding without worrying about that until you need to.) Regarding returned data the easy solution is to always override ALL callback methods and log the results from every callback. Then you have no doubt what data is returned through which callback, in case the documentation is vague about it (or non-existent). -Kurt On 7/16/13 12:45 AM, "twsapi" <no_reply@...> wrote:
Hi btw12342001, |
Re: NKD data
jayfunandgames
Nice, that works. Thanks a lot for the tip.
toggle quoted message
Show quoted text
--- In TWSAPI@..., Ed <news1000@...> wrote:
|
Re: NKD data
Ed
Try omitting local symbol and use expiration date of 201309 instead.
toggle quoted message
Show quoted text
On 7/16/2013 10:06 PM, jayfunandgames wrote:
|
NKD data
jayfunandgames
Trying to request NKD data, buy having a problem.
Using the following info Symbol: NKD Type: FUT Exchange: GLOBEX Local Symbol: NKD SEP 13 This is the format that I used when requesting YM futures, so I'm not sure what I'm doing wrong. Is there a good place that will show you the format needed for the different types of requests? Thanks, Jay |
Re: Tick Encoding/Decoding
Ed
I don't think there is a strict correlation between tick price/size
toggle quoted message
Show quoted text
and RTV. They seem to be completely different streams to me, with different sampling/aggregation. Remember that IB does not send each tick and you get about 3 updates per second. On 7/16/2013 4:15 AM, unatnahs57 wrote:
|
Re: Upcoming stock earnings dates
souqmate
Thanks for the link, rwk and Robert.
toggle quoted message
Show quoted text
Below are the one-liners to scrape Yahoo calendars on linux; cut 'n paste in your xterm (tcsh). European stocks appear in earnings.csv (since 2011), confCalls.csv (since 2013), in surprises.csv (since 2011), not in splits.csv nor ipo.csv. No Japanese stocks, as ramdukof bemoans; any hint welcome! Files with history (confCalls.csv, earnings.csv, ipo.csv, splits.csv, surprises.csv, marcro.csv) are readily available for 7 days at Good luck souqMate. ----------------------- # Earnings: since 19990401 (old format prior 20001031); header: "# Company,Symbol,Time (NY, or Before/After Mkt)" foreach d (19990401 19990402 ... 20130712) wget -q -O - " | sed -n '/>Conference</,/^colspan/H; ${x;s,\n, ,g; s,<td,\n<td,g; p}' | awk 'NR>1 && !(/colspan/)' | sed 's,<[^>]*>,,g; s, , ,g; s,&,\&,g; s/,//g' | awk '{l=NR%4; if(l==1) printf "'$d',"; if(l>0 && l<3) printf $0","; if(l==3){t=""; if(/Before/) t="Before"; if(/After/) t="After"; if(/ET/){split($1,a,":"); if(/pm/) a[1]+=12; t=a[1]":"a[2]} print t}}' >>! earnings.csv end # Conf Calls: since 20111014; header: "# Date,Time (NY),Symbol(if several: separated by blanks),Event" foreach d (20111014 20111015 ... 20130712) wget -q -O - " | sed -n '/>Access</,/size=1/H; ${x;s,\n, ,g; s,<td,\n<td,g; p}' | awk 'NR>1' | sed 's,<[^>]*>,,g; s, , ,g; s,&,\&,g; s/,//g' | awk '{l=NR%4; if(l==1){split($1,a,":"); if(/pm/) a[1]+=12; t=sprintf("%02d:%02d",a[1],a[2]); printf '$d'","t","} if(l==2) printf $0","; if(l==3) print $0}' >>! confCalls.csv end # Surprises, since 20021209; header: "# Date,Company,Symbol,Surprise (%),Reported EPS,Consensus EPS" foreach d (20021209 20021210 ... 20130712) wget -q -O - " | sed 's,</tr><tr,</tr>\n<tr,g; s,&,\&,g; s/,//g' | awk '/^<tr.*td><td$/,/^nowrap/{gsub(/^align/,"<align",$0); gsub(/td$/,"td>",$0); gsub(/<[^>]*>/,"",$0); print}' | awk '{l=NR%7; if(l==1) printf "'$d',"; if(l>0 && l<5) printf $0","; if(l==5) print $0}' >>! surprises.csv end # splits, since Jan 2000; header: "# Payable,Ex Date,Company,Symbol,Optionable?,Ratio,Announced" foreach y (00 01 02 03 04 05 06 07 08 09 10 11 12 13) foreach m (1 2 3 4 5 6 7 8 9 10 11 12) wget -q -O - " | grep ^noshade | sed 's,</table.*,,g; s,<tr,\n<tr,g; s,<td,\n<td,g; s,<[^>]*>,,g; s/,//g; s,&,\&,g; s, *,,g' | grep -v ^noshade | awk 'BEGIN{m["Jan"]=1;m["Feb"]=2;m["Mar"]=3;m["Apr"]=4;m["May"]=5;m["Jun"]=6;m["Jul"]=7;m["Aug"]=8;m["Sep"]=9;m["Oct"]=10;m["Nov"]=11;m["Dec"]=12} {l=NR%9; if(l==2||l==3||l==8){y=2000+'$y'; if(l==3) M=m[$1]; if(l==8 && m[$1]>M) y--; if(NF>0) $0=sprintf("%s%02d%02d",y,m[$1],$2)} if(l>1 && l<8) printf $0","; if(l==8) print $0}' >>! splits.csv end end # IPO pricings, since Jan 1998; header: "# OfferDate,Company,Symbol,SharesOffered[mln],ProposedPric[$],InitialPrice[$]" foreach y (98 99 00 01 02 03 04 05 06 07 08 09 10 11 12 13) foreach m (jan feb mar apr may jun jul aug sep oct nov dec) wget -q -O - " | sed 's,</TR>,</TR>\n,g' | grep '^<tr><td align' | sed 's,<td,\n<td,g; s,>M<,><,g; s,<[^>]*>,,g; s/,//g; s,\$,,g' | awk 'BEGIN{m["Jan"]=1;m["Feb"]=2;m["Mar"]=3;m["Apr"]=4;m["May"]=5;m["Jun"]=6;m["Jul"]=7;m["Aug"]=8;m["Sep"]=9;m["Oct"]=10;m["Nov"]=11;m["Dec"]=12} {l=NR%8; if(l==2){split($1,a,"-"); y=(a[3]>90? 1900:2000)+a[3]; $0=sprintf("%04d%02d%02d",y,m[a[2]],a[1])} if(l>1 && l<7) printf $0","; if(l==7) print $0}' >>! ipo.csv end end # macro-economy, since 20010102; header: "# date,time(NY),indicator,For,Actual,BriefingForecast,Expect,Prior,RevisedFrom" awk 'BEGIN{for(i=2001;i<2013;i++) for(j=1;j<53;j++) printf "%s%02d\n",i,j}' > ! /tmp/i foreach i ( `cat /tmp/i` ) wget -q -O - " | sed -n '/^From/,/^href/{s,<tr,\n<tr,g; s,More in-depth.*$,,; s,<[^<]*>, ,g; s, bcf,bcf,g; p}' | awk 'BEGIN{m["Jan"]=1;m["Feb"]=2;m["Mar"]=3;m["Apr"]=4;m["May"]=5;m["Jun"]=6;m["Jul"]=7;m["Aug"]=8;m["Sep"]=9;m["Oct"]=10;m["Nov"]=11;m["Dec"]=12} !(/^From|^href/){yr=substr('$i',1,4); d=sprintf("%s%02d%02d",yr,m[$1],$2); split($3,a,":"); hr=a[1]; mi=a[2]; if($4=="PM") hr+=12; t=sprintf("%02d%02d",hr,mi); txt=$5; for(n=6;n<NF-5;n++) txt=txt" "$n; OFS=","; print d,t,txt,$(NF-5),$(NF-4),$(NF-3),$(NF-2),$(NF-1),$NF}' >> macro.csv end # caution: prior 20120323, times are wrong: apply UTC2EST twice and subtract 3 hrs to get NY time. Corrected in the uploaded file. Corrections: 20090422 20090121 have Crude Oil at 1030 instead of 1035; and over 20080604-20081231 have it at 1035; over 2005-2010 can find Crude Oil on Wed and subsequent Thu (when holidays; discard Wed entry). Uploaded file is actually in tsv; change to csv: sed 's/,//g; s/\t/,/g' macro.tsv > macro.csv --- In TWSAPI@..., "rwk2095" <r@...> wrote:
|
to navigate to use esc to dismiss