feat(agents): scaffold delta-neutral funding carry agent - #182
Open
david-hummingbot wants to merge 1 commit into
Open
feat(agents): scaffold delta-neutral funding carry agent#182david-hummingbot wants to merge 1 commit into
david-hummingbot wants to merge 1 commit into
Conversation
Adds funding_carry_expert with the spot_perp_carry strategy: long spot, short perp, matched notional, on a single venue. Return is the funding the short leg collects; there is no directional exposure. Chosen because the edge is observable rather than predicted. Validated on 90 days of Bitget funding history across BTC/ETH/XRP/SOL/DOGE/LINK: funding is positive 69-79% of periods with P(pos|pos) of 77-88%, which makes it a carry to hold rather than a spread to chase. Findings encoded in the scaffold: - Never gate on funding sign. Closing on negative prints is the main way this loses money: BTC nets +46bps held vs -371bps when exiting on sign flips. Funding flips 52-93 times per 270 periods but negative prints are tiny, so each exit pays ~21bps to dodge a fraction of one. The strategy and skill both state this explicitly because an LLM's instinct is to "manage" the position. - A spot market is a hard requirement, not a preference. Screening all Bitget perps causally, the median annualised net is -2.6% across high-carry names but +10.6% for those with a spot listing. Without a spot leg there is no hedge and it becomes a naked perp. Spot-listed names showed 72-100% hit rates and 1-2 side changes over ~99 days; non-spot names showed 7-45% and 16-44. - Size on the trailing mean, never a snapshot. One live XRP funding print annualised to ~7.8% against a 90-day mean nearer 3%. - shutdown.md uses flatten_all, inverting the framework default. keep_spot_close_perp would close the hedge and leave a naked long, which for a strategy whose safety property is neutrality is the worst outcome available. funding_screener.py ranks candidates by realised buy-and-hold carry net of one round trip, and reports rejected unstable names so high funding on a flipping sign is not mistaken for opportunity. Ships as dry_run, $200 default, 3600s ticks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Adds
funding_carry_expertwith thespot_perp_carrystrategy: long spot, short perp, matched notional, on a single venue. Price moves cancel between the legs, so the entire return is the funding the short leg collects.Ships as
dry_run, $200 default, 3600s ticks. Additive only — no existing behaviour touched.Why this strategy
Validated on 90 days of Bitget funding history (BTC/ETH/XRP/SOL/DOGE/LINK): funding is positive 69–79% of periods with P(pos|pos) of 77–88%. That persistence is what makes it a carry you hold rather than a spread you chase — and is exactly why the cross-venue differential version failed while this one doesn't.
Expected net: 1–4% APR on majors, ~10% on screened names. Modest, and stated plainly in the docs rather than dressed up.
Three findings encoded in the scaffold
Never gate on funding sign
The intuitive move — close when funding turns negative — destroys the strategy:
Funding flips sign 52–93 times per 270 periods, but negative prints are tiny — each exit pays ~21 bps to dodge a fraction of one. This appears in
AGENT.md,strategy.md, and the deploy skill, because an LLM's instinct is to actively manage the position and here that instinct is the primary failure mode. The strategy's decision table answers "HOLD" to five separate alarming-looking observations.A spot market is a hard requirement, enforced in code
Screening all Bitget perps causally (side chosen from a trailing window, then forward funding collected):
Spot-listed names showed 72–100% hit rates with 1–2 side changes over ~99 days. Non-spot names showed 7–45% with 16–44 changes — funding that flips constantly and churns fees into a loss. Without a spot leg there is no hedge, so it is a naked perp rather than a carry.
require_spotdefaults true and the docs say never to disable it. The screener also reports rejected unstable names with their negative hold-net — those are the highest-funding symbols on the board, so surfacing them stops the agent rediscovering them as opportunities.Size on the trailing mean, never a snapshot
One live XRP funding print annualised to ~7.8%; the 90-day mean was nearer 3%. The screener emits both
funding_now_bpsandfunding_mean_bpsand the strategy is instructed to size from the mean.shutdown.mdinverts the framework defaultUses
flatten_allrather thankeep_spot_close_perp. The default would close the hedge and leave a naked long — for a strategy whose entire safety property is neutrality, that is the worst available outcome. Both legs go together, perp first to shed liquidation risk.Consequence documented: use
shutdown, not plainstop, when positions are open, or the API returns 409.Known limitations