Keyboard Shortcuts
Likes
- Twsapi
- Messages
Search
Re: 5 sec. Bars
Hi souqmate,
thanks for your questions. It happened in the Real account. I did not subscribe to Realtime Ticks No SPY data appeared in the last 32 minutes. I did not look inside TWS to look for bars (I should have, thanks, that is a good idea!!!) I have not tried resubscribing, but I think than the bars would appear again. This is a good idea, I could program sth. that unsubscribes and subscribes the bars whenever there is no bar for more than 10 minutes during opening hours. But still I would have some gaps. Are similar problems appearing with realtime ticks, or would it make sense to use realtime ticks to create the bars ? Thanks, Ernst |
Re: 5 sec. Bars
Scary.? I don't use 5sec (realtime) bars.? Several questions come to mind:
Paper or real account? Did you also subscribe to realtime ticks, and did your api get any for SPY in the last 32 minutes? Did you try unsubscribing and re-subscribing ? Did your TWS show SPY ticks in the last 32 minutes? Did your try Ctrl-Alt-F in your TWS to refresh realtime data ? Would a second client get SPY 5sec bars when the first doesn't ? Gd luck SouqMate. ---In TWSAPI@..., <ernst.tmp@...> wrote : Hello, I have written a Java program to subscribe to the 5 sec. bars, but I had missing data, so I rewrote everything in Python, but I still have problems. For instance, 32 minutes before todays Close, SPY bars stopped appearing, while all the other 5 sec. bars (VIX,? QQQ, ...) where coming in. I contacted IB tech support about this problem, but they where of no help. Do you have any ideas? Thanks, Ernst |
5 sec. Bars
Hello,
I have written a Java program to subscribe to the 5 sec. bars, but I had missing data, so I rewrote everything in Python, but I still have problems. For instance, 32 minutes before todays Close, SPY bars stopped appearing, while all the other 5 sec. bars (VIX,? QQQ, ...) where coming in. I contacted IB tech support about this problem, but they where of no help. Do you have any ideas? Thanks, Ernst |
Re: how long does historical pull take?
hi Dmitry, ? I have updated the table in the jTWSdump website: ? http://www.tradingsoftwarelab.com/jtwsdump/table.html ? showing increased limits of 5 Y (5 years) for 1M (1 month), 1W (1 week) and 1 day bars and also 10 D (10 days) for 5 mins, 3 mins, 2 mins and 1 min bars. These limits are for a single data request - much more data can be downloaded by setting the End Date/Time in another API request to a date before 5 years from now. In jTWSdump this can be easily managed by using the "Number of Queries" field. ? Thanks to Richard L King for the heads-up. |
Re: Building an options trading algo using TWS. Need some help!
I've looked into that, but the conditionals will be determined at market_open_time + 5 mins already. ?Doesn't seem to be useful it is better suited for single condition (time) orders instead of more condition (time + price) as the variables for the order placement.
|
Re: Connectivity With IB
Nick
¿ªÔÆÌåÓýI was able to connect just now - 4pm on east coast.On 12/15/2015 1:58 PM, mochasatin
wrote:
? |
Re: Connectivity With IB
¿ªÔÆÌåÓýConnectivity from the UK been fine all day - but was connected from just after midnight UK timeOn 15/12/15 18:58, mochasatin wrote:
-- Stewart Douglas sdouglas@... |
Re: Building an options trading algo using TWS. Need some help!
ce
?
Is? GAT (Good After Time ) order type useful here ?
?
https://www.interactivebrokers.com/en/index.php?f=587
?
-----Original Message----- From: "kein520@... [TWSAPI]" [TWSAPI@...] Date: 12/14/2015 08:17 PM To: TWSAPI@... Subject: [TWS API] Re: Building an options trading algo using TWS. Need some help! ? Somewhat related to OP's requirements, i.e., placing orders after certain time in market. ?How do you do it in TWS (not API)? ?I can't seem to find conditional orders in TWS doing that.
?
I am thinking about a simple execution like this, using swigibpy (Python C++ API wrapper):?
?
if PRICE > High of first 5 min candle:
Buy AMT shares of XXX when XXX goes above PRICE
else
Buy AMT shares of XXX when XXX goes above High of the first 5 min candle
# attach stop loss and scaling
Stop Loss AMT of XXX at Stop_loss_price
?
Listen to market data for the holdings in the portfolio
Sell AMT/2 shares of HOLDINGS when HOLDINGS appreciates 2%
Trailing Stop?HOLDINGS
?
?
?
? |
Re: Building an options trading algo using TWS. Need some help!
Hello all, Thanks for all the tips and comments! I am adding them to the specifications. As fshsweden stated, We need a robust framework that can handle and recover from all the problems that can arise. Any trading program needs close attention when running. That being said, is a java api? and TWS the way to go? If so, is building a GUI in NetBeans the best solution? I'm thinking commercial product in the distant future. Little newbie steps for now! |
Re: Building an options trading algo using TWS. Need some help!
Somewhat related to OP's requirements, i.e., placing orders after certain time in market. ?How do you do it in TWS (not API)? ?I can't seem to find conditional orders in TWS doing that.
I am thinking about a simple execution like this, using swigibpy (Python C++ API wrapper):? if PRICE > High of first 5 min candle: Buy AMT shares of XXX when XXX goes above PRICE else Buy AMT shares of XXX when XXX goes above High of the first 5 min candle # attach stop loss and scaling Stop Loss AMT of XXX at Stop_loss_price Listen to market data for the holdings in the portfolio Sell AMT/2 shares of HOLDINGS when HOLDINGS appreciates 2% Trailing Stop?HOLDINGS |
Re: Building an options trading algo using TWS. Need some help!
I haven't traded SPY option in awhile, but I noticed with ES options that market makers often pull bids and offers, usually both sides at once, for periods of a fraction of a second to several minutes.? During that time, there is exceedingly poor liquidity, and a stop could get filled at a very bad price.
Note also, if you're a USA taxpayer, ES and SPX options have much better tax treatment. Good luck! [rwk] ---In TWSAPI@..., <todell826@...> wrote : Once the credit spread is filled, the algo will monitor the long and short positions. The short position will immediately have a trailing stop order of Ycents placed on it. I have been using .20 cents for the first hour and then adjust to .1-.12 cents for the rest of the day. If price goes in my favor the short will lose value and eventually be stopped out for a profit. If price does not go in my favor the short will get stopped out thus minimizing loss. When this occurs, a tight trailing stop is placed on the long position. If price continues in the right direction the long will get stopped out. If price reverses the long will gain value and either increase profit for the spread or reduce the loss. Finding the right trailing stop values has been a challenge. Getting stopped out and maximizing profit is a fine line. Other ideas for exiting the trades are encouraged! |
Re: Building an options trading algo using TWS. Need some help!
Nick
You forgot to mention things like how to deal with and recover from an outage (either your app or internet connection or IB issue).
toggle quoted message
Show quoted text
Also you have to handle things like when to stay on the sidelines due to economic reports or holidays. If you are new to programming and want to develop this part time I doubt you will finish it in a year. Still, I'm rooting for your success. It's just that there is a huge amount of things you have to learn in order to create an app like this. On 12/14/2015 6:59 AM, todell826@... [TWSAPI] wrote:
This is a recent post to another forum. |
Re: Building an options trading algo using TWS. Need some help!
This is a recent post to another forum. I am new to the automated trading world and writing code. My goal is to develop an algorithm that trades options credit spreads. I have been manually trading this strategy for about a year, The problem is I still have a full time job and the strategy needs close attention. I would like the ability to have the algo enter trades. It would also need the ability to turn this feature off and be attached to a manually entered trade. The present strategy is to enter trades after the open and close all trades before market close. I have been trading SPY and the overnight gaps are dangerous. The criteria would be: 1. Determine the direction of the underlying. Bullish would enter a put credit. Bearish would enter a call credit spread. 2. Enter trades after an adjustable time. The first hour is too volatile. 3. A short position delta of A. This determines probability of profit. 4. A spread of B points 5. The credit is => the number of days till expiration (15%roi for 15dte) 6. I also look at open interest and find the highest. That is where the smart money is and a great indicator of what is going to happen. Once the credit spread is filled, the algo will monitor the long and short positions. The short position will immediately have a trailing stop order of Ycents placed on it. I have been using .20 cents for the first hour and then adjust to .1-.12 cents for the rest of the day. If price goes in my favor the short will lose value and eventually be stopped out for a profit. If price does not go in my favor the short will get stopped out thus minimizing loss. When this occurs, a tight trailing stop is placed on the long position. If price continues in the right direction the long will get stopped out. If price reverses the long will gain value and either increase profit for the spread or reduce the loss. Finding the right trailing stop values has been a challenge. Getting stopped out and maximizing profit is a fine line. Other ideas for exiting the trades are encouraged! If the trade goes my way and does not get stopped out. the algo will close the trade at a determined percentage of max profit. I currently use Interactive Brokers to trade so the algo should be compatible with IB. I am open to suggestions on where to use it. I see the algo working like this:
There is a lot more to discuss but I think this gives the basic concept. Check out www.daytradingzones.com. This where I learned the strategy. I am not affiliated with them. |
ECBOT in Test Account: bizarre Market Data to API (only) on (simulated) Order
So something strange, perhaps idiosyncratic for a particular day, but disturbing, nonetheless, suggesting an automated IB layer to the API L1 market data, at least for test accounts. Trading in paper, say Corn, when I entered an order market data would arrive immediately fading against the order to a round multiple of 75 cents, persisting until a bona fide Bid/Ask was sent. All simulated trading, and in the API only.but still? For instance, say the market in Corn was: 402.50@....? If I sold one, during a very quiet interval in the market (overnight), the market would show 402.50@... using the API (and I verified a "tickPrice" was received saying such).? But on TWS, the proper market would show (I had logged into my real account on TWS) |
Re: Building an options trading algo using TWS. Need some help!
If you are new to programming you have a long road ahead of you. I suggest you get an expert to at least set up a framework for you.
I have such a framework which allows setting up a simple trading environment in less than a day (and yes I do remember the remarks from people in this group that it is "impossible"..... ) However I do not give it away for free. The cost is relatively limited compared to creating it yourself though (expect at least 6 months if you do it yourself - TWS API has a lot of quirks...) Drop me an e-mail at fshsweden@... if you want to discuss this type of solution. //Peter |
Re: Building an options trading algo using TWS. Need some help!
Ben Alex
Hi It might help if you expand on what you're after. Do you want some guidance on coding Java generally, some help using IB's Java library, or are you seeking someone to write some or all of code for you? Is your long-term goal to maintain the code yourself or did you want someone to continue with that?Java can seem daunting to learn, but it is well worth it if you have a few months available. While there are hundreds of books and tutorials out there, I know lots of professional Java developers who worked their way through (and Oracle to their credit keep it up-to-date with new Java improvements). If you are after trading system design advice or help with the IB Java library, this list will give you a lot of free advice. also includes lots of design, programming and API information if you haven't already seen it. Basically, if you're willing to invest the time and use the many high quality (free) resources out there, you can almost certainly write it yourself. One thing I'm curious on is does your strategy require human involvement or is it entirely algorithmic? What is the typical holding time and what data do you process (eg daily, minute, tick, bid-ask level)? Letting people know that makes a major difference to the sort of program you're trying to build (ie a GUI-driven decision support tool vs a headless black box that performs trades) and is more likely to appeal to someone who has already built that class of application and can quickly adapt their existing experience and/or code. Cheers Ben |