This is a minimal, polling-based trading bot for Upstox with a threshold strategy. It can run in dry-run mode without credentials, simulating prices to test your logic.
- Threshold strategy: buy when LTP <= buy_below, sell when LTP >= sell_above
- CLI with
.envconfiguration - Dry-run mode that simulates price movement if no token is available
- Uses Upstox HTTP v2 APIs when
UPSTOX_ACCESS_TOKENis set; optional fallback to older SDK
- Create and activate a Python 3.10+ environment.
- Install dependencies:
pip install -r requirements.txt
- Copy
.env.exampleto.envand fill in your credentials if you want to trade live.
Dry-run with simulated prices:
python -m bot --symbol RELIANCE --exchange NSE_EQ --buy-below 2500 --sell-above 2510 --quantity 1 --dry-runLive mode (requires UPSTOX_ACCESS_TOKEN in .env):
python -m bot --symbol RELIANCE --exchange NSE_EQ --buy-below 2500 --sell-above 2510 --quantity 1Alternatively, pass an --instrument-key like NSE_EQ|RELIANCE.
- This example is deliberately simple and does not handle risk management, order rejections, or network retries beyond basics.
- Use at your own risk. For education/testing only.