Skip to content

feat(agents): Derive Perp Smart-Money Flow Agent - #178

Open
carlito-hummingbot wants to merge 12 commits into
hummingbot:mainfrom
carlito-hummingbot:feat/smart-money-flow-agent
Open

feat(agents): Derive Perp Smart-Money Flow Agent#178
carlito-hummingbot wants to merge 12 commits into
hummingbot:mainfrom
carlito-hummingbot:feat/smart-money-flow-agent

Conversation

@carlito-hummingbot

Copy link
Copy Markdown

Summary

Adds the Smart-Money Flow Condor agent: a directional perpetual-futures
trader that reads cross-market capital-flow + an on-chain Solana DeFi pulse
and takes bounded LONG/SHORT positions on Derive (derive_perpetual).

  • agents/smart_money_flow/ — AGENT.md, strategies/derive_flow_trader/
    (strategy.md + 50-USDC test-mode config), routines/onchain_flow.py
    (CoinGecko + GeckoTerminal keyless signal), skills/smart_money_playbook/,
    HOW_IT_WORKS.md, validation.md
  • Flow composite: risk regime (mcap momentum, BTC dominance) + per-asset
    flow intensity (vol/mcap, 24h change, trending) + Solana on-chain pulse
  • Decision matrix: LONG (RISK-ON + flow ≥ +0.4), SHORT (RISK-OFF + flow ≤ −0.4),
    else HOLD — no forced trades
  • Execution: Derive perps, USDC-quoted (SOL/ETH/BTC-USDC), bounded sizing
    (max 20 USDC/position, 2x, 1 position, 50-USDC wallet)
  • LLM: opencode-go:deepseek-v4-flash (cheap; ~$0.10–0.35/day at 300s cadence)

Depends on

Requires the opencode-go / deepseek provider from PR #170 (the agent's
agent_key uses opencode-go:deepseek-v4-flash). This PR is agent-only;
provider infra lands separately in #170.

Validation

  • Live on Derive mainnet (tiny ~55 USDC wallet): engine ticks, reads live
    data, returns HOLD in current RISK-OFF regime (correct — no signal ≥ ±0.4)
  • Manual SOL-USDC LONG placed + closed end-to-end (fees ~$0.02), proving the
    Derive execution path works
  • Frontend: rebuilt dist; strategy detail route loads (was a stale bundle +
    folder/slug mismatch — both fixed)

Notes

  • Tested on Derive mainnet only (other perp venues untested by design)
  • Condor UI filters testnet connectors, so validation is mainnet-with-small-size

📸 Screenshots attached: Agents tab (Live), strategy detail, onchain_flow report.
Agents_01
Agents_02
Agents_03
Routines_01
Routines_02
Routines_03

Carlito and others added 12 commits July 28, 2026 23:01
Directional perp agent driven by a capital-flow & positioning composite:
cross-market risk regime (CoinGecko /global + /coins/markets + /search/trending)
plus an on-chain Solana DeFi pulse (GeckoTerminal SOL top pools). The routine
produces a LONG/SHORT/HOLD signal; execution is venue-agnostic (Derive,
Hyperliquid, Backpack, Pacifica, ...) via default_trading_context + Hummingbot
server — the routine never calls an exchange API.

- agents/smart_money_flow/AGENT.md: identity, opencode-go:deepseek-v4-flash
- routines/onchain_flow.py: keyless signal fetch + scoring + ReportBuilder
- strategies/directional_flow/strategy.md: directional perp playbook, risk limits
- skills/smart_money_playbook/SKILL.md: flow decision matrix

Verified: routine compiles and scores correctly live (RISK-OFF -> HOLD;
forced RISK-ON +6.5% -> LONG +0.80; RISK-OFF -9.5% -> SHORT -0.40).
Pivoted from Orca Whirlpools spot (CLMM cannot express directional/short).
…alidation runbook

- strategy.md default_trading_context now names derive_perpetual as the concrete
  venue, documents the one-time 'connect derive_perpetual' step (Condor/API does
  NOT add keys by design), and gates mainnet behind derive_perpetual_testnet.
- validation.md: testnet-first runbook proving execution before PR submission
  (connect once in client; Condor/API drives the connected instance).
…or code

Verified against repo:
- API keys are added ONLY via web dashboard (Settings -> Keys); Telegram /keys
  is read-only; MCP API does not add keys.
- Condor web filters out testnet connectors (condor/web/routes/settings.py:
  'testnet' not in c.lower()), so derive_perpetual_testnet is NOT selectable.
  Validation must be mainnet derive_perpetual on a tiny isolated wallet.

Updated validation.md and strategy.md default_trading_context accordingly.
Cap budget at 50 USDC total: total_amount_quote 50, max_total_exposure_quote 50,
max_position_size_quote 20, min_order_amount_quote 10, single position
(max_open_executors 1), 2x leverage (~40 USDC notional, under balance). Keep
production defaults documented separately. Aligns strategy.md + HOW_IT_WORKS.md.
…-USDC

Derive perpetuals are quoted in USDC (trading-rule map + order-book subscription
both require '-USDC'), not USDT. Correct default_trading_context pairs and the
validation note accordingly.
…t result

Restarting hummingbot-api repopulates the derive_perpetual symbol map after a
bad-pair attempt (SOL-USDT) poisons it. Golden rules: use SOL/ETH/BTC-USDC on
Derive; restart container if create_executor hangs with KeyError. Records the
verified LONG SOL-USDC place+close on Derive mainnet (~$0.02 fees).
AGENT.md now states tested on Derive mainnet only (removed other DEXes from
description/body). HOW_IT_WORKS.md adds concise LLM-per-tick cost note:
deepseek-v4-flash pricing, prompt-cache effect, ~$0.10/day typical at 300s
cadence.
…w_trader)

The strategy folder was named 'directional_flow' while the strategy name
'Derive Flow Trader' slugifies to 'derive_flow_trader'. The web GET
/agents/{slug}/strategies/{sslug} resolves by folder name, so the frontend
(open button) passed the slug 'derive_flow_trader' and got 404
'Strategy not found'. Moved strategy.md into the slug-named folder and
removed the stale directional_flow folder. Also tightened the description
to Derive-only (remove Hyperliquid/Backpack/Pacifica per user request).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s in onchain_flow

- AGENT.md when_to_consult tightened to Derive perps (drop 'any venue').
- onchain_flow.py: report pair labels SOL/ETH/BTC now show -USDC to
  match Derive's USDC-quoted perps (signal is venue-independent; the
  displayed label was stale USDT).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… prevent frontmatter truncation

The '# --- ... ---' comment inside default_config ended YAML frontmatter at
the first '---', silently dropping risk_limits / sizing / trading_context.
The running engine then fell back to unsafe engine defaults. The fix removes
the dashes from the comment.
…m for opencode-go model

Switches agent_key from 'opencode-go:deepseek-v4-flash' to
'custom@opencode:deepseek-v4-flash' so the agent runs on opencode-go via PR hummingbot#175's
named custom OpenAI-compatible endpoint (no PR hummingbot#170 needed). Documents endpoint
setup: Settings -> LLM Endpoints, or CUSTOM_LLM_BASE_URL/CUSTOM_LLM_API_KEY in .env
for headless condor-bot.service deploys.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant