
royrzguo/hype-funding-carry
Developer tools이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기
Rust reference implementation of a delta-neutral HYPE funding carry strategy on Hyperliquid Portfolio Margin
개요
A Rust reference implementation of a HYPE funding carry strategy on Hyperliquid, using delta-neutral spot and perpetual positions with Portfolio Margin. Adapted from live trading code, it covers entry and exit, position management, risk controls, recovery, and accounting. Strategy parameters and execution conditions can be adjusted for account size and capital allocation. A single process uses WebSocket for live market data, entry and hedging, and REST for account checks and recovery. Execution state and audit logs are stored locally. Source code is in crates/hype-funding-carry/src/: controller.rs, controller_runtime.rs, and controller_service.rs coordinate these modules. Recovery and risk controls take priority over increasing positions. Spot maker fills are hedged with perpetuals based on the actual net filled quantity. Resting orders are managed by basis, order-book, and timeout conditions. Funding, borrowing interest, and fees are included in monitoring and accounting.
README
원문 README의 일부입니다. 원문 보기.
HYPE Funding Carry on Hyperliquid
A Rust reference implementation of a HYPE funding carry strategy on Hyperliquid, using delta-neutral spot and perpetual positions with Portfolio Margin. Adapted from live trading code, it covers entry and exit, position management, risk controls, recovery, and accounting. Strategy parameters and execution conditions can be adjusted for account size and capital allocation.
Architecture
A single process uses WebSocket for live market data, entry and hedging, and REST for account checks and recovery. Execution state and audit logs are stored locally.
Source code is in crates/hype-funding-carry/src/:
| Module | Main files | Responsibility |
|---|---|---|
| Market and account data | api.rs, ws.rs |
Order books, account state, PM, borrowing, open orders, and fills |
| Entry conditions | entry_policy.rs, model.rs |
Basis thresholds, depth, and next-period funding adjustments |
| Position management | portfolio.rs, deployment_phase.rs |
Paired positions, target allocation, and incremental adjustments |
| Risk controls | risk.rs, risk_phase.rs, asset_domain.rs |
PM risk, deleveraging, residual exposure, and asset-domain checks |
| Execution | order_policy.rs, live/ |
Maker orders, partial-fill hedging, IOC orders, cancellation, and exit |
| Recovery | attempt_state.rs, writer_lock.rs, state_io.rs |
Execution checkpoints, restart recovery, and writer locks |
| Accounting | accounting.rs, audit.rs, fill_notify.rs |
Account ledger, inventory, fees, and PnL |
controller.rs, controller_runtime.rs, and controller_service.rs coordinate these modules.
Recovery and risk controls take priority over increasing positions. Spot maker fills are
hedged with perpetuals based on the actual net filled quantity. Resting orders are managed
by basis, order-book, and timeout conditions. Funding, borrowing interest, and fees are
included in monitoring and accounting.
Build and configuration
Requires Rust 1.91+. Linux also requires pkg-config and OpenSSL development packages
(pkg-config libssl-dev on Debian/Ubuntu). Dependencies are pinned by Cargo.lock
and a fixed SDK commit.
cargo build --release --locked
cp .env.example .env
Set the account address, API agent address, HFC_PRIVATE_KEY_FILE, and HFC_STATE_DIR
in .env. The signing key is read from a local file; on Unix, group and other permissions
must be disabled. The account must have Portfolio Margin enabled and authorize the API agent.
Strategy parameters are in config/strategy.example.json:
target_deployment_ratio,deployment_band: paired position notional divided by net equity, and the adjustment band.entry_create_bps,entry_keep_bps: thresholds for placing and retaining entry orders.entry_policy: adjustment of basis thresholds for negative next-period funding.risk: PMR thresholds and deleveraging targets.
추천 도구
다른 키워드를 입력하거나 필터를 제거해 보세요.
설치
npx skillfish add royrzguo/hype-funding-carry