Skip to main content

tradingsignalbot

The Python client for the TradingSignalBot API.

The API is a preview. It is not live yet, so this package holds only the part you need first: verifying the signature of a webhook delivery, so you know an event came from TradingSignalBot and was not changed or replayed. The full client (render a chart from your own levels, register webhooks, read signals) comes here when the sandbox opens. Get early access to get sandbox keys first.

pip install tradingsignalbot

Standard library only (hmac.compare_digest), Python 3.8+, typed.

Verify a delivery

from flask import Flask, request, abort
from tradingsignalbot import verify_webhook, WebhookVerificationError

app = Flask(__name__)

@app.post("/hooks/signals")
def signals():
    try:
        event = verify_webhook(request.get_data(), request.headers.get("TSB-Signature"), SECRET)
    except WebhookVerificationError as e:
        abort(400, e.code)
    return "", 204

Pass the raw body, exactly as it arrived. Parsed and re-serialised JSON will not match.

The scheme

The scheme, as the API page states it:

Header TSB-Signature: t=<timestamp>,v1=<signature> (shown on the preview page)
Timestamp Unix seconds (the preview's example uses the event's time in seconds)
Signed "<timestamp>.<raw body>", HMAC-SHA256 with your webhook secret
Signature lowercase hex, 64 characters
Window the timestamp within 300 seconds of your clock, against replays (tolerance changes it, 0 turns it off)
Several v1= any one matching is enough, for secret rotation

The repository's test-vectors.json holds the cases both packages are tested against.

Both packages compare in constant time and check every signature and every secret, so a mismatch takes as long as a match.

API

Function Does
verify_webhook(body, header, secret, tolerance=300, now=None) Verifies, returns the parsed event
verify_signature(...) Verifies, returns the timestamp; raises WebhookVerificationError
is_valid_signature(...) True / False
sign_payload(body, secret, timestamp=None) The header TradingSignalBot would send: for your tests
compute_signature(body, secret, t) The hex HMAC
parse_signature_header(header) (timestamp, signatures)

secret can be a list while you rotate it. WebhookVerificationError.code is one of missing_header, bad_header, no_signature, timestamp, mismatch, bad_json.

Licence

MIT. Source and the JavaScript package: github.com/TradingSignalBot/sdk.


Part of the Forexia network: InterestRateDecision.com · Forexia Academy · TradingSignalBot · PropSim · OpenCharts

Metadata

Release files for tradingsignalbot 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tradingsignalbot 0.1.0
File Size Uploaded Provenance Actions
tradingsignalbot-0.1.0.tar.gz 5.8 kB Without provenance Details for tradingsignalbot-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tradingsignalbot 0.1.0
File Interpreter ABI Platform Actions
tradingsignalbot-0.1.0-py3-none-any.whl Python 3 none any Details for tradingsignalbot-0.1.0-py3-none-any.whl

Total release size: 12.0 kB

Release files / tradingsignalbot-0.1.0.tar.gz

Download URL tradingsignalbot-0.1.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
835631f11e35daf479475918918924733a881aaef2c1d08f9d6520e1e501b9f1
BLAKE2b-256 checksum
How to use checksums
f258158efedba2d0dc627378f55f34b9ebdae58e69aba1ad01e947324b68a3c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / tradingsignalbot-0.1.0-py3-none-any.whl

Download URL tradingsignalbot-0.1.0-py3-none-any.whl
Size 6.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0c1aed17a7dda4ea8807d04fb51e264f136b448f719272a4f439679e396a466
BLAKE2b-256 checksum
How to use checksums
100a23fb1e5ad52c0f9dd5ee2e6b345fd8480cfc0e6aa3f05586c0b1e018fca8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for tradingsignalbot 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page