reddygopalkrishna/trading-skills / skills/trading-entry
trading-entry
VerifiedEntry 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.
scripts/_vendor/tradekit/http.py
View on GitHub"""Minimal HTTP client on urllib with retries and JSON helpers."""
from __future__ import annotations
import json
import os
import ssl
import time
import urllib.error
import urllib.parse
import urllib.request
from typing import Any, Dict, Optional
USER_AGENT = "Mozilla/5.0 (compatible; trading-skills/0.2; +https://github.com/reddygopalkrishna/trading-skills)"
# Well-known OS certificate bundles. Some Python builds (notably the python.org macOS
# installer before "Install Certificates.command" is run) ship with an empty CA store.
SYSTEM_CA_BUNDLES = (
"/etc/ssl/cert.pem", # macOS, Alpine, BSD
"/etc/ssl/certs/ca-certificates.crt", # Debian/Ubuntu
"/etc/pki/tls/certs/ca-bundle.crt", # Fedora/RHEL
"/etc/ssl/ca-bundle.pem", # openSUSE
)
_SSL_CONTEXT: Optional[ssl.SSLContext] = None
def ssl_context() -> ssl.SSLContext:
"""A verifying SSL context. Falls back to the OS bundle when Python's own store is empty.
Certificate verification is never disabled. SSL_CERT_FILE / SSL_CERT_DIR still win.
"""
global _SSL_CONTEXT
if _SSL_CONTEXT is None:
ctx = ssl.create_default_context()
if not ctx.get_ca_certs() and not os.environ.get("SSL_CERT_FILE") and not os.environ.get("SSL_CERT_DIR"):
for bundle in SYSTEM_CA_BUNDLES:
if os.path.isfile(bundle):
try:
ctx.load_verify_locations(cafile=bundle)
break
except (ssl.SSLError, OSError):
continue
_SSL_CONTEXT = ctx
return _SSL_CONTEXT
class HTTPError(RuntimeError):
def __init__(self, status: int, message: str, body: str = ""):
super().__init__(f"HTTP {status}: {message}")
self.status = status
self.body = body
def request(method: str, url: str, params: Optional[Dict[str, Any]] = None,
data: Optional[Dict[str, Any]] = None, headers: Optional[Dict[str, str]] = None,
timeout: float = 20.0, retries: int = 2, backoff: float = 1.5,
json_body: Optional[Any] = None) -> bytes:
if params:
clean = {k: v for k, v in params.items() if v is not None}
url = url + ("&" if "?" in url else "?") + urllib.parse.urlencode(clean, doseq=True)
body = None
hdrs = {"User-Agent": USER_AGENT, "Accept": "application/json, text/csv, */*"}
if headers:
hdrs.update(headers)
if json_body is not None:
body = json.dumps(json_body).encode()
hdrs.setdefault("Content-Type", "application/json")
elif data is not None:
body = urllib.parse.urlencode({k: v for k, v in data.items() if v is not None}).encode()
hdrs.setdefault("Content-Type", "application/x-www-form-urlencoded")
last_err: Optional[Exception] = None
for attempt in range(retries + 1):
req = urllib.request.Request(url, data=body, method=method.upper(), headers=hdrs)
try:
with urllib.request.urlopen(req, timeout=timeout, context=ssl_context()) as resp:
return resp.read()
except urllib.error.HTTPError as e:
text = e.read().decode("utf-8", "replace")[:2000]
# retry only on throttling / transient server errors, never on order endpoints' 4xx
if e.code in (429, 500, 502, 503, 504) and attempt < retries and method.upper() == "GET":
time.sleep(backoff * (attempt + 1))
last_err = HTTPError(e.code, e.reason, text)
continue
raise HTTPError(e.code, str(e.reason), text) from None
except (urllib.error.URLError, TimeoutError, ConnectionError) as e:
last_err = e
if attempt < retries and method.upper() == "GET":
time.sleep(backoff * (attempt + 1))
continue
hint = ""
if "CERTIFICATE_VERIFY_FAILED" in str(e):
hint = (" | Python cannot find root certificates. On macOS run 'Install Certificates.command' "
"from your Python folder, or set SSL_CERT_FILE to a CA bundle.")
raise RuntimeError(f"network error for {urllib.parse.urlsplit(url).netloc}: {e}{hint}") from None
raise RuntimeError(f"request failed: {last_err}")
def get_json(url: str, **kw) -> Any:
return json.loads(request("GET", url, **kw).decode("utf-8"))
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| 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: 194k | Updated | Claude CodeCodex | Verified | Install |