fix(strategy): make sentiment telemetry provider-neutral - #186
Merged
Conversation
Record LLM failures as error_fallback with the configured provider and attempted model, page DeepSeek/xAI/Z.AI by name instead of Grok, and treat successful DeepSeek and Z.AI replies as live in reports. Historical xai_live, xai_error_fallback, neutral_fallback, and deepseek_fallback events still parse. Strategy rules, fail-closed BUY blocking, and rising-edge paging are unchanged. Co-Authored-By: Grok 4.6 <noreply@x.ai>
Trujillofa
force-pushed
the
fix/sentiment-telemetry-provider-neutral
branch
from
August 27, 2026 16:52
807691d to
dff7e1e
Compare
Move source taxonomy to src/sentiment_sources.py so the report can run from a file path or stdin without importing src.strategy.
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
Prospective-only telemetry fix: sentiment degradation and event attribution no longer hardcode Grok/xAI when DeepSeek or Z.AI is the configured provider. Successful DeepSeek and Z.AI replies count as live/answered. Failed provider requests are recorded as
error_fallbackwith the configured provider and attempted model. Historical event logs are not rewritten.Rebased onto current
origin/mainafter #184 (feat/zai-provider) sozai_liveis treated as answered and Z.AI failures are not labeledprovider=xai.This PR does not change strategy rules, thresholds, position sizing, trading mode, or execution. Fail-closed BUY blocking and rising-edge-only degradation paging are preserved.
Do not merge as a deploy authorization. Paper evidence window starts only after independent review and a separate deploy.
Type of Change
SHAs
origin/main):7d57c22498aebe75fdf98aa12042176cf07f1273dff7e1e7a7ba492438d534312658c5de6b67a21dWhat changed and why
src/strategy/sentiment_mean_reversion.pyerror_fallback(provider-neutral); stamp configured provider/model on failures; alert names DeepSeek/xAI/Z.AI, not Grok; shared answered/error source sets (xai_live,deepseek_fallback,zai_live; historicalxai_error_fallback).src/main.pyprovideron record; inferzaifromzai_*sources; daily summary live% uses answered sources.src/overseer/xai.pyprovider/modelproperties so failures can be attributed without poking privates.scripts/sentiment_report.pyxai_error_fallbackanderror_fallbackas errors; drop Grok-hardcoded health copy.tests/test_sentiment_mean_reversion.pytests/test_settings_integration.pyprovider=zai.tests/test_sentiment_report.pyCompatibility for old event logs
Readers accept both old and new source names. Nothing in stored JSONL is rewritten.
sourcexai_livedeepseek_fallbackzai_livexai_error_fallbackneutral_fallbackProspective writes:
sourceprovidermodelxai_livexaideepseek_fallbackdeepseekzai_livezaierror_fallbackdeepseek,zai, orxai)noneneutral_fallbacknonenoneDegradation still uses a rolling 10-observation window at >= 50% no-answer (
error_fallback+ historicalxai_error_fallback+neutral_fallback). Successful DeepSeek and Z.AI replies are not no-answer.Strategy / trading
Unchanged: RSI/BB gates, sentiment thresholds, panic SELL, high-vol filter, fail-closed block of new BUY when degraded, rising-edge-only Telegram paging. Pinned by
test_evaluate_trading_contract_is_unchangedand existing degrade/repage tests.Testing
uv run pytest -q— 1399 passeduv run ruff check .uv run ruff format --check .(ruff is canonical; templateblack --checknot run)git diff --checkcleanFocused:
tests/test_sentiment_mean_reversion.py,tests/test_sentiment_report.py,tests/test_settings_integration.py,tests/test_xai_client.py,tests/test_config.py.Checklist
Notes
PR only. After independent review and a separate SHA-pinned deploy, begin a pre-registered DeepSeek paper evidence window. Do not treat the existing three paper trades as validation. Current
sentiment-macroconfig on main is Z.AI; this PR does not change that provider setting.