Good day team Upstox and Community members,
I am trying to create Hotkey for Option (Index: Sensex/Nifty/Bank Nifty) scalping using Upstox Api. My objective is 1. Fetch live index data 2. Use hot key to Buy ITM Call('Hotkey: ‘C’) or Put("Hotkey: ‘P’)option , it should automatically select ITM call/put based on calculation , Also Stop loss to be placed for buy order (Based on Inputs mentioned in the code) 3. Modify stop loss of existing position (Since TSL isnt available yet) if trade moves in my favour, 4. Exit all positions after target achieved(Hotkey: ‘D’) . I have done this on Interactive broker, but i wante to shift to upstox, hence i have been trying to do this in upstox but didnt succeed. Is this even possible to achieve in Upstox api? kindly enlighten me
Yes, it is possible to set up hotkeys for F&O, but we do not have direct support or built-in implementations for trading strategies. However, you can achieve this by coding your strategy accordingly.
Let me address the points you mentioned:
-
Live Market Data: You can access real-time index data using the Market V3 WebSocket: Market Data Feed or the Market Quote API: Full Market Quote.
-
Fetching Instrument Keys: You can retrieve instrument keys from the instrument JSON files: Instrument JSON Files. This will provide both call and put option instrument keys, which you can map to specific hotkeys for quick order placements. When a hotkey is pressed, you will need to trigger the Place Order API accordingly.
-
Modifying Stop Loss Orders: Yes, you can continuously modify stop-loss orders, as trailing stop-loss (TSL) functionality is not available at the moment. You will need to handle modifications programmatically based on market conditions.
-
Exiting All Positions: If you need to close all open positions at once, you can use the “Exit All Positions” API: Exit All Positions. This allows for quick liquidation of all active positions in your account.
I hope this helps! Let me know if you need further clarification.
Thanks!
thanks a lot, i am halfway through , however i have one doubt, i want to ‘Buy’ option contract @ market price, to Protect my positions i also want to place a ‘Stoploss’ order, How do i go about it? Use Sell order or GTT order?
You can use GTT orders for Stop Loss: GTT Orders Documentation.
However, if you manually exit your position, make sure to cancel your GTT Stop Loss order; otherwise, the opposite leg might be created.