Implement --auto-rebalance mode, signal/definitions/ declarative config, and built-in indicators#16
Merged
Conversation
…ors (SMA_CROSS, RSI, PRICE_CHANGE) Agent-Logs-Url: https://github.com/JetSquirrel/longbridge-fs/sessions/4995d1ec-dfc9-44da-922a-2ab77dc7ed11 Co-authored-by: JetSquirrel <20291255+JetSquirrel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement next items for auto-rebalance and built-in metrics
Implement --auto-rebalance mode, signal/definitions/ declarative config, and built-in indicators
Mar 31, 2026
JetSquirrel
approved these changes
Mar 31, 2026
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.
Advances Phase 2 (v0.4.0) and Phase 3 (v0.5.0) of the Harness pipeline: auto-rebalance closes the portfolio drift → order loop without manual intervention; the signal layer adds declarative config + built-in indicator computation.
--auto-rebalancemode (Phase 2)New
AutoCreatePending()ininternal/portfolio/rebalance.goreadsportfolio/diff.jsonand auto-generatesportfolio/rebalance/pending.jsonwhenrequires_rebalance: true. Guards against double-execution (no-op ifpending.jsonalready exists). Wired into the controller loop afterComputeDiff().Signal definitions + built-in indicators (Phase 3)
New
internal/signal/package:definitions.go—ListDefinitions()scanssignal/definitions/*.json, filtersenabled: true; validatestypeasbuiltinorexternalindicator.go— Three built-in indicators reading close prices fromquote/hold/{SYMBOL}/D.json:SMA_CROSS— fast/slow SMA crossover with relative-distance strengthRSI— Wilder RSI with configurable overbought/oversold thresholdsPRICE_CHANGE— percentage change over a configurable windowsignal.go—ComputeAll()orchestrates definition scan → kline load → indicator dispatch → per-symboloutput/latest.json+history.jsonl→signal/active.jsonaggregationoutput.go—WriteOutput,AppendHistory,WriteActiveSignalsExample signal definition (
signal/definitions/sma_crossover.json):{ "name": "sma_crossover", "type": "builtin", "version": 1, "params": { "indicator": "SMA_CROSS", "fast_period": 5, "slow_period": 20 }, "symbols": ["AAPL.US"], "enabled": true }ComputeAll()is called each controller cycle (after research refresh, before portfolio sync) viasignalpkgalias to avoid collision withos/signal. Also completes thesignal/active.jsonaggregation item from Phase 3.New model types added:
SignalDefinition,SignalOutput,SignalEntry,ActiveSignals,ActiveSignalEntry.