Skip to content

reddygopalkrishna/trading-skills / skills/trading-entry

trading-entry

Verified

Entry timer for intraday setups in any market - watches bar by bar and says the moment a setup triggers, waiting (and how far), still forming, expired or market closed. Opening-range breakout (first 15 minutes by default) or a break of any level you give, long or short, on 1, 2, 5 or 15-minute bars, with an optional volume check and a no-entries-near-the-close cutoff. Reads each exchange's session from the data (NSE 09:15, NYSE 09:30, LSE 08:00...), replays past sessions for practice, and hands the trigger to trading-plan with stop ideas. Never places an order. Use when the user says "tell me when to get in", "watch RELIANCE", "has it broken out", "did it break the opening range", "time my entry", "ORB", "check my watchlist for breakouts", or after a scan finds a setup.

FileKindSize
SKILL.mdskill md3.9 KB
assets/watchlists/crypto-majors.txtmarkdown112 B
assets/watchlists/global-index-etfs.txtmarkdown106 B
assets/watchlists/global-large-caps.txtmarkdown306 B
assets/watchlists/india-large-caps.txtmarkdown291 B
assets/watchlists/us-mega-caps.txtmarkdown173 B
assets/watchlists/world-indices.txtmarkdown104 B
scripts/_vendor/tradekit/__init__.pyscript516 B
scripts/_vendor/tradekit/alerts.pyscript7.5 KB
scripts/_vendor/tradekit/analysis.pyscript10.3 KB
scripts/_vendor/tradekit/backtest.pyscript17.8 KB
scripts/_vendor/tradekit/brokers/__init__.pyscript1022 B
scripts/_vendor/tradekit/brokers/_rest.pyscript2.7 KB
scripts/_vendor/tradekit/brokers/base.pyscript3.5 KB
scripts/_vendor/tradekit/brokers/dhan.pyscript6.8 KB
scripts/_vendor/tradekit/brokers/fyers.pyscript7.1 KB
scripts/_vendor/tradekit/brokers/groww.pyscript7.7 KB
scripts/_vendor/tradekit/brokers/kite.pyscript14.5 KB
scripts/_vendor/tradekit/brokers/paper.pyscript12.7 KB
scripts/_vendor/tradekit/brokers/upstox.pyscript7.8 KB
scripts/_vendor/tradekit/cli.pyscript2.4 KB
scripts/_vendor/tradekit/config.pyscript6.0 KB
scripts/_vendor/tradekit/data.pyscript18.5 KB
scripts/_vendor/tradekit/disclosures.pyscript17.4 KB
scripts/_vendor/tradekit/expr.pyscript19.0 KB
scripts/_vendor/tradekit/feeds.pyscript9.4 KB
scripts/_vendor/tradekit/frame.pyscript8.9 KB
scripts/_vendor/tradekit/fundamentals.pyscript6.1 KB
scripts/_vendor/tradekit/gate.pyscript8.1 KB
scripts/_vendor/tradekit/http.pyscript4.3 KB
scripts/_vendor/tradekit/indicators.pyscript13.1 KB
scripts/_vendor/tradekit/journal.pyscript11.1 KB
scripts/_vendor/tradekit/metrics.pyscript6.2 KB
scripts/_vendor/tradekit/montecarlo.pyscript7.8 KB
scripts/_vendor/tradekit/options.pyscript24.4 KB
scripts/_vendor/tradekit/patterns.pyscript12.9 KB
scripts/_vendor/tradekit/report.pyscript8.4 KB
scripts/_vendor/tradekit/risk.pyscript4.7 KB
scripts/_vendor/tradekit/sec.pyscript12.0 KB
scripts/_vendor/tradekit/session.pyscript9.4 KB
scripts/entry.pyscript8.1 KB

scripts/_vendor/tradekit/brokers/groww.py

