0

Trying to build a simple system that buys a call if Last trades above prior hour bar high, or buys a put if Last trades below prior hour low. And when the new entry takes place an automatic trailing stop is placed at half the value of the option. Ideally looking for the next out of the money option.

Currently this is what I have for the ticker underlying:

@Override
public void nextValidId(int orderId) {
    System.out.println("id "+orderId);
    nextOrderID = orderId;
    //contract.m_localSymbol = "ESM7";
    Contract c = new Contract ();
    //contract.m_localSymbol = "ESM7";
    c.m_symbol = "SPY";
    c.m_exchange = "SMART";
    c.m_secType = "STK";
    c.m_currency = "USD";

    m_s.reqHistoricalData(1, c, 
    LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE)+ " 16:00:00",
            "2 D", "1 day", "MIDPOINT", 1, 1, null);
    m_s.reqMktData(1, c, "", false, null);
    Order order = new Order();
    order.m_action = "BUY";
    order.m_totalQuantity = 1;
    order.m_lmtPrice = 4.00;
    order.m_orderType = "LMT";  
    order.m_account = "11231231";
    Contract contract = new Contract();
    contract.Symbol = "SPY";
    contract.SecType = "OPT";
    contract.Exchange = "BOX";
    contract.Currency = "USD";

    contract.LastTradeDateOrContractMonth = 

Expiration should be strike should be automatically entered to be the next expiring contract

        contract.Strike = 

strike should be automatically entered

        contract.Right =

right (call / put ) should be automatically entered

        contract.Multiplier = "100";

}

I am not sure how to take this and place an order.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
PlacePrint App
  • 101
  • 1
  • 12
  • Please help. I'm clueless on it from here. – PlacePrint App Apr 19 '17 at 18:34
  • Unfortunately I don't know the answer, but it would improve your question if you mention whether the problem is that the subject is not covered by the standard doc or that it is covered but there are problems with that. F. ex maybe around https://www.interactivebrokers.com/en/software/api/apiguide/java/java_ewrapper_methods.htm - https://www.interactivebrokers.com/en/software/api/apiguide/java/contract.htm - https://www.interactivebrokers.com/en/software/api/apiguide/java/order.htm – SantiBailors Apr 20 '17 at 07:13
  • It is partially covered in documentation. But it doesn't include how to automatically find nearest at money strike and auto find nearest expiration. – PlacePrint App Apr 20 '17 at 12:24

0 Answers0