Skip to content
All strategies

Strategies

ADA Hedged Funding Carry at Binance's Interest-Rate Floor: Long ADAUSDT Spot + Short ADAUSDT USD-M Perp While the Trailing 3-Day Mean Funding Is >= 0.01%/8h, Flat When It Turns Negative (1H bars, delta-neutral, ~50% time-in-market)

Outcome: Abandoned

AdaHedgedFundingCarryFloor1H

Outcome Summary

AdaHedgedFundingCarryFloor1H tried to harvest ADA perp funding with a hedged spot-long/perp-short pair, gated on the trailing 3-day mean funding sitting at or above the 0.01%/8h protocol floor. Its funding-only pre-study (no basis P&L) looked promising at +3.22% net per episode across 26 episodes. Over 4 iterations the code gained total-equity sizing, liquidation-buffer resets and anti-churn rules, but it never passed verification. The run was abandoned because Layer 1 static analysis flagged an abs()-based funding timestamp lookup as look-ahead, so no backtest, optimization or analyst review ever took place.

Hypothesis

Source: 小草, 'FMZ官方收费策略介绍', FMZ digest (https://www.fmz.com/digest-topic/6613), section 1 '币安永续套取资金费率策略'. The article has four mechanisms. Only section 1 is used here. Sections 2-3 (spot and perp fixed grids) are rejected: they are bar-level mean reversion with no regime rule, which is the fee graveyard family, and the article admits they only work in ranging markets. Section 4 (the Leeks-Reaper-derived HF trade-flow scalper) is rejected under lesson L167: it needs rebates and sub-second loops, and our port of it……Show moreShow less

Source: 小草, 'FMZ官方收费策略介绍', FMZ digest (https://www.fmz.com/digest-topic/6613), section 1 '币安永续套取资金费率策略'. The article has four mechanisms. Only section 1 is used here. Sections 2-3 (spot and perp fixed grids) are rejected: they are bar-level mean reversion with no regime rule, which is the fee graveyard family, and the article admits they only work in ranging markets. Section 4 (the Leeks-Reaper-derived HF trade-flow scalper) is rejected under lesson L167: it needs rebates and sub-second loops, and our port of it already went to -100%. The section 1 idea is restated from first principles, not ported. The article's 30+ coin hand-picked basket is replaced by ONE liquid coin (lessons L151 and L137). The '-0.2% emergency exit' is replaced by a trailing-mean rule. MECHANISM (one sentence, instrument stripped): Binance USD-M funding = premium + clamp(interest - premium, ±0.05%), with interest fixed at 0.03%/day. So whenever the perp premium sits inside the clamp band, longs pay shorts a structural 0.01%/8h (~11% APR), and more in speculative regimes. A spot-long / perp-short pair collects that cash flow with no directional exposure. The economic payer is the leveraged long who prefers perp exposure to buying spot. INSTRUMENTS: long leg ADAUSDT.BINANCE_SPOT (CASH, 1x). Short hedge leg ADAUSDT.BINANCE (USD-M perp, 1x notional, ~2x account leverage on its margin slice). Signal: the Binance USD-M funding_rate supplementary key for ADAUSDT. That key is collected for BINANCE USD-M, per lesson L160. Bars: 1-HOUR on both legs, used only for execution and hedge-ratio checks. Why ADA: it has 6.6 years of funding history (2020-01 onward), mean 8h funding of +0.0124%, and near-zero use in the corpus. BTC is not used (it is over the concentration share). ETH gave only 9-13 episodes. LINK is already in the pipeline as a directional funding trade. PRE-STUDY (funding stream only, point-in-time, run before proposing, basis P&L NOT included): trailing 9-print (3-day) mean funding. Enter at >= 0.0100%/8h, exit when the mean falls below 0. On ADAUSDT 2020-01 to 2026-09 this gave 26 episodes, median hold 31 days, median funding collected per episode 0.69% of notional, mean 3.52%. Net of a 0.30% round trip (spot 0.20% + perp 0.10%), the mean is +3.22% per episode, and 77% of episodes are net-positive. Time in market is about 50%. Five episodes started in the last two years. Selection choices, stated per lesson L122: the coin (ADA, chosen from a 6-coin pre-study of ETH/DOGE/LINK/XRP/ADA/SOL; all six were net-positive, so the mechanism does not depend on the pick), the window (3 days = 9 settlements) and the entry threshold (0.01% = the protocol's interest floor, not a fitted number). The exit at 0 means 'the shorts start paying'.

This iteration is a resubmission. The factory log shows only one backtest for this run (bt-...-i1), and the only registered strategy file is AdaHedgedFundingCarryFloor1H_v1.py (iteration-1 code). The iteration 2-4 feedback files are byte-identical copies of the first review, written 3 minutes apart. So the code that already carried review fixes 1-4 and refinements 1-4 was never backtested. This submission keeps that logic unchanged. (1) Sizing uses total book equity x capital_frac/2 instead of min(). (2) Perp……Show moreShow less

This iteration is a resubmission. The factory log shows only one backtest for this run (bt-...-i1), and the only registered strategy file is AdaHedgedFundingCarryFloor1H_v1.py (iteration-1 code). The iteration 2-4 feedback files are byte-identical copies of the first review, written 3 minutes apart. So the code that already carried review fixes 1-4 and refinements 1-4 was never backtested. This submission keeps that logic unchanged. (1) Sizing uses total book equity x capital_frac/2 instead of min(). (2) Perp margin safety: no inter-venue transfer exists in the engine (runner funds each venue with a fixed $100k), so the approach is venue leverage 3 plus a perp notional cap of perp_eq x min(3 x 0.8, 1/(liq_buffer + reset_room)). (3) After a reset, the pair re-opens at the size recomputed from total equity, with no cooldown. (4) Every close logs its reason and hold time, and holds under 24h are flagged SHORT HOLD, so the 2-hour pairs are traceable. Other retained changes: the funding AND basis gate on entry and exit, a 24h minimum hold, a 24h cooldown, and the hedge-integrity flatten. Only change in this iteration: each open logs the pair notional as % of total book and which cap bound it (target, perp_cap or spot_cap), and each close logs the entry notional, so the '>= 40% of book' metric can be audited. Structural caveat: the initial pair is 40% of the book, but after a liquidation-buffer reset the drained perp account caps re-opened pairs at about 25-30% of book, because the engine cannot move cash between venues. Refinement 5 (maker perp leg first) is not implemented. A SELL limit at the bar close would be marketable, so it would fill as taker in the bar-based engine. A resting limit above the close would leave about 1H of one-legged exposure. The saving is about 0.06% per pair against a pre-study mean of about 3.5% per episode.

verification_loop: Verification failed (Layer 1 — static analysis): - Look-ahead: a supplementary observation is selected by ABSOLUTE distance to the bar timestamp, which returns the NEXT observation when it is closer than the previous one. Use self.supp_as_of(key) (latest at or before the bar) or an explicit `ts <= bar.ts_init` filter — never abs(). (line 241)

Implementation

Delta-neutral ADA funding carry: long ADAUSDT spot + equal-quantity short ADAUSDT USD-M perp while the trailing 9-print (3-day) mean 8h funding is >= 0.01%/8h (Binance's interest floor) and the basis is >= 0. Exit when the mean is < 0 and the basis is <= 5bp, after a 24h minimum hold. Hard exit if the mean is < -0.01%/8h or funding goes stale. Each pair is sized from total book equity (0.8 x total / 2 per leg). The perp account is kept margin-safe with 3x venue leverage and a liquidation-buffer reset. Orphan or mismatched legs are flattened, with a 24h re-entry cooldown.

Verification Results

Verification failed (Layer 1 — static analysis): - Look-ahead: a supplementary observation is selected by ABSOLUTE distance to the bar timestamp, which returns the NEXT observation when it is closer than the previous one. Use self.supp_as_of(key) (latest at or before the bar) or an explicit `ts <= bar.ts_init` filter — never abs(). (line 241)

When the pair is open and _entry_px==0, seed _entry_px from the perp position's avg_px_open.

The hedge-check anchor _entry_px and the _rehedge_pending flag are only in-memory. After a paper/live restart with the pair open, _entry_px=0 and the 40% re-hedge check is silently disabled for the rest of the episode. The comment says 'persisted across restarts', but nothing reconstructs them from open positions.

Optional: log a 'naked_leg_unwind' counter so any such events show up in diagnostics.

The two legs are submitted as independent market orders. If one is rejected (e.g. the spot CASH leg is short of cash after fees), the naked-leg guard closes the other leg on the next bar. That is safe, but it costs a full round trip, and at 1.0 leverage with a 0.5 capital_frac a failure like this should be rare. There is no alternative to this; it is noted for the analyst.

Keep it only if the base contract allows it.

min_bars_required() override shadows the base method (static-analysis warning). It is harmless because no price indicators are used and the funding window has its own full-window check.

Analysis

See workspace/discussions/60066445-7e7a-4e07-a878-4abd7f7ab7ec/iteration_1_feedback.md. Fixes: (1) size each pair from total book equity (perp plus spot) × capital_frac / 2 per leg, not from min(); (2) keep the perp leg margin-safe with perp-venue leverage (for example 3, with notional capped at perp_eq × leverage × 0.8), or rebalance the two accounts at every reset if the engine can transfer between venues; (3) re-open at the full rebalanced size after a hedge reset; (4) find out why two pairs (2021-05-19 and……Show moreShow less

See workspace/discussions/60066445-7e7a-4e07-a878-4abd7f7ab7ec/iteration_1_feedback.md. Fixes: (1) size each pair from total book equity (perp plus spot) × capital_frac / 2 per leg, not from min(); (2) keep the perp leg margin-safe with perp-venue leverage (for example 3, with notional capped at perp_eq × leverage × 0.8), or rebalance the two accounts at every reset if the engine can transfer between venues; (3) re-open at the full rebalanced size after a hedge reset; (4) find out why two pairs (2021-05-19 and 2021-06-22) closed after 2 hours with zero funding. Metric expected to move: perp notional should stay at or above 40% of equity in every episode (it is about 2-6% now), and funding P&L for 2023-2025 should rise from about $50-650 a year to low thousands. If net return per episode, after the roughly 0.30% two-leg round trip, is still below 0.30% of notional after the fix, abandon as fee_edge. Separately, the paired ±7% prints on flat days go to the harness team; it is not a strategy fix. ## Library refinements (from the knowledge library; test them, do not assume them) The library's funding-arbitrage course (51bitquant class_20/21/22) teaches the same spot-long/perp-short carry. Where it differs from this strategy: it sizes to a fixed target quantity, protects the perp leg with a liquidation-distance rule rather than frequent resets, requires BOTH a funding condition and a spread (basis) condition to open and to close, and flattens the spot leg at once if the hedge breaks. Adopting these deals with the shrinking notional and the fee churn behind the -0.027% per-trade result. 1. [sizing] Fixed target size from total book + liquidation-distance reset instead of 40% rehedge: At each episode entry set target coin qty Q = capital_frac * (perp_eq + spot_eq) / 2 / price, with capital_frac = 0.8 (per-leg notional about 40% of total book). Set config leverage = 3 on the perp venue and cap perp notional at perp_eq * 3 * 0.8. Remove rehedge_move = 0.40. Replace it with a liquidation-buffer rule: reset the pair only when perp_eq < 0.35 * perp_notional (about an 80% ADA rally from entry at the sizes above). After a reset, reopen at min(Q_new, perp cap), where Q_new again comes from total equity, never from min(perp_eq, spot_eq). — The analyst found notional falling from $50k to about $2k because min()-based sizing followed the drained perp account after each 40% reset, so funding income fell to $46-154 a year. The course software sizes to a fixed 'initial_target_pos' (要对冲的最大的目标数量) and fills up to it while funds allow. It guards the short leg with 'close_before_liquidation_pct' (the leg is closed only when price nears the liquidation price), not a fixed price-move trigger. The class_20 notes list liquidation (爆仓导致仓位清算) as the main risk to manage. Fewer resets also means fewer 0.30% two-leg round trips. (source: 套利软件策略参数说明和使用 p.1; 套利介绍 p.1; 第十五课: 为什么合约(期货)危险? p.1) 2. [entry] Two-condition gate: funding AND basis must agree to open and to close: Compute basis_t = perp_close / spot_close - 1 on each aligned 1H close. ENTER only if funding_mean_9 >= 0.0001 AND basis_t >= 0.0 (perp not trading at a discount to spot). Normal EXIT only if funding_mean_9 < 0.0 AND basis_t <= +0.0005, so we never close into a wide positive basis that the short leg would pay for. Hard EXIT regardless of basis if funding_mean_9 < -0.0001 or if the funding data goes stale (keep max_funding_age_hours = 24). — The course states the profit as '价差+资金费率' (spread plus funding). Its risk list includes '平仓的时候价差扩大,赚的资金费率没有覆盖手续费和价差': a widened spread at close can wipe out the funding collected. The software opens only when both 'open_spread_ptc' and 'open_rate_pct' are met, and closes only when both 'close_spread_ptc' and 'close_rate_pct' are met (要同时满足价差和资金费率). The current strategy ignores basis entirely, and 50% of its pairs lose money, so the basis P&L at entry and exit is a likely source of the leak. (source: 套利软件策略参数说明和使用 p.1; 套利介绍 p.1) 3. [filter] Anti-churn: minimum episode life and re-entry cooldown: Ignore the normal exit (hard exits still apply) until the pair has been on for 3 funding settlements (24h). After any exit, block re-entry for 24h (3 settlements). Record in the log why each pair closed after less than 24h, so the 2021-05-19 and 2021-06-22 two-hour pairs (-$823, -$1037, zero funding) can be traced to the stale-funding check, the rehedge, or the signal. — The first risk the course lists is '资金费率没有了,亏了手续费': funding stops and the fees are simply lost. A pair opened and closed within 2 hours pays the full ~0.30% round trip and cannot collect a single 8h print. The two-condition close rule in class_22 is a hysteresis device for the same reason. A 24h floor guarantees each paid round trip is exposed to at least 3 settlements (about 0.03% at the floor rate, more in speculative regimes). (source: 套利介绍 p.1; 套利软件策略参数说明和使用 p.1) 4. [stop] Hedge-integrity check: flatten the orphan leg when quantities diverge: On every 1H close while in carry, compare open coin quantities. If |spot_qty - perp_qty| / max(spot_qty, perp_qty) > 0.05, or either leg is missing (liquidated, rejected, or partially filled), close the excess or orphan leg at market on that bar and mark the episode flat. Allow re-entry only through the normal entry gate and cooldown. — The course software sells the matching spot if the perp is liquidated or auto-deleveraged ('爆仓会卖出相应的现货,降低单边敞口风险'; '防止交易所减仓,也会卖出相应的现货'). Its risk list names '对冲不及时,造成仓位敞口风险'. The vnpy spread doc says the passive leg must hedge right after the active leg fills (对冲必须尽可能及时). Two separate venue accounts and min-notional rounding make a one-sided position possible here, and one would put directional ADA risk into a book meant to be delta-neutral. (source: 套利软件策略参数说明和使用 p.1; 套利介绍 p.1; 价差交易模块 p.1) 5. [cost] Maker perp leg first, market spot hedge on fill: Treat the perp as the active leg. At the signal close, post a limit order on ADAUSDT.BINANCE at the bar close price (short entry / buy-to-close exit), good for 2 bars. On fill, send the spot leg as a market order at the next bar. If the limit order has not filled after 2 bars, cancel it and send both legs at market. With our fees (perp maker 0.02% vs taker 0.05%; spot 0.10% either way) this cuts the two-leg round trip from about 0.30% to about 0.24% of notional when the limit orders fill. — The course software's main cost lever is making one leg a maker order ('合约是maker(0.02%)', with taker on the other leg). vnpy's spread module fills the active leg first and hedges immediately with the passive leg. Per-trade return is currently -0.027% against a 0.30% round trip, so a 0.06% saving on every pair matters. It does not fix the edge by itself, and the backtest has to confirm the fill rate. (source: 套利软件策略参数说明和使用 p.1; 价差交易模块 p.1)

Iteration History

Verification failed (Layer 1 — static analysis): - Look-ahead: a supplementary observation is selected by ABSOLUTE distance to the bar timestamp, which returns the NEXT observation when it is closer than the previous one. Use self.supp_as_of(key) (latest at or before the bar) or an explicit `ts <= bar.ts_init` filter — never abs(). (line 223)

Verification failed (Layer 1 — static analysis): - Look-ahead: a supplementary observation is selected by ABSOLUTE distance to the bar timestamp, which returns the NEXT observation when it is closer than the previous one. Use self.supp_as_of(key) (latest at or before the bar) or an explicit `ts <= bar.ts_init` filter — never abs(). (line 239)

Outcome Summary

Point-in-time funding lookups must use self.supp_as_of()/supp_window() or an explicit ts <= bar.ts_init filter; any abs()-distance timestamp match is a hard Layer 1 error that blocks the strategy before it can be backtested.

After 4 iterations the run was abandoned in a verification loop. Layer 1 static analysis kept rejecting the code for look-ahead because it picked the supplementary funding observation by absolute distance to the bar timestamp (line 241), which can return the next print.

A delta-neutral ADA funding carry: hold long ADAUSDT spot and short ADAUSDT USD-M perp while the trailing 9-print (3-day) mean funding is at or above Binance's 0.01%/8h interest-rate floor, and go flat when the mean turns negative. The aim was to collect the structural payment that longs make to shorts.

No pipeline backtest or optimization metrics exist for this run: the backtest report is empty and no optimization report was produced. The only numbers are from the hypothesis's funding-only pre-study, which excluded basis P&L: 26 episodes over 2020-01 to 2026-09, mean +3.22% per episode net of a 0.30% round trip, 77% of episodes net-positive, and about 50% time in market.

Abandon Reason

verification_loop: Verification failed (Layer 1 — static analysis): - Look-ahead: a supplementary observation is selected by ABSOLUTE distance to the bar timestamp, which returns the NEXT observation when it is closer than the previous one. Use self.supp_as_of(key) (latest at or before the bar) or an explicit `ts <= bar.ts_init` filter — never abs(). (line 241)

Backtest Review

Sharpe
0.23
Total return
5.85%
Max drawdown
0.45%
Trades
102
Win rate
50.0%
Profit factor
1.06

Backtest and paper results are hypothetical. Trading involves risk of loss.