I want my python script to extract stocks according to my screener and automate the trade accordingly, so if anyone can help me out, and if I can do it on my mobile , that’ll be super booster, and if not can do it in laptop too
1. Set Up Upstox Developer Access
- Create an app on the Upstox Developer Portal.
- Note down your API key, API secret, and redirect URI.
2. Authenticate with Upstox
- You’ll need to complete OAuth authentication to get an access token.
- This token allows your script to interact with your trading account.
3. Create Your Screener Logic
- Define your stock screener conditions (e.g., RSI < 30, price above 200 SMA).
- You can use external data (like from NSE, Yahoo Finance, etc.) or Upstox historical data API.
4. Fetch Market Data
- Use Upstox APIs (like Quote API or Historical Candle API) to get live or historical prices.
- Apply your screener logic to shortlist stocks.
5. Place Orders
- For each shortlisted stock, use the Place Order API to execute trades.
- Make sure you handle order types, quantity, stop loss, etc., as per your strategy.
6. Automate the Script
- Use task schedulers like
cron
on Linux/macOS or Task Scheduler on Windows to run it at desired intervals. - Add logging and error handling to track issues or missed trades.
Can You Run This from Mobile?
- You can, using:
- Pythonista (for iOS) or Pydroid 3 (for Android): These allow Python scripting directly on mobile.
- Cloud IDEs like Replit or Google Colab, which can be accessed via mobile browser.
- Or, host your script on a server (AWS, Heroku, etc.) and control it remotely via mobile.
For more information please refer to API Documentation – Fast Secure Free – Upstox | Upstox Developer API for more information.
Thanks!
I want trading symbol and instrument_keys of all the stocks (almost 1828) which have marketcap >=500crores , so how to get that and if url is available for the issue would be fine enough to do the further process,
Can anyone tell me how to fetch the nearest strike price of specific Instrument keys saved in the .JSON through complete.json.gz automatically without needing to download and save it as a .JSON
@KAILASH_11790155 There isn’t a direct method to fetch the nearest strike price. However, you can use the Option Chain | Upstox Developer API to retrieve all available strike prices for a specific underlying instrument and its corresponding expiry.
Thanks
however i succeeded in fetching the nearest strike price of the specific option with the instrument key , but failed to fetch the live ltp or say current trading price of that option, please help, will appreciate that
and after getting the correct option strike of say ABC 1050 ce , how to get the correct instrument key of the strike to get live ltp to make order executable through the script directly with maintaining sl and tgt monitoring to exit the position
When you retrieve the option strike data using the Option Chain API, the corresponding instrument_key
is also included in the response.
Below is a sample response:
{
"status": "success",
"data": [
{
"name": "NIFTY",
"segment": "NSE_FO",
"exchange": "NSE",
"expiry": "2024-02-15",
"instrument_key": "NSE_FO|37590",
"exchange_token": "37590",
"trading_symbol": "NIFTY 19650 CE 15 FEB 24",
"tick_size": 5,
"lot_size": 50,
"instrument_type": "CE",
"freeze_quantity": 1800,
"underlying_key": "NSE_INDEX|Nifty 50",
"underlying_type": "INDEX",
"underlying_symbol": "NIFTY",
"strike_price": 19650,
"minimum_lot": 50,
"weekly": true
},
{
"name": "NIFTY",
"segment": "NSE_FO",
"exchange": "NSE",
"expiry": "2024-02-15",
"instrument_key": "NSE_FO|37668",
"exchange_token": "37668",
"trading_symbol": "NIFTY 19700 CE 15 FEB 24",
"tick_size": 5,
"lot_size": 50,
"instrument_type": "CE",
"freeze_quantity": 1800,
"underlying_key": "NSE_INDEX|Nifty 50",
"underlying_type": "INDEX",
"underlying_symbol": "NIFTY",
"strike_price": 19700,
"minimum_lot": 50,
"weekly": true
}
]
}
Thanks!
so is there a way to get the specific option strike’s ltp through put/call option chain url or we can get it from option chain url ,