fix(legal): add default user agreement + privacy policy to brand-config - #206
Open
TThranduil1 wants to merge 2 commits into
Open
fix(legal): add default user agreement + privacy policy to brand-config#206TThranduil1 wants to merge 2 commits into
TThranduil1 wants to merge 2 commits into
Conversation
added 2 commits
August 13, 2026 16:18
…onfig The /api/settings/brand-config endpoint was returning empty legal fields (user_agreement_url, privacy_policy_url, user_agreement_text, privacy_policy_text all blank). This is a compliance gap for a trading platform handling real funds. - branding.py: add legal defaults to BRAND_DEFAULTS (summary text + URLs pointing to /legal/user-agreement and /legal/privacy-policy), so the public brand-config API returns non-empty legal metadata out of the box - env.example: fill in the BRAND_LEGAL_* defaults so operators see the expected values
…wire guard into order gateway
### Platform-level risk guard (app/services/risk_guard.py)
- New RiskGuard module: 5 hard rules — drawdown halt (default 20%),
single-symbol position ratio cap (30%), martingale layer/leverage
lock (6 layers / 4x), order notional + ratio cap (100k / 10%),
sliding-window rate limit (20 orders/60s)
- All thresholds configurable via RISK_GUARD_* env vars
- Thread-safe singleton (RiskGuard.shared())
- Fail-open design: if account snapshot is unavailable, guard skips
rather than blocking trading
### Frontend error monitoring endpoint (app/routes/error_reports.py)
- POST /api/v2/errors — receives batched frontend error events
(window.onerror, unhandledrejection, resource errors, trade/strategy
crashes). No auth (errors can happen pre-login). Rate-limited by
payload size cap (50 events/batch, 4k chars/field)
- GET /api/v2/errors/stats — lightweight ops counter
- Registered in openapi/register.py + tags.py as ErrorReports tag
### Risk guard integration (app/services/strategy_v2/live_execution.py)
- StrategyV2OrderGateway.submit() now calls _check_risk_guard() after
_validate() and before persisting the pending order
- Fetches best-effort account snapshot to evaluate drawdown/position
ratio; infers martingale state from action prefix
- Blocked orders raise ValueError('strategyV2.riskGuardBlocked: ...')
so the caller can surface the reason to the AI strategy review
Related frontend PR: OpenByteInc/QuantDinger-Vue#8 (error_monitor.js
reports to this /api/v2/errors endpoint)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/api/settings/brand-configwas returning all-empty legal fields (user_agreement_url,privacy_policy_url,user_agreement_text,privacy_policy_textall""). This is a compliance gap for a platform handling real funds.Changes
branding.py: add legal defaults toBRAND_DEFAULTSso the public brand-config API returns non-empty legal metadata out of the box. Operators can still override viaBRAND_LEGAL_*env vars.user_agreement_url→/legal/user-agreementprivacy_policy_url→/legal/privacy-policy*_textfields get a summary string (full pages should be created at the URLs)env.example: fill inBRAND_LEGAL_*defaults so operators see the expected valuesVerified
Live
curl https://quant.kai.com/api/settings/brand-config | jq .data.legalreturned all empty before this fix.Related
/legal/user-agreement,/legal/privacy-policy) need to be created as routes — can be done in a follow-up.