Type/to search

ANT价差收敛_双周期动态网格_V3.0.1

Common strategy
Created: 2026-11-06 09:32:00
Last modified: 8 hours ago
2
Follow
544
Followers

ANT Spread Convergence · Dual-Timeframe Dynamic Grid

Risk warning: Live trading is enabled by default, and the strategy sends real orders. The assumed share count does not guarantee contract equivalence, rebasing or convergence. Cross-exchange hedging does not eliminate spread divergence, single-leg liquidation, funding, liquidity or execution mismatch risk. P&L uses configured fees and funding budgets rather than final exchange settlements. Verify contract units, permissions, fees and margin before running.

Strategy Concept

The strategy studies spreads between Anthropic pre-market contracts. Its fixed direction is long Hyperliquid xyz:ANT and short Binance or OKX ANTHROPIC. Quotes and quantities are normalized using the selected share-count assumption and contract specifications.

Two timeframes serve different purposes:

  • The long timeframe sizes the initial position. Recent spread location, available balances, reserve capacity and estimated downside room determine the initial number of paired lots.
  • The short timeframe controls grid spacing. The strategy reduces one paired lot when the spread narrows sufficiently and conditionally refills or adds one when it widens.
  • A fully flat position ends the round. Once both legs are flat and no request is unresolved, the round is settled and a new plan uses current prices and balances.

The strategy does not automatically reverse its hedge direction. Statistical bands are recent activity ranges, not guaranteed price boundaries.

WS Interface and Execution Architecture

The strategy uses FMZ's WebSocket event interface. ctx.subscribe provides depth and private account streams, while ctx.poll processes quotes, orders, fills and connection events.

  1. Executable spreads: five depth levels are subscribed on xyz and twenty on the CEX. Order-size-weighted execution prices produce separate entry and exit spreads. Historical closes support statistics; current depth drives trading.
  2. Historical preparation: startup pairs closed candles from the same minute on both venues. WS samples subsequently update the history. Insufficient, sparse, stale or discontinuous history blocks new rounds.
  3. Sequential execution: the xyz leg executes first, followed by the CEX hedge sized from confirmed fills. Normal WS execution uses IOC limit orders with price tolerance. Simultaneous or complete fills are not guaranteed.
  4. Account and order routing: available balances primarily come from WS, with REST queries when required fields are missing. Detected Binance portfolio-margin accounts use REST limit orders, with WS reports still required to confirm outcomes.
  5. Unresolved requests: unknown terminal states remain recorded and block blind resubmission and new exposure. Reconnection alone does not establish that orders or positions have been reconciled.

Use a node supporting the required depth and private streams and ctx.subscribe, ctx.poll and ctx.submit. Support depends on the venue and account type. REST routing does not replace the required WS data and account reports.

Trading Workflow

text
Add Hyperliquid futures + Binance or OKX futures ↓ Verify conversion assumptions, contracts, positions and open orders ↓ Prepare paired history → wait for valid quotes and account snapshots ↓ Long-timeframe planning: location, capacity and initial paired lots ↓ Confirm plan → execute both legs → split confirmed fills into lots ↓ Short-timeframe grid: reduce / refill / add conditionally ↓ Both legs flat and no unresolved request → settle the round ↓ Refresh balances → plan the next round

Initial Position Planning

Defaults use a 24-hour window and its 10th–90th percentile spread band, with at least two hours of valid history.

Initial size is constrained by funding capacity, band location, reserve requirements and available profit room. Approximately 25% of capacity is reserved where capacity permits; a one-lot account cannot reserve an additional lot. If available room cannot support one grid step, the strategy waits.

The round's capacity and initial planning snapshot remain fixed after entry. Long-timeframe changes do not repeatedly rebuild the initial position during that round.

Dynamic Grid Execution

The default short window is 30 minutes. Reduction and addition spacing are calculated separately, both defaulting to approximately one third of the robust spread range, subject to the cost-and-profit floor.

Confirmed trades update the reference spread. After a reduction, the next refill uses the current reduction spacing.

