Java Program that monitors TICK

Discussion in 'App Development' started by HeSaidSheSaid, Oct 12, 2017.

  1. Hi! I want to write a little program in Java that monitors the NYSE TICK. When the TICK gets to +400, then I'd sell 100 shares of SPY. If the TICK drops down to -400, then I'd buy 100 shares of SPY.

    1) I want to deploy this little program to the IB trading platform. Please tell me how the system work together (like how my program would monitor the TICK values. I assume IB provides some sort of a unique variable name and TCP port for TICK values, so one's Java program would poll the variable name and the port for a change in value, then get them off the IB server, and send and display them on my monitor. Did I get the process down correctly?

    2) Please tell me how my program would interact with IB TWS, so the TICK data can be exchanged and my program would process the logic (TICK +/- 400).

    3) How about sending in sell and buy order? Does IB TWS special variables for sell order and buy order (where one has to place his buy/sell order data in TWS, so IB can understand and execute the order.

    4)... chances are I haven't listed all the issues or configurations needed for this type of setup. Thank you for your inputs!
     
  2. Ad 1) You got it more or less correct. Your java program would connect to the API and then subscribe to the streaming data of the instrument you're interested in. You receive the price and/or volume information and process the data in your java program.
    Ad 2) your java program does NOT interact with TWS (it merely uses TWS to communicate with IB's data servers). If you need graphical output on your screen you have to create that of your own in your java program, outside of TWS.
    Ad 3) your java program would submit buy/sell orders to IB via the API based on your trading logic. your java program needs to monitor the execution of those orders. e.g. what to do in case the order doesn't get filled, or gets partially filled.
    Ad 4) depending on how sturdy you want to have it do you need to add additional code to protect it from crashing or to take care of unexpected situations. In case you want to run it for days/weeks without supervision you may want to have more fail-safe features. If you're sitting in front of your monitor and can see what is happening, then you might get away with less as long as you can interfere (i.e. stop the program) with it.

    By the way, I have no experience with this TICK instrument. In the above I have assumed that IB has this symbol for you available. If not, you would need to subscribe to those items that together define TICK and calculate the value in your java program.
     
    tommcginnis likes this.
  3. Thanks HobbyTrading!

    Ad 1) let's assume I've purchased the IB subscription service, and I think IB calls it TICK-NYSE (from Dr. Google :), then I assume I'm going to call a variable TICK-NYSE in my java program, then please tell how my Java program would interact with IB TWS, so it knows where to obtain the TICK-NYSE from and TWS would understand what my program is requesting. I think I'd need to specify the IP address of TWS server in my program?... (I just know a little bit of everything :). Thanks.
     
  4. You are correct: IB calls this the TICK-NYSE index (they also seem to have TICK for other indices).
    What your program needs to do is the following:
    step 1a: connect to IB. You need to have either TWS or Gateway running to achieve this. TWS/Gateway will take care of the communication with IB's servers, you don't need to worry about that.
    step 1b. define a so-called "contract" for TICK-NYSE. You can do this by specifying a combination of defining parameters such as name, currency, exchange, or its unique conid (an IB specific number). You also need to specify that this is an index.
    step 1c. request market data for this contract. This is like a subscription: IB will start to stream values to you. You receive this stream in your program and you need to process this stream: analyse it and base decisions on it. You will use methods reqMktData() and override tickPrice() and/or tickSize().

    More information on receiving live market data is here: http://interactivebrokers.github.io/tws-api/market_data.html#gsc.tab=0

    Once you have all this up and running flawlessly you can focus how to place an order for your instrument of choice (e.g. SPY).
     
    tommcginnis likes this.
  5. Snuskpelle

    Snuskpelle

    Do yourself a favor and write a quick implementation of this strategy at platform like e.g. quantconnect.com

    I tested a variant of it and I had the impression the strategy is has lost its edge. Then again, perhaps I don't monitor enough stocks as I (for performance reasons) had to limit to ~500.

    Just saying this because it's possible to spend an amazing amount of time implementing infrastructure for strategies that don't work.
     
    fan27 likes this.