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.