Normal reductions check the reference level, the lot's own entry cost and estimated net proceeds using actual entry prices, executable exit prices, configured fees and the lot's accrued funding budget. Reaching a spread trigger alone is insufficient.

Additions also require available balances, acceptable effective leverage, round capacity, remaining profit room, sufficient depth and the current grid upper bound. A jump beyond that bound waits for updated statistics rather than being chased.

Round Completion and Risk Handling

A round ends when the final lot is closed, both legs are flat and no request remains unresolved. No permanent base position is retained for eventual convergence.

There is no additional inter-round delay by default, but a new round still requires planning and confirmation. The optional spread protection level is disabled by default. Deleveraging, exception handling and manual closes may realize losses.

Fees and Cost Conditions

A paired entry and exit involve four fills. With similar leg notionals:

Round-trip fees = 2 × (xyz taker fee + CEX taker fee)

Grid spacing also includes slippage allowance and a minimum net-profit requirement:

Cost-and-profit floor = round-trip fees + 2 × per-leg slippage budget + minimum net profit

Defaults are:

  • xyz taker fee: 1 bp;
  • CEX taker fee: 4 bps;
  • per-leg slippage budget: 5 bps;
  • minimum net profit: 5 bps.

The resulting default spacing floor is 25 bps. This is a configured budget and trading threshold, not a fixed realized cost or a profit guarantee.

Enter actual account and market fees. Funding data is read from the exchanges where available; otherwise the configured budget is used. Individual grid net estimates do not allocate funding, while round settlement deducts the accumulated round funding budget. Reconcile final results against both exchanges' statements.

Live Configuration

Configure exactly two exchanges:

  • Hyperliquid futures: xyz:ANT_USD.swap;
  • Binance USDT-margined futures or OKX futures: ANTHROPIC_USDT.swap.

The Hyperliquid leg uses available USDC and the CEX leg available USDT. Use independent accounts or avoid external positions and orders in the target contracts.

The default pre-market share-count assumption is 12.7 billion. Binance quotes are normalized by 127 ÷ 10, and OKX by 127 ÷ 100. Quantities additionally account for contract multipliers, precision and minimum order requirements. The converted stage uses one share per unit in the code; official contract rules must still be verified.

The default planning leverage is 2. The strategy does not configure exchange leverage or margin mode. Set these separately.

Startup checks positions and open orders without taking over external exposure. Ledger mismatches, external orders or unresolved requests block startup. Exchanges, conversion settings and live/paper mode cannot be changed while positions or unresolved requests remain.

Main Live Parameters

ParameterDefaultPurpose
Live tradingOnSends real orders; off simulates against live depth. Change only while flat.
CEX conversion stagePre-marketSelects the applicable conversion assumption.
Share count, in 100 million shares127Determines quote normalization and hedge quantities.
Planning leverage2Sizes capacity; does not configure exchange leverage.
Long window, hours24Initial position planning band.
Minimum valid history, hours2Coverage, continuity and freshness must also pass.
Tail trimming, %10Uses the 10th–90th percentile range on both timeframes.
Initial capacity reserve, %25Limits initial exposure and preserves addition capacity.
Maximum lots per round0Automatic sizing; positive values can enlarge lots and limit their count.
Short window, minutes30Updates grid range and spacing.
Reduction spacing / short range0.333333Subject to the cost-and-profit floor.
Addition spacing / short range0.333333A refill after reduction uses reduction spacing.
Fallback spacing, bps100Used with fewer than five short-window minute points.
Minimum net profit, bps5Used in spacing and normal reduction checks.
Plan confirmation / action interval, seconds2Confirms new plans and limits action frequency.
Additional flat cooldown, seconds0New planning and confirmation still apply.
Deleveraging threshold3Attempts paired reductions after a leg remains above the threshold for three seconds.
Planning funding reserve, days3Funding budget horizon, not a holding deadline.
Fallback net daily funding, bps10Used when valid funding data is unavailable.
Optional spread protection, bps0Disabled at zero; positive values enable protective closing.
Cumulative round-loss limit, U10Blocks new rounds and additions at the negative limit.
xyz / CEX taker fees, bps1 / 4Configure actual account fees.
Price tolerance and slippage budget, bps5One allowance per leg for normal reductions; up to three for hedge completion and risk exits.
Order terminal-state wait, seconds8Unresolved outcomes remain pending after cancellation and further waiting.
Flatten on stopOnAttempts REST market closes without pending requests; off preserves positions.

