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.
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?
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.
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.
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 - 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 - 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
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']
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.
It seems like you are trying to place a Good Till Triggered (GTT) order, but using the `place_order` function, which is typically used for regular orders. In the Kite API provided by Zerodha, GTT orders are placed using a different method. The `place_gtt` method is used for GTT orders.
Here's an example of how to place a GTT order correctly using the Kite API:
In this example: - `trigger_type=kite.GTT_TYPE_SINGLE` is used to set a single trigger condition. - `trigger_values=[1150.0]` is the trigger value at which the order should be placed. - `last_price=1200` should be replaced with the current market price of the instrument. - The `orders` list contains the details of the order to be placed once the trigger condition is met.
If you have both a stoploss and a target, you can set up a GTT with multiple triggers. Here's how to do it:
```python kite.place_gtt( trigger_type=kite.GTT_TYPE_OCO, # OCO stands for One Cancels the Other tradingsymbol="HDFCBANK20SEPFUT", exchange="NFO", trigger_values=[1150.0, 1160.0], # Stoploss and target prices last_price=1200, # replace with the current market price orders=[ { "transaction_type": kite.TRANSACTION_TYPE_SELL, "quantity": 550, "price": 1150.0, # Stoploss price "order_type": kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_NRML }, { "transaction_type": kite.TRANSACTION_TYPE_SELL, "quantity": 550, "price": 1160.0, # Target price "order_type": kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_NRML } ] ) ```
In this example: - `trigger_type=kite.GTT_TYPE_OCO` is used for One Cancels the Other, which means either the stoploss or the target will trigger and the other order will be canceled. - `trigger_values=[1150.0, 1160.0]` includes both the stoploss and target trigger values.
Make sure you replace the placeholders with the actual values specific to your needs Learn is terabox legit. This approach should fix the error and place your GTT order as intended.
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?
Can you let us know in detail, what are you trying to achieve?
The order placement APIs don't accept GTT fields. So, you need to place either GTT or Order Placement, as per your requirement.
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.?
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.
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?
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
You can check the API documentation here.
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.
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 "=="?
tradingsymbol=name,
trigger_values=[sl_price,tp],last_price=trd_list[one_tick_token]['mkt_price'] and
"quantity":trd_list[one_tick_token]['qty']
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.
Here's an example of how to place a GTT order correctly using the Kite API:
```python
kite.place_gtt(
trigger_type=kite.GTT_TYPE_SINGLE,
tradingsymbol="HDFCBANK20SEPFUT",
exchange="NFO",
trigger_values=[1150.0],
last_price=1200, # replace with the current market price
orders=[{
"transaction_type": kite.TRANSACTION_TYPE_SELL,
"quantity": 550,
"price": 1160.0, # target price
"order_type": kite.ORDER_TYPE_LIMIT,
"product": kite.PRODUCT_NRML
}]
)
```
In this example:
- `trigger_type=kite.GTT_TYPE_SINGLE` is used to set a single trigger condition.
- `trigger_values=[1150.0]` is the trigger value at which the order should be placed.
- `last_price=1200` should be replaced with the current market price of the instrument.
- The `orders` list contains the details of the order to be placed once the trigger condition is met.
If you have both a stoploss and a target, you can set up a GTT with multiple triggers. Here's how to do it:
```python
kite.place_gtt(
trigger_type=kite.GTT_TYPE_OCO, # OCO stands for One Cancels the Other
tradingsymbol="HDFCBANK20SEPFUT",
exchange="NFO",
trigger_values=[1150.0, 1160.0], # Stoploss and target prices
last_price=1200, # replace with the current market price
orders=[
{
"transaction_type": kite.TRANSACTION_TYPE_SELL,
"quantity": 550,
"price": 1150.0, # Stoploss price
"order_type": kite.ORDER_TYPE_LIMIT,
"product": kite.PRODUCT_NRML
},
{
"transaction_type": kite.TRANSACTION_TYPE_SELL,
"quantity": 550,
"price": 1160.0, # Target price
"order_type": kite.ORDER_TYPE_LIMIT,
"product": kite.PRODUCT_NRML
}
]
)
```
In this example:
- `trigger_type=kite.GTT_TYPE_OCO` is used for One Cancels the Other, which means either the stoploss or the target will trigger and the other order will be canceled.
- `trigger_values=[1150.0, 1160.0]` includes both the stoploss and target trigger values.
Make sure you replace the placeholders with the actual values specific to your needs Learn is terabox legit. This approach should fix the error and place your GTT order as intended.