← Chat Archive

Share:
List of Bots on bot.openalgo
2026-07-28 13:51 21 messages hermes-20260728_1350...
ASSISTANT (hermes, k3)
2026-07-28 13:51
TOOL (hermes, k3)
[Tool: skill_view] {"success": true, "name": "openalgo-bot-operations", "description": "Live operations for the OpenAlgo trading bots on this VPS — verifying broker state (orderbook/positionbook/MCP tools), OpenAlgo REST API field quirks that silently break bots, and per-bot-system day-state conventions. Use whenever a bot mis-fires, double-enters, or its position/orders look wrong.\n", "tags": ["openalgo", "trading-bots", "debugging", "mcp", "positionbook"], "related_skills": [], "content": "---\nname: openalgo-bot-operations\ndescription: |\n Live operations for the OpenAlgo trading bots on this VPS — verifying broker state (orderbook/positionbook/MCP tools), OpenAlgo REST API field quirks that silently break bots, and per-bot-system day-state conventions. Use whenever a bot mis-fires, double-enters, or its position/orders look wrong.\ntags:\n - openalgo\n - trading-bots\n - debugging\n - mcp\n - positionbook\n---\n\n# OpenAlgo Bot Operations\n\n## 0. \"Are the bots working?\" — 60-second health check (verified Jul 28, 2026)\n\nRun `scripts/bot_health_check.sh` first (services + last poll line per bot + broker pings), or manually:\n\n1. Services: `systemctl list-units --all 'renko-vidya-bot@*' 'daily-vidya-bot@*' 'crossover-lipi-vidya@*' 'google-daily-lipi-vidya@*'`\n - All instances stopped at the SAME second in the journal with `Result=success` = deliberate mass stop (dashboard STOP or systemctl), NOT a crash. Report them as \"stopped on purpose\", not \"failed\".\n2. Liveness: every bot polls ~60s, so a fresh POLL/Monitoring line in its log = healthy. Log paths:\n - renko: `/home/ubuntu/bots/renko_vidya_bot/logs/bot_<sym>.log`\n - daily_vidya: `/home/ubuntu/bots/daily_vidya_bot/mdocument/logs/dvbot_<sym>.log`\n - crossover_lipi: `/home/ubuntu/bots/crossover_lipi_vidya/mdocument/logs/clv_<sym>.log`\n3. Brokers: POST `{BROKER_URLS[b]}/api/v1/ping` with `BROKER_API_KEYS[b]` (sys.path `/var/www/openalgo-chart/api`). All 3 (flattrade/shoonya/kotak) must pong — a healthy bot still can't trade if its ORDER_BROKER is offline. Renko bots are hard-wired to flattrade (`ORDER_BROKER` in config.py); the Jul 23 flattrade outage is why the 13 equity instances stayed stopped after the stateless rewrite.\n\nDashboard ↔ systemd wiring (bot.openalgo.theworkpc.com, port 5100):\n- Registry: `/home/ubuntu/bots/dashboard/bot_systems.yaml` — 4 systems; each tab row maps 1:1 to `<service_prefix>@<symbol>.service`.\n- START button flow: writes mode file → `sudo systemctl start` → on-demand data fill. Passwordless sudo via `/etc/sudoers.d/renko-vidya-bots` (dashboard runs as ubuntu). START from the UI and `systemctl start` from CLI are equivalent.\n- START popup modes: **\"Wait for crossover\" = safe** (monitor-only until a fresh crossover). **\"Order now\" = DANGER**: acts on the LAST crossover even if hours stale and places a REAL order immediately — proven Jul 23 when a test start fired a live ULTRACEMCO CE within seconds. Always recommend \"Wait for ... [20222 chars total, truncated]
2026-07-28 13:51
ASSISTANT (hermes, k3)
2026-07-28 13:51
TOOL (hermes, k3)
[Tool: read_file] {"content": "1|# ═══════════════════════════════════════════════════════════════════════════\n2|# Bot Systems Registry\n3|# ═══════════════════════════════════════════════════════════════════════════\n4|# Each bot system registers here. The shared dashboard discovers them and\n5|# creates a tab for each one.\n6|#\n7|# To add a new bot system:\n8|# 1. Create bots/<name>/ with config.py, signal_engine.py, bot.py\n9|# 2. Add an entry here with the path to its directory\n10|# 3. Dashboard picks it up on next restart\n11|#\n12|# To remove a bot system:\n13|# 1. Set active: false or remove the entry\n14|# 2. Restart dashboard\n15|# ═══════════════════════════════════════════════════════════════════════════\n16|\n17|bot_systems:\n18| - name: \"Renko Xover (Raw)\"\n19| key: \"renko_vidya\"\n20| path: \"/home/ubuntu/bots/renko_vidya_bot\"\n21| service_prefix: \"renko-vidya-bot\"\n22| description: \"SMA(2) × VIDYA(20) Renko crossover\"\n23| active: true\n24|\n25| - name: \"Xover + Daily Trend Filter\"\n26| key: \"daily_vidya\"\n27| path: \"/home/ubuntu/bots/daily_vidya_bot\"\n28| service_prefix: \"daily-vidya-bot\"\n29| description: \"Zone-filtered VIDYA — line in stone, per-symbol broker\"\n30| active: true\n31|\n32| - name: \"Intraday Breakout (2-Loss Halt)\"\n33| key: \"google_lipi_vidya\"\n34| path: \"/home/ubuntu/bots/google_daily_lipi_vidya\"\n35| service_prefix: \"google-daily-lipi-vidya\"\n36| description: \"2-brick Renko + LIPI/anchor boundaries, intraday, 2 lots\"\n37| active: true\n38|\n39| - name: \"Xover Fut + Hedge\"\n40| key: \"crossover_lipi_vidya\"\n41| path: \"/home/ubuntu/bots/crossover_lipi_vidya\"\n42| service_prefix: \"crossover-lipi-vidya\"\n43| description: \"Margin-optimized 5-min VIDYA × LIPI Anchor crossover (Options + Futures)\"\n44| active: true", "total_lines": 43, "file_size": 2103, "truncated": false, "is_binary": false, "is_image": false}
2026-07-28 13:51
ASSISTANT (hermes, k3)
The four bot systems registered on bot.openalgo (from /home/ubuntu/bots/dashboard/bot_systems.yaml): 1. Renko Xover (Raw) — renko_vidya Path: /home/ubuntu/bots/renko_vidya_bot Service: renko-vidya-bot@<symbol> SMA(2) × VIDYA(20) Renko crossover 2. Xover + Daily Trend Filter — daily_vidya Path: /home/ubuntu/bots/daily_vidya_bot Service: daily-vidya-bot@<symbol> Zone-filtered VIDYA — line in stone, per-symbol broker 3. Intraday Breakout (2-Loss Halt) — google_lipi_vidya Path: /home/ubuntu/bots/google_daily_lipi_vidya Service: google-daily-lipi-vidya@<symbol> 2-brick Renko + LIPI/anchor boundaries, intraday, 2 lots 4. Xover Fut + Hedge — crossover_lipi_vidya Path: /home/ubuntu/bots/crossover_lipi_vidya Service: crossover-lipi-vidya@<symbol> Margin-optimized 5-min VIDYA × LIPI Anchor crossover (Options + Futures) All 4 are active: true. Want me to check which instances are currently running per system?
2026-07-28 13:51
USER (hermes, k3)
how is 2 and 4 different
2026-07-28 13:52
ASSISTANT (hermes, k3)
2026-07-28 13:52
TOOL (hermes, k3)
[Tool: search_files] {"total_count": 2, "files": ["/home/ubuntu/bots/crossover_lipi_vidya/mdocument/ARCHITECTURE.md", "/home/ubuntu/bots/crossover_lipi_vidya/mdocument/WORKING.md"]}
2026-07-28 13:52
TOOL (hermes, k3)
[Tool: search_files] {"total_count": 4, "files": ["/home/ubuntu/bots/daily_vidya_bot/mdocument/ARCHITECTURE.md", "/home/ubuntu/bots/daily_vidya_bot/mdocument/WORKING.md", "/home/ubuntu/bots/daily_vidya_bot/mdocument/TROUBLESHOOTING.md", "/home/ubuntu/bots/daily_vidya_bot/mdocument/LOGS.md"]}
2026-07-28 13:52
ASSISTANT (hermes, k3)
2026-07-28 13:52
TOOL (hermes, k3)
[Tool: read_file] {"content": "1|# Crossover LIPI & VIDYA Bot — Architecture\n2|\n3|## System Overview\n4|Standalone, margin-optimized intraday trading bot repository located at:\n5|`/home/ubuntu/bots/crossover_lipi_vidya/`\n6|\n7|Trades options + futures in a staggered sequence to maximize margin benefit and minimize margin requirement for futures positions.\n8|\n9|## Strategy Definition\n10|- **Symbols**: Configurable in `symbols.yaml` (default: ULTRACEMCO, Renko brick size 2.0).\n11|- **Signal**: Crossover of 5-min VIDYA(20) and LIPI VIDYA (Daily VIDYA line).\n12| - **`xover`**: 5-min VIDYA(20) crosses ABOVE LIPI VIDYA.\n13| - **`xunder`**: 5-min VIDYA(20) crosses BELOW LIPI VIDYA.\n14|\n15|## Staggered & Margin-Optimized Execution Sequence\n16|To receive exchange margin benefits for futures and prevent upfront margin surges:\n17|\n18|### 1. `xover` Flow (Bullish / Put + Long Future)\n19|- **If carrying reverse position (Call + Short Future)**:\n20| 1. `BUY` (Square off) Short Future\n21| 2. Wait 2 seconds (receive broker execution/confirmation)\n22| 3. `SELL` (Square off) Long Call\n23| 4. Wait 2 seconds\n24| 5. `BUY` OTM1 Put\n25| 6. Wait 2 seconds (receive portfolio margin hedge benefit)\n26| 7. `BUY` Long Future\n27|- **If Flat**:\n28| 1. `BUY` OTM1 Put\n29| 2. Wait 2 seconds\n30| 3. `BUY` Long Future\n31|\n32|### 2. `xunder` Flow (Bearish / Call + Short Future)\n33|- **If carrying reverse position (Put + Long Future)**:\n34| 1. `SELL` (Square off) Long Future\n35| 2. Wait 2 seconds\n36| 3. `SELL` (Square off) Long Put\n37| 4. Wait 2 seconds\n38| 5. `BUY` OTM1 Call\n39| 6. Wait 2 seconds\n40| 7. `SELL` (Short) Future\n41|- **If Flat**:\n42| 1. `BUY` OTM1 Call\n43| 2. Wait 2 seconds\n44| 3. `SELL` (Short) Future\n45|\n46|## Risk & Emergency Exits (SL ₹3,000)\n47|- Monitored on every poll.\n48|- Calculates combined live P&L of (Option + Future) from broker positionbook.\n49|- If Combined P&L $\\le -\\text{₹}3,000$:\n50| 1. Square off Future FIRST (`BUY` to cover Short Future, or `SELL` to close Long Future).\n51| 2. Wait 2 seconds.\n52| 3. Square off Option SECOND (`SELL` Call or Put).\n53| 4. Set `halted` flag for the day.\n54|\n55|## Multi-Broker Support\n56|Selectable broker per symbol in `symbols.yaml`: `shoonya`, `flattrade`, `kotak`.\n57|\n58|---\n59|\n60|## Crossover Detection — In-Memory State Change (July 28, 2026)\n61|\n62|This bot was ALREADY using the correct pattern (it never relied on the chart API's broken `crossover` field). It detects crossovers by comparing Renko VIDYA vs LIPI anchor directly:\n63|\n64|- `get_renko_vidya()` reads the 5-min DB directly, builds daily Renko bricks, computes VIDYA(20) on brick closes\n65|- `get_lipi_anchor()` reads the daily VIDYA anchor from chart API\n66|- Bot compares `vidya_now > lipi_anchor` (xover) vs `vidya_now < lipi_anchor` (xunder)\n67|- State tracked in `last_crossover_ts` (disk state file) to prevent re-triggering same crossover\n68|\n69|This is the referen ... [3985 chars total, truncated]
2026-07-28 13:52
TOOL (hermes, k3)
[Tool: read_file] {"content": "1|# Daily VIDYA Bot — Architecture\n2|\n3|## What this is\n4|\n5|A standalone, stateless, zone-filtered trading bot system. One systemd service\n6|per symbol: `daily-vidya-bot@<name>.service` (13 symbols).\n7|\n8|It trades the same SMA(2) × VIDYA(20) Renko crossover as the Renko VIDYA bot,\n9|PLUS a daily-trend zone filter (the \"line in stone\"). It may hold positions\n10|opposite to the renko bot on the same underlying — the logics are different\n11|and that is by design.\n12|\n13|**No files are shared with the renko bot.** This folder is self-contained:\n14|config.py, telegram.py, bot.py, daily_vidya_symbols.yaml.\n15|\n16|> **Note (Jul 27 2026 rewiring):** `signal_engine.py` is now **dead code**. All\n17|> computed values (Renko bricks, SMA, VIDYA, crossover signal, daily anchor)\n18|> are fetched from the chart API at `http://127.0.0.1:5050`. The bot no longer\n19|> computes anything itself and no longer reads the `daily_vidya` DB.\n20|\n21|## Strategy\n22|\n23|1. Signal: SMA(2) crosses VIDYA(20) on Renko bricks built from 5-min closes.\n24|2. Zone filter: yesterday's daily VIDYA = today's LINE IN STONE (anchor).\n25| - price > anchor + 0.5% → CLEAR_LONG\n26| - price < anchor − 0.5% → CLEAR_SHORT\n27| - inside ±0.5% → IN_ZONE\n28|3. Direction enforcement (ZONE_DIRECTION_ENFORCED=True in config.py):\n29| BUY_CALL only when CLEAR_LONG, BUY_PUT only when CLEAR_SHORT.\n30| IN_ZONE → HOLD existing position, no new entries.\n31|\n32|## Data flow (ZERO broker API calls for market data; ALL computation via chart API)\n33|\n34|```\n35|incremental_filler.py (cron */5, 9:00–15:xx Mon–Fri, shared chart infra)\n36| two-tier: symbols with a RUNNING bot (renko-vidya-bot@* OR daily-vidya-bot@*)\n37| get 5-min fills; all others hourly. Same API calls as before — the daily\n38| bot's 13 symbols are the same symbols the renko system already fills.\n39| │ writes\n40| ▼\n41|/var/www/openalgo-chart/api/dbs/<name>_5min.db ← source: 5min_db\n42| │\n43| ▼\n44|chart API (http://127.0.0.1:5050) ← the bot fetches ALL computed values from here\n45| ├─ GET /api/renko-signal/<SYM> → Renko bricks, SMA(2), VIDYA(20), crossover\n46| │ signal (source: 5min_db). Replaces the\n47| │ former in-process signal_engine.py math.\n48| └─ GET /api/daily-vidya/<SYM> → daily anchor (yesterday's VIDYA), the\n49| \"line in stone\". Replaces the former\n50| daily_vidya DB / daily_anchors table.\n51|```\n52|\n53|The bot makes **no local DB reads** and **no self-computation**. Two HTTP GETs\n54|to the chart API per poll supply every computed value. The broker API is\n55|touched only at trade time: positionbook (truth for positions), quotes (limit\n56|pricing), placeorder/cancelorder.\n57|\n58|> `signal_engine.py` remains in the folder but is no longer imported or called\n59| ... [6371 chars total, truncated]
2026-07-28 13:52
ASSISTANT (hermes, k3)
They trade different instruments off different signals. The short version: Bot 2 — Xover + Daily Trend Filter (daily_vidya_bot) - Instrument: OPTIONS ONLY. Buys 1-2 lots of OTM1 Call or Put, monthly expiry. No futures. - Signal: SMA(2) × VIDYA(20) crossover on Renko bricks (same core signal as bot 1), gated by yesterday's daily VIDYA anchor ±0.5% zone. In-zone = hold, no new entries; clear-long zone = calls only, clear-short zone = puts only. - Exit: opposite crossover flips it out (and reverses). A ₹1,500/lot SL is reported in alerts but never placed — exit-on-flip is the risk control. - State: fully stateless. Broker positionbook = truth, no state files. Bot 4 — Xover Fut + Hedge (crossover_lipi_vidya) - Instrument: FUTURES + an OTM1 option bought as a hedge, always as a PAIR. Long future + long put (bullish), or short future + long call (bearish). - Signal: 5-min VIDYA(20) crossing the LIPI VIDYA anchor — a different crossover than bot 2's SMA×VIDYA. - Execution: staggered leg sequence with 2-sec gaps, ordered to capture exchange margin benefit (option hedge goes on before the future leg; on reversal, future squares off first). If the option leg is rejected, the flow aborts so you never end up with a naked future. - Exit: hard combined-P&L stop of ₹3,000 across both legs, monitored every poll. Hit → square off future first, then option, then halt for the day. - State: keeps a disk state file (last_crossover_ts) to avoid re-firing the same crossover. So: bot 2 is a pure options buyer with a trend-zone filter and flip-based exits; bot 4 is a hedged futures system with margin-optimized staggered entries and a hard rupee stop-loss that halts the day.
2026-07-28 13:53
USER (hermes, k3)
read both codes and then tell me
2026-07-28 13:53
ASSISTANT (hermes, k3)
2026-07-28 13:54
TOOL (hermes, k3)
[Tool: terminal] {"output": "775 /home/ubuntu/bots/daily_vidya_bot/bot.py\n 816 /home/ubuntu/bots/crossover_lipi_vidya/bot.py\n 137 /home/ubuntu/bots/daily_vidya_bot/config.py\n 91 /home/ubuntu/bots/crossover_lipi_vidya/config.py\n 1819 total", "exit_code": 0, "error": null}
2026-07-28 13:54
ASSISTANT (hermes, k3)
2026-07-28 13:54
TOOL (hermes, k3)
[Tool: read_file] {"content": "1|#!/usr/bin/env python3\n2|\"\"\"\n3|════════════════════════════════════════════════════════════════════════════\n4|Daily VIDYA Bot — Zone-Filtered Renko VIDYA (standalone, stateless)\n5|════════════════════════════════════════════════════════════════════════════\n6|\n7|One systemd service per symbol: daily-vidya-bot@<name>.service\n8|\n9|STATELESS DESIGN — no state files, no brick-count memory. Every 60s poll:\n10|\n11| 1. Read local 5-min DB → Renko bricks → VIDYA(20) + SMA(2) → latest crossover\n12| 2. Read local anchor DB → yesterday's daily VIDYA (line in stone)\n13| + freshness guard: anchor date must equal the last trading day with data\n14| 3. Read broker → what position do I ACTUALLY have? (broker = truth)\n15| 4. Gates, in order:\n16| FRESHNESS — crossover within 5 min of its candle CLOSE (else monitor)\n17| ZONE — price outside anchor ±0.5% (else HOLD, no entry)\n18| DIRECTION — CALL only above anchor, PUT only below (config flag)\n19| 5. Signal vs broker position: match → hold · opposite → exit+reverse · flat → enter\n20|\n21|DATA: zero broker API calls for market data. 5-min candles and the daily\n22|anchor are read from local SQLite (same DBs as chart + renko bots).\n23|Broker API is touched ONLY at trade time: positionbook, quotes, orders.\n24|\n25|Crash → systemd Restart=on-failure → next poll is a full fresh assessment.\n26|════════════════════════════════════════════════════════════════════════════\n27|\"\"\"\n28|\n29|import logging\n30|import os\n31|import sys\n32|import threading\n33|import time\n34|import traceback\n35|from datetime import datetime, timedelta\n36|from pathlib import Path\n37|from typing import Optional\n38|\n39|import requests\n40|\n41|# ── Local imports (all files live in THIS folder — nothing shared) ──────────\n42|# Loaded by FILE PATH with unique module names: when the dashboard imports\n43|# this bot.py, plain `from config import ...` would resolve to the renko\n44|# bot's already-cached \"config\"/\"signal_engine\"/\"telegram\" modules.\n45|# Path-based loading keeps this system fully isolated.\n46|BOT_DIR = Path(__file__).parent.resolve()\n47|sys.path.insert(0, str(BOT_DIR))\n48|sys.path.insert(0, str(Path(\"/var/www/openalgo-chart/api\"))) # broker_config only\n49|\n50|import importlib.util as _ilu\n51|\n52|def _load_local(module_name: str, filename: str):\n53| spec = _ilu.spec_from_file_location(module_name, str(BOT_DIR / filename))\n54| mod = _ilu.module_from_spec(spec)\n55| spec.loader.exec_module(mod)\n56| return mod\n57|\n58|_cfg = _load_local(\"dv_config_local\", \"config.py\")\n59|BotConfig = _cfg.BotConfig\n60|load_all_configs = _cfg.load_all_configs\n61|load_single_config = _cfg.load_single_config\n62|LOG_DIR = _cfg.LOG_DIR\n63|DEFAULT_PRODUCT = _cfg.DEFAULT_PRODUCT\n64|FRESH_CROSSOVER_MINUTES = _cfg.FRESH_CROSSOVER_MINUTES\n65|CANDLE_MINUTES = _cfg.CANDLE_MINUTES\n66|ZONE_PCT = _cfg.ZONE_PCT\n67|ZONE_DIRECTION_E ... [40364 chars total, truncated]
2026-07-28 13:54
ASSISTANT (hermes, k3)
2026-07-28 13:54
TOOL (hermes, k3)
[Tool: read_file] {"content": "1|#!/usr/bin/env python3\n2|\"\"\"\n3|════════════════════════════════════════════════════════════════════════════\n4|Crossover LIPI & VIDYA Bot — Margin-Optimized Execution Engine\n5|════════════════════════════════════════════════════════════════════════════\n6|\n7|Strategy:\n8| Crossover of Renko 5-min VIDYA(20) and LIPI VIDYA Anchor (Daily VIDYA line):\n9| · LIPI Anchor = last completed trading day's fixed_vidya from daily_vidya DB (e.g. 11851.35)\n10| · Renko VIDYA = VIDYA(20, 0.2) computed on Renko(2) bricks from 5-min DB (e.g. 11800.73)\n11|\n12| Crossover Signals:\n13| · xover (Renko VIDYA 20 crosses ABOVE LIPI VIDYA Anchor):\n14| - If flat: Buy OTM1 Put ──► Wait 2s ──► Buy Future\n15| - If carrying position (Call + Short Future):\n16| 1. Square off Short Future (BUY) ──► Wait 2s\n17| 2. Square off Long Call (SELL) ──► Wait 2s\n18| 3. Buy OTM1 Put ──► Wait 2s\n19| 4. Buy Future\n20| · xunder (Renko VIDYA 20 crosses BELOW LIPI VIDYA Anchor):\n21| - If flat: Buy OTM1 Call ──► Wait 2s ──► Sell (Short) Future\n22| - If carrying position (Put + Long Future):\n23| 1. Square off Long Future (SELL) ──► Wait 2s\n24| 2. Square off Long Put (SELL) ──► Wait 2s\n25| 3. Buy OTM1 Call ──► Wait 2s\n26| 4. Sell Future\n27| \n28| Stop Loss:\n29| · Combined P&L of (Option + Future) <= -₹3,000 live from broker positionbook.\n30| · Exits Future FIRST ──► Wait 2s ──► Exits Option SECOND.\n31|\n32| Broker Integration:\n33| · Supports Shoonya, Flattrade, Kotak (configurable in symbols.yaml).\n34|════════════════════════════════════════════════════════════════════════════\n35|\"\"\"\n36|\n37|import argparse\n38|import json\n39|import logging\n40|import os\n41|import sqlite3\n42|import sys\n43|import threading\n44|import time\n45|import traceback\n46|from datetime import datetime\n47|from logging.handlers import RotatingFileHandler\n48|from pathlib import Path\n49|from typing import Optional, Dict, Tuple\n50|\n51|BOT_DIR = Path(__file__).parent.resolve()\n52|sys.path.insert(0, str(BOT_DIR))\n53|sys.path.insert(0, str(Path(\"/var/www/openalgo-chart/api\")))\n54|\n55|import importlib.util as _ilu\n56|\n57|def _load_local(module_name: str, filename: str):\n58| spec = _ilu.spec_from_file_location(module_name, str(BOT_DIR / filename))\n59| mod = _ilu.module_from_spec(spec)\n60| spec.loader.exec_module(mod)\n61| return mod\n62|\n63|_cfg = _load_local(\"clv_config_local\", \"config.py\")\n64|LOG_DIR = _cfg.LOG_DIR\n65|PRODUCT = _cfg.PRODUCT\n66|STRATEGY_TAG = _cfg.STRATEGY_TAG\n67|DATA_BROKER_PREFERENCE = _cfg.DATA_BROKER_PREFERENCE\n68|load_single_config = _cfg.load_single_config\n69|load_all_configs = _cfg.load_all_configs\n70|POLL_INTERVAL = getattr(_cfg, \"POLL_INTERVAL\", 60)\n71|STAGGER_DELAY_SEC = getattr(_cfg, \"STAGGER_DELAY_SEC\", 2.0)\ ... [41504 chars total, truncated]
2026-07-28 13:54
ASSISTANT (hermes, k3)
Read both bot.py files fully (775 and 816 lines). Here's what the code actually says — a few things differ from the docs: SIGNAL — what triggers a trade Bot 2 (daily_vidya): SMA(2) vs VIDYA(20) on Renko bricks, both values fetched from the chart API (/api/renko-signal). Entry fires only on a STATE CHANGE — one in-memory boolean self._last_sma_above compared between 60s polls. Flip the boolean → signal. No flip → no trade, even if conditions look perfect. Bot 4 (crossover_lipi): Renko VIDYA(20) vs the LIPI anchor (yesterday's daily VIDYA). But despite the name, it does NOT wait for a crossover event. In check_and_trade, if the bot is FLAT and vidya_now > anchor → it enters XOVER immediately (is_auto_entry = True). It's a state comparison, not an edge detector. The last_crossover_ts dedup is bypassed by is_auto_entry in exactly the flat/reversal cases. DATA SOURCES — opposite philosophies Bot 2: zero local DB reads. Everything computed comes from the chart API over HTTP; broker API touched only at trade time. Bot 4: reads SQLite directly — get_renko_vidya() opens <symbol>_5min.db, groups 5-min candles into daily closes, builds Renko bricks and computes VIDYA itself (imports signal_engine.py, which is dead code in bot 2). get_lipi_anchor() reads <symbol>_daily_vidya.db directly. Chart API is only a fallback. So bot 4 violates the "fetch from chart API, never self-compute" rule that bot 2 follows — and note its VIDYA is computed on DAILY closes grouped from 5-min data, a different series than bot 2's intraday renko-signal VIDYA. INSTRUMENTS & EXECUTION Bot 2: one option leg. BUY 1 lot OTM1 CE or PE, NRML LIMIT at LTP×1.03. On opposite signal: exit, sleep 2s, reverse. Max lots checked against live positionbook. Bot 4: two legs, staggered with 2s gaps. XOVER = buy OTM1 PE then buy future; XUNDER = buy OTM1 CE then short future. On reversal it squares off future first, then option, then re-enters (4 orders, ~6s). If the option entry leg is rejected, the flow aborts before the future leg — no naked futures. RISK CONTROLS Bot 2: no real stop-loss. sl_amount is only printed in alerts. Exit-on-flip is the only risk control. Plus entry gates: anchor freshness guard (≤3 days old), zone filter (±0.5% around anchor blocks entries), direction enforcement (CALL only in CLEAR_LONG, PUT only in CLEAR_SHORT). Bot 4: hard combined SL — option P&L + future P&L ≤ −₹3,000 (from live positionbook) → square off future first, then option, set halted=True for the day. Also has optional target profit (tp_inr), entry cutoff (14:55, no new entries after), and EOD squareoff at 15:15 if enable_eod_squareoff. Plus market-hours guard (09:15–15:20, Mon–Fri) — bot 2 has no time checks at all. STATE Bot 2: fully stateless. No files. Crash/restart → next poll reassesses from broker truth. Bot 4: day-state JSON at state/day_<name>.json — halted, mode (FLAT/XOVER/XUNDER), last_crossover_ts. Mode and last_crossover_ts carry forward across days for positional carryover. One practical consequence: bot 2 can sit flat for hours in-zone waiting for a fresh SMA×VIDYA flip; bot 4 will enter the moment it starts flat on the right side of the anchor — restart it mid-day flat and it trades on the next poll.
2026-07-28 13:55