View on GitHub
"""Groww Trade API adapter (REST, standard library only).

Credentials (environment variables win over secrets.json):
    GROWW_ACCESS_TOKEN / groww_access_token   expires daily 06:00; create it under Groww > Trading APIs
    GROWW_API_KEY / groww_api_key             optional: lets `groww-login` mint the token with the approval flow
    GROWW_API_SECRET / groww_api_secret

Symbols are EXCHANGE:TRADINGSYMBOL (e.g. NSE:RELIANCE). Segment is CASH (equity) only here.
Products: CNC, MIS, NRML.
Cost: a "Trading API Subscription" is required (see groww.in/user/profile/trading-apis); the price is not
published in the API docs. Rate limits: orders 10/s and 250/min.
The docs do not state the response shape of every call; the field names used are the ones listed on
groww.in/trade-api/docs/curl (order list, holdings, positions, margins). No quotes are available, so
position values are at cost.
"""

from __future__ import annotations

import hashlib
import time
import uuid
from typing import Dict, List, Optional

from .. import config
from . import _rest
from .base import Broker, BrokerError, normalize_order

BASE = "https://api.groww.in/v1"
_TYPE = {"market": "MARKET", "limit": "LIMIT", "stop": "SL_M", "stop_limit": "SL"}
_PRODUCT = {"CNC": "CNC", "MIS": "MIS", "NRML": "NRML"}
_OPEN = ("NEW", "ACKED", "TRIGGER_PENDING", "APPROVED", "MODIFICATION_REQUESTED", "CANCELLATION_REQUESTED")
_FILLED = ("EXECUTED", "COMPLETED")


