jeeva780's picture
Upload 7 files
948485c verified
|
Raw History Blame Contribute Delete
2.14 kB
---
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"
}
```