feat: harden Conway input sanitization, replication startup, and safety keys#166
Open
stackiesmash wants to merge 7 commits intoConway-Research:mainfrom
Conversation
… multi-TF, TWAP
5 battle-tested patterns from Hummingbot research (2026-02-19):
1. Kill Switch / Max Drawdown Guard (loop.ts)
- Halts trading 12h if session P&L hits -5% (-$50 virtual)
- Code-level guard enforced before every LLM inference call
2. ATR-based Position Sizing (tools.ts — calculate_atr tool)
- New tool: calculate_atr(symbol) → ATR14 from 1h candles
- Formula: size = $100 × ($50 / ATR14), clamped $10-$500
3. Multi-Timeframe Confluence (tools.ts — fetch_market_context tool)
- New tool: fetch_market_context(symbol) → 1h/4h/daily trend
- Required call before any trade entry
4. Paper trade tracking (tools.ts — open/close/check_paper_position tools)
- open_paper_position: records entry with all 3 barriers
- close_paper_position: records exit, updates session P&L
- check_paper_positions: checks all barriers, returns any expired
5. SOUL.md strategy upgrades
- Full Triple Barrier rules documented
- ATR sizing formula with examples
- Kill switch rules
- TWAP entry splitting guidance
- Multi-TF confluence requirement
New files: src/trading/{atr.ts,drawdown.ts,market.ts}
The early sleep check in loop.ts was breaking out of the while loop
without calling db.setAgentState('sleeping'), causing index.ts outer
loop to immediately re-run the agent instead of sleeping properly.
Manifested as a rapid-fire restart loop after Pi's Hummingbot upgrades
introduced the outer while(running) loop in index.ts.
…a, and skill command safety
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
Verification
Notes