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: Tick Encoding/Decoding
I'm the author of the TickUtils.jar you're referring to.
(For others reading this thread, this jar can be found in the Files section of this group. It provides encoding and decoding facilities to store tick data in a much smaller space than either plain text or some kind of fixed binary format. I use it for storing tick data in an SQL database. At the time I originally wrote it, I needed to minimize the space occupied by the data, because disk space was still expensive back then and database backups were interminable over a 10Mb/s network. I also didn't have the performance necessary to write a row for each tick, so I batch up the ticks for each minute into a blob using the encoding routines, and write the blobs at a predictable rate. Nowadays disk space is almost trivially cheap. My database is now around 25GB, and would be about 150GB without this encoding - not a huge file by modern standards. However the performance aspect may still be relevant, given that at some times I can be recording several hundred ticks per second. By the way, the encoding/decoding overhead is completely insignificant.) If you want to use this jar with IB's Java API, you need to understand a few things. 1. IB actually sends trade price and the corresponding trade size in a single message from TWS to the API client, but the API code then splits that into two separate callbacks - a tickPrice and a tickSize. (The same applies to bids and asks.) 2. This combined message is only sent when the price changes - otherwise just the size is sent, and a tickSize callback occurs. 3. After sending the combined price/size message, TWS then sends the exact same size again as a separate message, and the API generates another identical tickSize callback from this (there are historical reasons for this apparently nonsensical 'feature', though I suspect they are no longer valid). 4. If a trade occurs at the same price and size as the previously reported trade, not even the tick size is sent - just a volume update. (Note that the 'previously reported trade' isn't necessarily the same as the most recent actual trade, because the API doesn't necessarily report every trade.) From this information, we can make the following deductions: - when a tickPrice is received, the next tickSize (for the same tick type obviously) will be the size for that price (and will in fact occur immediately after, as it happens during the processing of the same socket message from TWS). - when a tickSize is received that is identical to the previous tickSize, it should be ignored, because it is just the duplicate that TWS sends after sending the combined price/size message - it doesn't represent a separate trade. You should now have enough understanding to be able to generate the formats required by the TickUtils.jar. By the way, please think carefully about whether you actually need to use these encoding/decoding routines. For example, if you just need to store tick data in ordinary files, it's best to simply write it out as text. The problem with the encoded format is that it's not human-readable. I actually do this in addition to my database recording, as a sort of backup - the files are compressed (by the operating system), which reduces their size to about one-sixth of their uncompressed size. Richard From: TWSAPI@... [mailto:TWSAPI@...] On Behalf Of sc1447 Sent: 14 July 2013 20:55 To: TWSAPI@... Subject: [TWS API] Tick Encoding/Decoding Hi All, I'm trying to encode tick data from IB, and wanted to use TickUtils.jar contributed here. But it seems to work with standard tick formats for example a Trade tick would have format (%time %price %trade size). IB data shows up as (%time %tick type %value), so IB would send two tick responses for a trade tick, instead of one. I was wondering if anyone was using the encoding utility for IB and if they would have a converter for IB tick data into the the format the encoder needs and are willing to share it. Thanks S |
C# Option Contract Details
andrewcmeier
Excellent, it worked, had to change a couple of other fields but it was definitely the contractID, thank you. The final code I used is:
toggle quoted message
Show quoted text
AAAA = new Contract(0, "AAPL", SecurityType.Option, "20130719", 420.0, RightType.Call, "100", "SMART", "USD", "", "", SecurityIdType.None, ""); Still not sure how to get all options for a stock but will keep trying. --- In TWSAPI@..., "Richard L King" <rlking@...> wrote:
|
Re: C# Option Contract Details
contractId is IB's own unique identifier for a contract. If you know this id
for a specific contract, you can use it in a contract details request and not supply any of the other fields. Setting this to 22 as you have done, and then supplying all the other fields for a contract whose id is almost certainly not 22, is probably the source of your error. So try setting contractId to 0. Richard From: TWSAPI@... [mailto:TWSAPI@...] On Behalf Of andrewcmeier Sent: 15 July 2013 04:47 To: TWSAPI@... Subject: [TWS API] Re: C# Option Contract Details I've had a look, it looks great, however, I still can't seem to fix my problem. The way you set up a contract in VB is: contract.conId = Convert.ToInt32(ss(2)) contract.symbol = TextBox1.Text contract.secType = "OPT" contract.expiry = ss(0).Trim.ToString contract.strike = Convert.ToDouble(ss(1)) contract.right = "C" contract.multiplier = "" contract.exchange = "SMART" contract.primaryExchange = "" contract.currency = "USD" contract.localSymbol = "" contract.includeExpired = 0 tickcount += 1 AxTws1.reqMktDataEx(rnumber, contract, "", 1) '0 =streaming 1=snapshot However, in C# I don't seem to have any of the contract.x and can't even seem to use .reqMktDataEx() I've tried another method which uses: AAAA = new Contract(22, "AAPL", SecurityType.Option, "201307", 420.0, RightType.Call, "", "SMART", "USD", "", "", SecurityIdType.None, ""); The constructor for this is: public Contract(int contractId, String symbol, SecurityType securityType, String expiry, double strike, RightType right, String multiplier, string exchange, string currency, string localSymbol, string primaryExchange, SecurityIdType secIdType, string secId) It still says no security definition found. Any idea of what is wrong here? Thanks again. --- In TWSAPI@... <mailto:TWSAPI%40yahoogroups.com> , Nick <nickhere@...> wrote: lines, change Tester to A1 and that is what I have. "andrewcmeier" <andrewcmeier@> wrote: (.Hi there, 0.21.Full.zip) to develop TWS software in C#. what I'm using: option in C#? I also then wan't to be able to leave fields out to do thingsOption A1 = new Option("AA", "AA", "20130719", RightType.Call, 8.0m); such as return all the contracts in a month, does anyone have any examples how to do this? but don't have any documentation, I've only worked out what to do from searching through lots of the code.
|
Re: Tick Encoding/Decoding
unatnahs57
1. I am making data request as: mClientSocket.reqMktData(id, contract, "", false);
toggle quoted message
Show quoted text
which returns the "last price and quantity in separate callbacks". So, using the post #24461 that you suggested I made the request as: mClientSocket.reqMktData(id, contract, "233", false); which returns Last Trade tick as: id=0 RTVolume=3066.00;4;1373851042866;1108;3065.15771661;false I can now construct the LastTick object instance used in TickUtils.jar. (Not yet sure if BidTick, AskTick can be done this way, but I'll investigate further, I wanted to reply at the earliest). ++++++ 2a. I also noticed an interesting thing. Request made with only "233" still gives me IB response for tickPrice, tickSize methods, so I'm actually using more bandwidth. 2b. Also, please take a look at the data below (I tested $NQ_F) 2013.07.14 20:17:14:836,0,6.0 2013.07.14 20:17:15:759,0,7.0 2013.07.14 20:17:20:208,0,6.0 id=0 lastTimestamp=1373851042 <-tickString() response 2013.07.14 20:17:21:989,4,3066.0 <-TRADE_PRICE 2013.07.14 20:17:21:993,5,1.0 <-TRADE_SIZE 2013.07.14 20:17:21:999,8,1105.0 <-VOLUME 2013.07.14 20:17:22:004,1,3065.75 2013.07.14 20:17:22:014,0,4.0 2013.07.14 20:17:22:021,0,4.0 2013.07.14 20:17:22:025,3,6.0 id=0 RTVolume=3066.00;4;1373851042866;1108;3065.15771661;false 2013.07.14 20:17:23:132,5,3.0 <-TRADE_SIZE 2013.07.14 20:17:23:233,8,1108.0 <-VOLUME 2013.07.14 20:17:23:324,0,5.0 2013.07.14 20:17:23:328,3,7.0 2013.07.14 20:17:24:052,0,6.0 i) There is almost a 030ms (average seems to be like 040ms) lag between when trade is executed and when we get RTVolume response. ii) I get a tickString response timestamp, then I get a trade, trade size, tickString Tick data, then trade size and then volume upto that point. Seems 2nd trade_size is not preceded with TRADE_PRICE if the price is same as last traded price. iii) Seems we can construct TRADE ticks using tickPrice stream ourselves, although VWAP might get messed up if data breaks in between. I'll be looking at this for a bit, but thanks a lot for your reply. S. --- In TWSAPI@..., "rwk2095" <r@...> wrote:
|
Re: C# Option Contract Details
andrewcmeier
I've given this a quick try, no luck yet, will try again when I get a chance.
toggle quoted message
Show quoted text
--- In TWSAPI@..., Shane Castle <shane.castle@...> wrote:
|
C# Option Contract Details
andrewcmeier
I've tried both dates, no luck.
toggle quoted message
Show quoted text
--- In TWSAPI@..., Peter Gum <petergum@...> wrote:
|
C# Option Contract Details
andrewcmeier
I've had a look, it looks great, however, I still can't seem to fix my problem. The way you set up a contract in VB is:
toggle quoted message
Show quoted text
contract.conId = Convert.ToInt32(ss(2)) contract.symbol = TextBox1.Text contract.secType = "OPT" contract.expiry = ss(0).Trim.ToString contract.strike = Convert.ToDouble(ss(1)) contract.right = "C" contract.multiplier = "" contract.exchange = "SMART" contract.primaryExchange = "" contract.currency = "USD" contract.localSymbol = "" contract.includeExpired = 0 tickcount += 1 AxTws1.reqMktDataEx(rnumber, contract, "", 1) '0 =streaming 1=snapshot However, in C# I don't seem to have any of the contract.x and can't even seem to use .reqMktDataEx() I've tried another method which uses: AAAA = new Contract(22, "AAPL", SecurityType.Option, "201307", 420.0, RightType.Call, "", "SMART", "USD", "", "", SecurityIdType.None, ""); The constructor for this is: public Contract(int contractId, String symbol, SecurityType securityType, String expiry, double strike, RightType right, String multiplier, string exchange, string currency, string localSymbol, string primaryExchange, SecurityIdType secIdType, string secId) It still says no security definition found. Any idea of what is wrong here? Thanks again. --- In TWSAPI@..., Nick <nickhere@...> wrote:
|
Re: Tick Encoding/Decoding
rwk2095
It's not clear from your question what you're trying to accomplish. If you're interested in market microstructure, i.e. very short term, you might have a look at TickString. See this old post:
toggle quoted message
Show quoted text
[rwk] --- "sc1447" <sc1447@...> wrote: I'm trying to encode tick data from IB, and wanted to use TickUtils.jar contributed here. But it seems to work with standard tick formats for example a Trade tick would have format (%time %price %trade size). |
option expiry [was: C# Option Contract Details]
The expiry is as it always was, a friday for US stock options. The OSI
toggle quoted message
Show quoted text
symbol, introduced a couple years ago, is always one day later than the expiry. If you are using the OSI symbol use saturday; if you are specifying the expiry field use friday. -Kurt On 7/14/13 8:51 AM, "Peter Gum" <petergum@...> wrote:
|
Tick Encoding/Decoding
Hi All,
I'm trying to encode tick data from IB, and wanted to use TickUtils.jar contributed here. But it seems to work with standard tick formats for example a Trade tick would have format (%time %price %trade size). IB data shows up as (%time %tick type %value), so IB would send two tick responses for a trade tick, instead of one. I was wondering if anyone was using the encoding utility for IB and if they would have a converter for IB tick data into the the format the encoder needs and are willing to share it. Thanks S |
Re: C# Option Contract Details
In the file section of this group
toggle quoted message
Show quoted text
I wrote a option chain getter I included the source.it in vb and conversion is easy to c# i had very little problems with it it get the chain of any stock ticker gets all the quotes and draws vertical spread graphs nick On 7/14/2013 6:23 AM, andrewcmeier wrote:
Oops, Tester and A1 were meant to be the same variable in the options lines, change Tester to A1 and that is what I have. |
Re: C# Option Contract Details
Peter Gum
Should '20130719' be '20130720'? I.e. 19 -> 20 to match the tws market line. (Although IB will expire the option on the 19th. Confusing.)
toggle quoted message
Show quoted text
Pete On 07/14/13, andrewcmeier<andrewcmeier@...> wrote:
Oops, Tester and A1 were meant to be the same variable in the options lines, change Tester to A1 and that is what I have. --- In TWSAPI@..., "andrewcmeier" <andrewcmeier@...> wrote:
|
Re: C# Option Contract Details
You're running an older version of ib-csharp.
toggle quoted message
Show quoted text
The latest code is now hosted here: Download that and give it a try. Shane On Sunday, July 14, 2013, andrewcmeier wrote:
Oops, Tester and A1 were meant to be the same variable in the options |
Re: C# Option Contract Details
andrewcmeier
Oops, Tester and A1 were meant to be the same variable in the options lines, change Tester to A1 and that is what I have.
toggle quoted message
Show quoted text
--- In TWSAPI@..., "andrewcmeier" <andrewcmeier@...> wrote:
|
C# Option Contract Details
andrewcmeier
Hi there,
I've started using the Krs.Ats.IBNet software () to develop TWS software in C#. Setting up equities is easy enough: Equity Google = new Equity("GOOG"); client.RequestMarketData(14, Google, null, true, false); But when I try to adapt it to options, I can't get it to work. This is what I'm using: Option A1 = new Option("AA", "AA", "20130719", RightType.Call, 8.0m); client.RequestMarketData(15, Tester, null, false, false); This is what it has in its class): public Option(string equitySymbol, string optionSymbol, string expiry, RightType right, decimal strike) This is the error I get when I raise e.ErrorCode: "No security definition has been found for the request" Does anyone know what I'm entering wrong, or just how to set up an option in C#? I also then wan't to be able to leave fields out to do things such as return all the contracts in a month, does anyone have any examples how to do this? I'm finding that C# should be a good way to download and analyse data but don't have any documentation, I've only worked out what to do from searching through lots of the code. Thanks for your help. |
Re: TWS API child order questions
Ray Salem
IN the demo account it was minutes, not sure if this would be true with real account
thanks ray ________________________________ From: cf16r <piter@...> To: TWSAPI@... Sent: Friday, July 12, 2013 11:23 AM Subject: [TWS API] Re: TWS API child order questions ? @raysalem619 did you really mean "minutes"? can somebody tell this is not true in a real account? I would like to see rather something less than second. |
Re: Upcoming stock earnings dates
Robert
I use
toggle quoted message
Show quoted text
" Let me know if anyone is interested in the VB.Net code that parses the downloaded html. It works well for me. r4 --- In TWSAPI@..., "rwk2095" <r@...> wrote:
|
Re: Upcoming stock earnings dates
rwk2095
I built a short term stock-trading app about ten years ago that excluded stocks with earning releases that day or the next. I used Yahoo!Finance via a screen scraper as my source of earnings release schedule, though it was not always complete. My scraper app was pretty primative, and whenever Yahoo changed the format of the web page, my program failed to deliver the desired data.
toggle quoted message
Show quoted text
There are several other sites that also have earnings release schedules, and interestingly, their lists are usually quite different. I ran the app for 8+ years, but I shelved it about a year and a half ago because the performance had deteriorated. [rwk] --- "ramdukof" <ramdukof@...> wrote: Is there any API request that returns upcoming stock earnings dates? |
to navigate to use esc to dismiss