studerw / td-ameritrade-client

TD Ameritrade Java Client
Apache License 2.0
69 stars 47 forks source link

Getting Error while creating Option order #49

Closed ajaythukral closed 3 years ago

ajaythukral commented 3 years ago

Hi, I am trying to create option order and I am getting following error

java.lang.RuntimeException: Non 200 response: [400 - { "error" : "Following parameters are not allowed when placing an order: optionDeliverables"

Here is my code snippet Order order = new Order(); order.setComplexOrderStrategyType(ComplexOrderStrategyType.NONE); order.setOrderType(OrderType.LIMIT); order.setSession(Session.NORMAL); order.setOrderStrategyType(OrderStrategyType.SINGLE); BigDecimal buyprice = new BigDecimal(1.0).setScale(2, RoundingMode.HALF_UP); order.setPrice(buyprice); order.setDuration(Duration.DAY);

  OrderLegCollection olc = new OrderLegCollection();
  olc.setInstruction(Instruction.BUY_TO_OPEN);
  olc.setQuantity(new BigDecimal("1"));
  order.getOrderLegCollection().add(olc);

  OptionInstrument instrument = new OptionInstrument();
  instrument.setSymbol("CCL_012122C30");
  instrument.setAssetType(AssetType.OPTION);
  olc.setInstrument(instrument);;

}

Any help for the same will be highly appreciated.

ajaythukral commented 3 years ago

Need to set optionDeliverables to null