These are the main settings; the parameter panel contains all 33. Quote age, timing differences, hedge tolerances, price jumps and contract-rule checks also constrain execution.

Operating Notes

  1. Share-count assumptions and contract relationships require ongoing verification. The strategy remains long xyz and short the CEX; it does not automatically reverse after a rule change.
  2. Margin is separate on each venue. Deleveraging depends on valid quotes, account estimates and available execution channels and cannot guarantee protection from liquidation.
  3. IOC orders may fail or partially fill. Sequential execution creates temporary exposure, and depth changes, rejections or hedge failures may produce losses.
  4. The cumulative loss limit uses completed-round net estimates. It is not an account-equity stop and does not include current floating losses.
  5. Data or account-stream problems suspend affected decisions. Unavailable channels can prevent reductions. Pending requests and persistent halt states require reconciliation.
  6. With flatten-on-stop enabled, normal shutdown attempts REST market closes. Pending requests preserve the request and ledger instead of triggering additional close orders. Check actual positions after crashes or exchange failures.
  7. Fees, funding and P&L include estimation assumptions. Displayed results are not final settled returns, and small-account results do not establish suitability for larger capital.
  8. Larger allocations require further work on market impact, order splitting, hedge mismatch and execution monitoring. AI can assist with these improvements, followed by testing against actual account conditions and capital size.
Source
JavaScript
/* ANT 价差收敛 · 双周期动态网格 V3.0.1(2026-11-06)
 * 大周期确定本轮底仓与资金预留;小周期确定区间、动态格距并逐份买卖。
 * 两腿全部归零且没有未决请求,本轮立即结束;重新规划新一轮,不继承旧锚点。
 * 多 Hyperliquid xyz:ANT,空 Binance/OKX ANTHROPIC;换算比例是研究假设。
 * WS 行情、账户及回报;Binance 统一保证金 REST 下单;结果不明保留未决。
 * 本地收益使用成交现金流、配置费率和资金费预算估算,非交易所最终结算。
 * 仅使用独立账户。XML 的实盘开关默认开启,参数说明见导入文件。
 */
var VERSION='3.1.0', STORE='ant_dual_cycle_v3';
var H=null,C=null,P=null,PRIV={},READY={},STREAMS={},BOOK={},CURRENT=null,S=null;
var BUSY=false,STARTED=false,FUND={},HIST=[],HIST_KEY='',HIST_MAX=10080;
var lastSample=0,lastStatus=0,lastRules=0,lastHist=0,lastCurve=0,PURPOSE='';
Strategy parameters
Strategy parameters
交易与换算
实盘下单
CEX换算阶段
CEX换算股数(亿)
资金规划目标杠杆
大周期与底仓
大周期观察窗口(小时)
最少有效历史(小时)
区间两端裁尾(%)
初始底仓资金预留(%)
每轮总份数上限
小周期与格距
小周期观察窗口(分钟)
减仓间距/小周期振幅
新增仓间距/小周期振幅
小周期不足时备用格距(bps)
WS价差采样间隔(秒)
每份最低净收益(bps)
规划确认/动作间隔(秒)
空仓后额外等待(秒)
风险控制
降杠杆触发线
规划资金费预留(天)
净资金费日预算(bps)
可选价差保护线(bps)
累计轮次亏损上限(U)
两腿最大股数误差(%)
最大股数误差金额(U)
持仓价格跳变拦截(bps)
停止时平仓
执行与费率
xyz吃单费率(bps)
CEX吃单费率(bps)
限价容差与滑点预算(bps)
订单终态等待(秒)
CEX盘口最大年龄(ms)
两腿盘口最大时间差(ms)
规则/资金费检查(秒)
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)