class GrowwClient:
    def __init__(self, access_token: Optional[str] = None):
        self.access_token = access_token or config.secret("groww_access_token", "GROWW_ACCESS_TOKEN")

    def _h(self) -> Dict[str, str]:
        _rest.need("Groww", access_token=self.access_token)
        return {"Authorization": f"Bearer {self.access_token}", "Accept": "application/json", "X-API-VERSION": "1.0",
                "Content-Type": "application/json"}

    def _req(self, method, path, params=None, body=None):
        j = _rest.call("Groww", method, BASE + path, self._h(), params=params, body=body)
        if isinstance(j, dict) and j.get("status") == "FAILURE":
            e = j.get("error") or {}
            raise BrokerError(f"Groww {method} {path}: {e.get('message', j)} ({e.get('code')})")
        return j.get("payload", j) if isinstance(j, dict) else j

    def generate_token(self, api_key: str, api_secret: str) -> Dict:
        ts = str(int(time.time()))
        checksum = hashlib.sha256((api_secret + ts).encode()).hexdigest()
        j = _rest.call("Groww", "POST", BASE + "/token/api/access",
                       {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json", "Accept": "application/json"},
                       body={"key_type": "approval", "checksum": checksum, "timestamp": ts})
        data = j.get("payload", j) if isinstance(j, dict) else {}
        if not data.get("token"):
            raise BrokerError("Groww did not return a token (approve the API key on the Groww Cloud API Keys page first)")
        self.access_token = data["token"]
        return data

    def margins(self):
        return self._req("GET", "/margins/detail/user")

    def holdings(self):
        return self._req("GET", "/holdings/user")

    def positions(self):
        return self._req("GET", "/positions/user", params={"segment": "CASH"})

    def orders(self):
        return self._req("GET", "/order/list", params={"segment": "CASH", "page": 0, "page_size": 100})

    def place_order(self, body):
        return self._req("POST", "/order/create", body=body)

    def cancel_order(self, order_id):
        return self._req("POST", "/order/cancel", body={"segment": "CASH", "groww_order_id": order_id})


def split_symbol(symbol: str):
    if ":" in symbol:
        e, t = symbol.split(":", 1)
    else:
        e, t = (config.load()["broker"].get("default_exchange") or ""), symbol
    if e.upper() not in ("NSE", "BSE") or not t:
        raise BrokerError("use EXCHANGE:SYMBOL with NSE or BSE (e.g. NSE:RELIANCE) or set broker.default_exchange")
    return e.upper(), t.upper()


class GrowwBroker(Broker):
    name = "groww"
    live = True

    def __init__(self, client: Optional[GrowwClient] = None):
        self.client = client or GrowwClient()
        self.cfg = config.load()

    def account(self) -> Dict:
        m = self.client.margins() or {}
        cash = _rest.f(m.get("clear_cash"))
        return {"broker": "groww", "live": True, "currency": self.cfg["account"].get("currency"),
                "cash": round(cash, 2), "equity": round(cash, 2), "margin_used": _rest.f(m.get("net_margin_used"))}

    def positions(self) -> List[Dict]:
        out = []
        for h in (self.client.holdings() or {}).get("holdings", []):
            q = _rest.f(h.get("quantity"))
            if q:
                avg = _rest.f(h.get("average_price"))
                out.append({"symbol": f"NSE:{h.get('trading_symbol')}", "qty": q, "avg_price": avg, "last_price": avg,
                            "market_value": round(q * avg, 2), "unrealized_pnl": 0.0, "product": "CNC"})
        for p in (self.client.positions() or {}).get("positions", []):
            q = _rest.f(p.get("quantity"))
            if q:
                avg = _rest.f(p.get("net_price"))
                out.append({"symbol": f"{p.get('exchange', 'NSE')}:{p.get('trading_symbol')}", "qty": q, "avg_price": avg,
                            "last_price": avg, "market_value": round(q * avg, 2),
                            "unrealized_pnl": 0.0, "realized_pnl": _rest.f(p.get("realised_pnl")), "product": p.get("product")})
        return out

    def orders(self, open_only: bool = False) -> List[Dict]:
        out = []
        for o in (self.client.orders() or {}).get("order_list", []):
            st = str(o.get("order_status", "")).upper()
            if open_only and st not in _OPEN:
                continue
            out.append({"order_id": o.get("groww_order_id"), "symbol": f"{o.get('exchange')}:{o.get('trading_symbol')}",
                        "side": str(o.get("transaction_type", "")).lower(), "qty": o.get("quantity"),
                        "type": o.get("order_type"), "limit_price": o.get("price"), "stop_price": o.get("trigger_price"),
                        "status": "filled" if st in _FILLED else st.lower(), "filled_qty": o.get("filled_quantity"),
                        "avg_fill_price": o.get("average_fill_price"), "product": o.get("product"),
                        "created": o.get("created_at"), "message": o.get("remark")})
        return out

    def to_params(self, order: Dict) -> Dict:
        o = normalize_order(order)
        exch, ts = split_symbol(o["symbol"])
        ref = "TS" + uuid.uuid4().hex[:12].upper()  # 14 chars, alphanumeric (docs: 8-20)
        p = {"trading_symbol": ts, "quantity": _rest.whole_qty(o, "Groww"), "validity": "DAY", "exchange": exch,
             "segment": "CASH", "product": _rest.product_for(order, _PRODUCT, "Groww"), "order_type": _TYPE[o["type"]],
             "transaction_type": o["side"].upper(), "order_reference_id": ref}
        if o["limit_price"] is not None:
            p["price"] = o["limit_price"]
        if o["stop_price"] is not None:
            p["trigger_price"] = o["stop_price"]
        return p

    def place(self, order: Dict) -> Dict:
        params = self.to_params(order)
        j = self.client.place_order(params) or {}
        if not j.get("groww_order_id"):
            raise BrokerError(f"Groww did not return an order id: {str(j)[:200]}")
        return {"order_id": j["groww_order_id"], "status": "submitted", "broker_status": j.get("order_status"),
                "broker": "groww", "params": params}

    def cancel(self, order_id: str) -> Dict:
        j = self.client.cancel_order(order_id) or {}
        return {"order_id": j.get("groww_order_id", order_id), "status": "cancel_requested"}
slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack."Stars: 198kUpdated Claude CodeCodexVerifiedInstall
ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt.Stars: 196kUpdated Claude CodeCodexVerifiedInstall