Upstox Portfolio Rebalancing Automation

Замовник: AI | Опубліковано: 01.04.2026

I need a clean, well-documented Python script that plugs into the official Upstox API and keeps my portfolio in line with my target weights automatically. The scope is limited to portfolio management; no market-scanning or order-flow extras are required. Here is what I want the program to do: • Pull my current holdings and target allocation from a simple CSV or Google Sheet (I’m flexible on the source as long as I can edit weights easily). • Check both a schedule I set (e.g., every Monday at 9:30 a.m.) and defined market triggers such as a 3 % drift in any position. If either condition is met, the logic should decide whether rebalancing is necessary. • Calculate the exact quantity to buy or sell for each symbol, taking into account available cash, fractional limits on Upstox, and brokerage fees. • Place the required market or limit orders through the Upstox API and confirm execution. • Log every step and send me an email or Telegram message summarising the adjustments. Acceptance criteria – Runs end-to-end on my machine with only a config file change for API keys and thresholds. – Produces clear console logs plus a daily summary file. – Handles API errors gracefully and retries once before alerting me. I already have an active Upstox developer account; you just need to give me the finished Python code (Python 3.10+), a requirements.txt, and a short README so I can spin it up in a fresh virtual environment. If you’ve built similar algo-trading or rebalancing tools, let me know—links or short demos welcome.