got an unexpected keyword argument "trigger_values" while placing GTT order

Dileep
Dileep edited September 2020 in Python client
Hi,
When i place GTT order through python API getting the error as "place_order() got an unexpected keyword argument 'trigger_values"
kite.place_order(tradingsymbol="HDFCBANK20SEPFUT",
quantity=550,
trigger_values=[1150.0, 1160.0],
exchange="NFO",
variety="regular",
order_type="MARKET",
transaction_type="SELL",
product="NRML"
)
I am placing a market order with stoploss and target
Can any one help me to fix the issue.
  • sujith
    You can check out the documentation here to know more about placing GTT.
  • Dileep
    Dileep edited September 2020
    Hi @sujith last_price is mandatory in condition ,if i place Market order of GTT ?
  • rakeshr
    Yes, last_price is a mandatory field. And GTT orders are placed as the limit. You can go through this article to know more about GTT.
  • Dileep
    Dileep edited September 2020
    Thanks @rakeshr , @sujith So , through Web UI i can place market order, but through API i can place only limit order of GTT?

    This is below sample code of mine i am placing limit order of infy at 702. and placing target order at 710. But i am getting the error.Can you please advise what needs to modify in the below code.
    kite.place_order(
    type="single",
    condition= {
    "exchange":"NSE",
    "tradingsymbol":"INFY",
    "trigger_values":[702.0],
    "last_price":742.0
    },
    orders=
    {
    "exchange":"NSE",
    "tradingsymbol":"INFY",
    "transaction_type": "SELL",
    "quantity": 1,
    "order_type": "LIMIT",
    "product":"CNC",
    "price":710
    }
    )

    getting error as place_order() got an unexpected keyword argument 'type'
    Note: type is a keyword in python.Can you change the parameter name in your code?
  • sujith
    I think you are confused between place order and place GTT.
    Can you let us know in detail, what are you trying to achieve?
  • Dileep
    Dileep edited September 2020
    Hi @sujith i am replacing BO with GTT . Can you provide the sample code?


  • rakeshr
    i am replacing BO with GTT
    No, you can't place BO order with GTT or via versa, both are independent and different product.
    The order placement APIs don't accept GTT fields. So, you need to place either GTT or Order Placement, as per your requirement.
  • Dileep
    Hi @rakeshr , @sujith

    In web UI i am able to place GTT with target and stoploss with market order of selling a "HDFCBANK future" can i achive the same using API.?
  • rakeshr
    @Dileep
    place GTT with target and stoploss with market order of selling
    Yes, you can achieve this by Sell two-leg gtt order. You have to set stoploss and target values as trigger price in two leg GTT.
    Eg. Here for HDFCBANK for last_price = 1135.60 and if you want stoploss and target % = 2 %
    stoploss = 1112.8 and target = 1158.3
    "trigger_values":[1112.8, 1158.3]
    You can go through this documentation.
  • Dileep
    Hi @rakeshr thanks for your help. Now i am able to successfully place the GTT created. But HDFCBANK not showing in the Positions. Means it is just created GTT, But not entered in to the Postion with market order. Please advise me.


    trigger_type="two-leg",
    tradingsymbol ="HDFCBANK20SEPFUT",
    exchange="NFO",
    trigger_values=[1112,1158],
    last_price=1138.95,
    Where should we mention "Market" order type in the code?
  • rakeshr
    @Dileep
    Means it is just created GTT, But not entered in to the Postion with market order
    Yes, GTT is created, and once that triggered param is meet. It will be executed as Market.
  • D11458
    @rakeshr @Dileep - Hello, I just came across this thread that is exactly my query on how to place gtt when BO is temp unavailable....below is how I am trying to place GTT but getting error, kindly let me know what am I missing:
    kite.place_gtt(tradingsymbol=name,trigger_type=kite.GTT_TYPE_OCO,exchange=kite.EXCHANGE_NSE,trigger_values=[sl_price,tp],last_price=trd_list[one_tick_token]['mkt_price'],orders={"SELL",trd_list[one_tick_token]['qty']})

    Error : TypeError: argument of type 'int' is not iterable
  • sujith
    You seem to be sending the wrong orders param.
    You can check the API documentation here.
  • D11458
    @sujith - I did go through the links you have given...can you kindly assist with param, is it wrong only on orders param rest others are ok? I see orders param has transaction_type, qty and price, I have left price as not sure what to mention there
  • rakeshr
    orders={"SELL",trd_list[one_tick_token]['qty']}
    orders param has to be list of orders i.e for both trigger orders. Here, you are sending only one order.
    You can check the sample orders example here.
     [
    {
    "exchange":"NSE",
    "tradingsymbol": "INFY",
    "transaction_type": "SELL",
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "CNC",
    "price": 702.5
    },
    {
    "exchange":"NSE",
    "tradingsymbol": "INFY",
    "transaction_type": "SELL",
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "CNC",
    "price": 798.5
    }
    ]
  • D11458
    Hi @rakeshr - thanks, I used your above reply to place gtt as below:
    kite.place_gtt(tradingsymbol=name,trigger_type=kite.GTT_TYPE_OCO,exchange=kite.EXCHANGE_NSE,trigger_values=[sl_price,tp],last_price=trd_list[one_tick_token]['mkt_price'],orders=[{ "exchange":"NSE", "tradingsymbol": name, "transaction_type": "SELL", "quantity":trd_list[one_tick_token]['qty'], "order_type": "LIMIT", "product": "CNC", "price": tp},
    {"exchange":"NSE", "tradingsymbol": name, "transaction_type": "SELL", "quantity":trd_list[one_tick_token]['qty'], "order_type": "LIMIT", "product": "CNC", "price": sl_price}])

    it gives me error - *** SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
  • rakeshr
    it gives me error - *** SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
    Doesn't seem to be generated from the above gtt order placement. You need to check your variable assignment properly above eg. tradingsymbol=name,
    trigger_values=[sl_price,tp],last_price=trd_list[one_tick_token]['mkt_price'] and
    "quantity":trd_list[one_tick_token]['qty']
  • arick111
    The error message "got an unexpected keyword argument 'trigger_values' while placing GTT order" suggests that the function call for placing a GTT (Good 'Til Triggered) order contains an invalid argument 'trigger_values'.

    The 'trigger_values' argument is not a valid parameter for placing a GTT order. Check the API documentation or the function definition to ensure that you are using the correct parameters for placing a GTT order.

    If you are still having trouble, you can provide more context or code snippets for further assistance in debugging the issue.
  • teuber
    In web UI i am able to place GTT with target and stoploss with market order of selling a "HDFCBANK future" can i achive the same using API.?
Sign In or Register to comment.