hyperliquid-position-csv
Zero-dependency Python (decimal.Decimal) & JavaScript (ESM) library + CLI to reconstruct flat-to-flat perpetual position cycles (0 → position → 0) from Hyperliquid's public userFills endpoint and export clean RFC-4180 CSV summaries.
- Live Web Tracker (English): Hyperliquid Whale Position & Trade History Tracker
- 在线巨鲸持仓与交易历史追踪器(中文): Hyperliquid 钱包追踪器
- Methodology & CSV Guide: Hyperliquid Wallet Trade History & Position Cycles
Python Installation & Quick Start
pip install hyperliquid-position-csv
hl-position-csv --address 0x... > positions.csv
from hyperliquid_position_csv import group_position_cycles, cycles_to_csv
cycles = group_position_cycles(raw_fills)
print(cycles_to_csv(cycles))
Why Reconstruct Position Cycles?
Hyperliquid's public POST https://api.hyperliquid.xyz/info ({"type": "userFills", "user": "0x..."}) returns up to 2,000 individual order execution fragments. A single position entered across 15 partial maker fills and closed across 12 taker fills appears as 27 separate rows, and a single flip order crossing zero splits across two logical trades.
hyperliquid-position-csv groups raw fills per market (preserving both native perpetuals like BTC and HIP-3 namespaced builder markets like xyz:NVDA) into clean position cycles:
- Exact
BigInt18-decimal fixed-point math — no IEEE-754 floating-point precision drift on sizes, fees, or realized PnL. - Honest window boundaries — if a wallet's 2,000-fill history starts mid-position (
startPosition != 0),completeis markedfalserather than fabricating an entry price. - Single-fill reversals handled — orders that cross through
0close the prior cycle cleanly and open a new opposite-side cycle.
Usage
1. CLI (Export any 0x wallet directly to CSV)
# Fetch live public fills for a Hyperliquid wallet and write CSV
node ./bin/cli.mjs 0x0000000000000000000000000000000000000000 --out positions.csv
# Or reconstruct offline from a saved userFills JSON array
node ./bin/cli.mjs --input ./sample-fills.json --out positions.csv
2. ESM Library
import { fetchHyperliquidUserFills, groupPositionCycles, cyclesToCsv } from './src/index.mjs';
const fills = await fetchHyperliquidUserFills('0x...');
const cycles = groupPositionCycles(fills);
console.log(cyclesToCsv(cycles));
Output CSV Columns
| Column | Description |
|---|---|
coin |
Perpetual symbol (e.g. BTC, ETH, or HIP-3 namespace:SYMBOL) |
side |
long or short |
status |
closed (returned to 0) or open |
opened_at / closed_at |
ISO-8601 timestamps (blank if outside the 2,000-fill window) |
opened_size / closed_size |
Total base quantity opened and closed within the cycle |
avg_entry_px / avg_exit_px |
Volume-weighted average entry and exit prices |
realized_pnl |
Sum of closedPnl across all executions in the cycle |
fees / fee_token |
Total execution fees and fee currency |
fills_count |
Number of partial fills aggregated into this cycle |
complete |
true only when both flat entry (0 → pos) and flat exit (pos → 0) are inside the loaded history |
Related Open Analytics & Documentation by HoldWins
- Hyperliquid Whale Radar (Live Leaderboard,Candlesticks B/S Markers & CSV Export) · 中文巨鲸雷达
- How to Track Hyperliquid Whale Positions · 巨鲸持仓查询指南
- Hyperliquid Liquidation Price & Mark Distance · 清算价与清算距离
- HIP-3 Tokenized Stock Perps vs bStocks · 美股代币与链上永续合约区别
- Perpetual Futures Open Interest & Funding Monitor · 合约异动监测
License
MIT © HoldWins
Go Module Installation (pkg.go.dev)
go get github.com/dalangdalang934/hyperliquid-position-csv@latest
import "hlcycles" // github.com/dalangdalang934/hyperliquid-position-csv
cycles, _ := hlcycles.GroupPositionCycles(fills)
csvOut, _ := hlcycles.FormatCyclesCSV(cycles)
- Go Module (
pkg.go.dev): https://pkg.go.dev/github.com/dalangdalang934/hyperliquid-position-csv - Position Cycle Methodology: Hyperliquid Wallet Trade History Guide (EN) · 中文版持仓周期说明
Metadata
Release files for hyperliquid-position-csv 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hyperliquid_position_csv-1.1.0.tar.gz | 6.8 kB | Without provenance | Details for hyperliquid_position_csv-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hyperliquid_position_csv-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for hyperliquid_position_csv-1.1.0-py3-none-any.whl |
Total release size: 15.4 kB
Release files / hyperliquid_position_csv-1.1.0.tar.gz
| Download URL | hyperliquid_position_csv-1.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f668a6e33171f79ca0f5f387b397806dedee7c8dd72a9c13f809ec39f209f2c2
|
|
BLAKE2b-256 checksum How to use checksums |
8518d3adc05067359517f1cd9fff7a67dafceeb152accf5389f5a12c2c9e5560
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / hyperliquid_position_csv-1.1.0-py3-none-any.whl
| Download URL | hyperliquid_position_csv-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ccbd03b78f32e0dbf95175a0d193a9b7e7c73da8330cd798afbcacc7f1f66d92
|
|
BLAKE2b-256 checksum How to use checksums |
d4f50c898e047800ea201ce361169a4194e7fb1004e827438bff97b0d8077235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.0 {"installer":{"name":"uv","version":"0.11.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for hyperliquid-position-csv 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.