File size: 2,137 Bytes
5c9575c 948485c 5ca022e 948485c 5c9575c 948485c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | ---
title: Selva Option Backtest
emoji: 📈
colorFrom: gray
colorTo: gray
sdk: docker
app_port: 7860
---
# Selva Option Backtest — Real ICICI Direct Breeze Data
This version is a Hugging Face Docker Space using a Node.js/Express backend.
## What it does
- Connects to ICICI Direct Breeze using the API session entered in the browser.
- Keeps `BREEZE_API_SECRET` server-side.
- Fetches real NIFTY 1-minute historical candles.
- Fetches real NIFTY option 1-minute historical candles.
- Runs the overnight ATM CE + PE backtest on the server.
- No simulated market prices are used by the backtest.
- Exports trade and daily results as CSV.
## Hugging Face Secrets
In Space Settings -> Secrets and Variables, add:
- `BREEZE_API_KEY`
- `BREEZE_API_SECRET`
Do NOT put the secret in `index.html`, `main.js`, or commit it to Git.
## Breeze session
Click the ICICI Direct login link shown by the app, complete the login/authorization flow, copy the API session value, and paste it into the app.
The API session is kept only in the running server process and is not written to disk.
## Strategy
The UI keeps the original strategy structure:
- Entry: 15:15
- Entry days: Monday to Thursday
- Buy ATM CE + ATM PE
- ATM step: 50
- Hold overnight
- Next trading day: SL checked before target
- Default square-off: 15:10
- Default target: 20 points
- Default SL: 10 points
- Default brokerage: ₹40 per leg
- Quantity: 65
Important: the weekday expiry mapping is retained from the supplied strategy. For historical periods that cross changes in the NIFTY weekly-expiry calendar or exchange holidays, verify the expiry calendar before using results for trading decisions.
## Local run
```bash
npm install
set BREEZE_API_KEY=your_key
set BREEZE_API_SECRET=your_secret
npm start
```
Open http://localhost:7860
## API endpoints
- GET `/api/health`
- GET `/api/status`
- GET `/api/login-url`
- POST `/api/connect`
- POST `/api/logout`
- POST `/api/backtest`
The `/api/backtest` endpoint expects:
```json
{
"start": "2026-09-01",
"end": "2026-10-01",
"targetPts": 20,
"slPts": 10,
"brokerage": 40,
"sqOff": "15:10"
}
```
|