Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,11 @@ aperiodic basis \

## Supported Exchanges

| Exchange | ID |
|-----------------|-------------------|
| Binance Futures | `binance-futures` |
| OKX Perpetuals | `okx-perps` |
| Exchange | ID |
|-----------------------|----------------------|
| Binance Futures | `binance-futures` |
| OKX Perpetuals | `okx-perps` |
| Hyperliquid Perpetuals | `hyperliquid-perps` |

## Intervals

Expand Down
29 changes: 29 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ func TestCLI_Symbols_InvalidAPIKey(t *testing.T) {
}
}

func TestCLI_Symbols_HyperliquidPerps_InvalidAPIKey(t *testing.T) {
t.Setenv("APERIODIC_API_URL", DefaultBaseURL)
t.Setenv("APERIODIC_API_KEY", "invalid-key")

_, stderr, code := runCLI("symbols", "-exchange", "hyperliquid-perps")
if code != 1 {
t.Fatalf("expected exit code 1 for invalid API key, got %d; stderr: %s", code, stderr)
}
}

func TestCLI_OHLCV_InvalidAPIKey(t *testing.T) {
t.Setenv("APERIODIC_API_URL", DefaultBaseURL)
t.Setenv("APERIODIC_API_KEY", "invalid-key")
Expand All @@ -159,6 +169,25 @@ func TestCLI_OHLCV_InvalidAPIKey(t *testing.T) {
}
}

func TestCLI_OHLCV_HyperliquidPerps_InvalidAPIKey(t *testing.T) {
t.Setenv("APERIODIC_API_URL", DefaultBaseURL)
t.Setenv("APERIODIC_API_KEY", "invalid-key")

outputDir := t.TempDir()
_, stderr, code := runCLI(
"ohlcv",
"-exchange", "hyperliquid-perps",
"-symbol", "perpetual-BTC-USDC:USDC",
"-interval", "1d",
"-start-date", "2025-03-01",
"-end-date", "2025-04-01",
"-output-dir", outputDir,
)
if code != 1 {
t.Fatalf("expected exit code 1 for invalid API key, got %d; stderr: %s", code, stderr)
}
}

func TestCLI_OHLCV_MissingFlags(t *testing.T) {
t.Setenv("APERIODIC_API_KEY", "fake")

Expand Down
56 changes: 56 additions & 0 deletions processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,62 @@ import (
"testing"
)

func TestCLI_Symbols_HyperliquidPerps(t *testing.T) {
requireAPIKey(t)

stdout, stderr, code := runCLI("symbols", "-exchange", "hyperliquid-perps")
if code != 0 {
t.Fatalf("expected exit code 0, got %d; stderr: %s", code, stderr)
}

lines := strings.Split(strings.TrimSpace(stdout), "\n")
if len(lines) == 0 {
t.Fatal("expected at least one symbol in output")
}
}

func TestCLI_OHLCV_HyperliquidPerps_Download(t *testing.T) {
requireAPIKey(t)

outputDir := t.TempDir()

stdout, stderr, code := runCLI(
"ohlcv",
"-exchange", "hyperliquid-perps",
"-symbol", "perpetual-BTC-USDC:USDC",
"-interval", "1d",
"-start-date", "2025-03-01",
"-end-date", "2025-04-01",
"-output-dir", outputDir,
)
if code != 0 {
t.Fatalf("expected exit code 0, got %d; stderr: %s", code, stderr)
}

if !strings.Contains(stdout, "Successfully downloaded") {
t.Errorf("expected success message, got: %s", stdout)
}

files, err := filepath.Glob(filepath.Join(outputDir, "*.parquet"))
if err != nil {
t.Fatalf("failed to glob output dir: %v", err)
}
if len(files) == 0 {
t.Fatal("expected at least one parquet file in output dir")
}

for _, f := range files {
info, err := os.Stat(f)
if err != nil {
t.Errorf("failed to stat %s: %v", f, err)
continue
}
if info.Size() == 0 {
t.Errorf("expected non-empty file %s", f)
}
}
}

func TestCLI_VTWAP_InvalidAPIKey(t *testing.T) {
t.Setenv("APERIODIC_API_URL", DefaultBaseURL)
t.Setenv("APERIODIC_API_KEY", "invalid-key")
Expand Down
5 changes: 3 additions & 2 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ const (
type Exchange string

const (
ExchangeBinanceFutures Exchange = "binance-futures"
ExchangeOkxPerps Exchange = "okx-perps"
ExchangeBinanceFutures Exchange = "binance-futures"
ExchangeOkxPerps Exchange = "okx-perps"
ExchangeHyperliquidPerps Exchange = "hyperliquid-perps"
)

type TradeMetric string
Expand Down