MarketProtection Issue

manoj_trade
Hi,
When tried to modify a limit sell order to market order by kite's ModifyOrder function with protection parameter as "MarketProtection:MarketProtection.Auto", I am getting error as "Market orders without market protection are not allowed via API. Please set market protection or use a Limit order."

Issue happened when tried to modify sensex option and .net library is latest (v5.0.0).

Please check.

Regards,
Manoj
  • salim_chisty
    When modifying an order, please note the following behavior:
    If you are modifying a LIMIT order to a MARKET order, the market_protection parameter must be specified, as it is mandatory for market orders.
    However, if you are modifying an existing MARKET order, there is no need to pass the market_protection parameter again, as it is already associated with the order.

    Please refer to the similar discussion here.
  • manoj_trade
    But I am passing the market protection parameter as "MarketProtection:MarketProtection.Auto"
  • manoj_trade
    manoj_trade edited April 3
    @Matti
    @tonystark
    @salim_chisty
    Any comment regarding the above issue. Can I pass "MarketProtection:MarketProtection.Auto" when modifying a limit order to market order.
  • Nivas
    Nivas edited April 7
    @manoj_trade The market_protection parameter in ModifyOrder was introduced in v5.1.0 of the .NET client. In v5.0.0, ModifyOrder does not include this parameter. Upgrading to v5.1.0 will resolve this — ModifyOrder in v5.1.0 natively supports the market_protection parameter.

    Also note:
    • Constants.MarketProtection.Auto is valid.
    • If you use using static KiteConnect.Constants;, you can directly use MarketProtection.Auto.

  • manoj_trade
    Have updated the version to v5.1.0. But the issue is still there. Please see the steps below to reproduce the issue.

    Place a SL-L order and try to modify it to Market order by calling ModifyOrder with market protection to MarketProtection: 2.00.

    But getting the error "Market orders without market protection are not allowed via API. Please set market protection or use a Limit order".

    I was checking this on sensex option.

    @Nivas
    @Matti
    @tonystark
  • tonystark
    @manoj_trade We tried this at our end we were able to modify the order.

    Could you post logs after enabling Debug mode in the Kite constructor? Need to see how the order is placed and how it is modified. Make sure to trim auth tokens and keys from the logs before posting.

    Alternatively you can share a minimal reproducible code.
  • manoj_trade
    manoj_trade edited April 8
    Assuming that kite .net library is writing logs using "Console.WriteLine". But my application is Winforms. So that need to check workaround for the logs.
    Please give some time.

    If possible please change "Console.WriteLine" to "Debug.WriteLine" when the .net library update is released.

    @tonystark
  • tonystark
    @manoj_trade Will consider this for the next lib update. For now could you try a simple Console app with the scenario you described?
  • manoj_trade
    Converted the Win App to a console app. But no logs are showing in console. Don't know why still checking.

    Also please note that when modifying to a Market order I am passing the following parameters only.

    mKite.ModifyOrder(OrderId: "26040....",Quantity: 20.00m,Price: 0.00m,TriggerPrice: 0.00m,OrderType: "MARKET",
    MarketProtection: 2.00m);

    @tonystark
  • manoj_trade
    I could resolve the issue. It was a bug from my side.
    Sorry guys and thanks for the help.

    This issue can be closed.
    @tonystark
This discussion has been closed.