{"id":41464102,"url":"https://github.com/coinbase-samples/prime-fix-md-go","last_synced_at":"2026-01-23T16:17:58.894Z","repository":{"id":315466805,"uuid":"1050135860","full_name":"coinbase-samples/prime-fix-md-go","owner":"coinbase-samples","description":"A Go-based FIX protocol client for receiving real-time and snapshot market data from Coinbase Prime.","archived":false,"fork":false,"pushed_at":"2025-09-18T18:28:05.000Z","size":107,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-18T21:05:45.433Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coinbase-samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-04T02:12:32.000Z","updated_at":"2025-09-18T18:27:24.000Z","dependencies_parsed_at":"2025-09-18T21:22:59.987Z","dependency_job_id":null,"html_url":"https://github.com/coinbase-samples/prime-fix-md-go","commit_stats":null,"previous_names":["coinbase-samples/prime-fix-md-go"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/coinbase-samples/prime-fix-md-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase-samples%2Fprime-fix-md-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase-samples%2Fprime-fix-md-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase-samples%2Fprime-fix-md-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase-samples%2Fprime-fix-md-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase-samples","download_url":"https://codeload.github.com/coinbase-samples/prime-fix-md-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase-samples%2Fprime-fix-md-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28695529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T15:57:05.722Z","status":"ssl_error","status_checked_at":"2026-01-23T15:56:27.656Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T16:17:58.128Z","updated_at":"2026-01-23T16:17:58.849Z","avatar_url":"https://github.com/coinbase-samples.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prime FIX Market Data Client\n\nA Go-based FIX protocol client for receiving real-time and snapshot market data from Coinbase Prime.\n\n## Features\n\n- **Real-time Market Data**: Subscribe to live trades, order book updates, and OHLCV data\n- **Snapshot Data**: Get point-in-time snapshots of trades, order books, and OHLCV data  \n- **SQLite Storage**: All market data is stored in a local SQLite database for analysis\n- **CLI Interface**: Interactive command-line interface with tab completion\n- **Multiple Data Types**: Supports trades, bids/offers, and OHLCV (Open, High, Low, Close, Volume)\n\n## Prerequisites\n\n- Go 1.23.2 or higher\n- Coinbase Prime account with FIX API access\n- Valid API credentials (Access Key, Signing Key, Passphrase, Service Account ID, Portfolio ID)\n\n## Installation\n\n1. Clone the repository\n2. Install dependencies:\n   ```bash\n   go mod tidy\n   ```\n3. Build the application:\n   ```bash\n   go build -o fix-md-client ./cmd\n   ```\n\n## Configuration\n\nCreate a `fix.cfg` file in the project root with your FIX session configuration. Use `fix.cfg.example` as a template:\n\n```bash\ncp fix.cfg.example fix.cfg\n# Edit fix.cfg with your service account ID\n```\n\n### TLS Setup (Optional)\n\nCoinbase Prime FIX supports native TLS, so no stunnel or proxy is required.\n\nTo generate a local CA certificate bundle from your system trust store, run:\n\n```bash\nsecurity find-certificate -a -p /System/Library/Keychains/SystemRootCertificates.keychain \u003e ~/system-roots.pem\n```\n\nThen edit your `fix.cfg` file to replace `YOUR_SSL_CA_FILE_PATH` with the path to your CA file and `YOUR_SENDER_COMP_ID` with your actual service account ID:\n\n```ini\nSSLCAFile=/Users/yourname/system-roots.pem\nSenderCompID=YOUR_SVC_ACCOUNT_ID\n```\n\n## Environment Variables\n\nSet the following environment variables with your Coinbase Prime credentials:\n\n```bash\nexport PRIME_ACCESS_KEY=\"your-access-key\"\nexport PRIME_SIGNING_KEY=\"your-signing-key\" \nexport PRIME_PASSPHRASE=\"your-passphrase\"\nexport PRIME_SVC_ACCOUNT_ID=\"your-service-account-id\"\nexport PRIME_TARGET_COMP_ID=\"COIN\"\nexport PRIME_PORTFOLIO_ID=\"your-portfolio-id\"\n```\n\nAlternatively, copy `.env.example` to `.env` and fill in your credentials:\n\n```bash\ncp .env.example .env\n# Edit .env with your actual credentials\n```\n\n## Usage\n\nRun the application:\n```bash\n# Option 1: Run directly (no build needed)\ngo run cmd/main.go\n\n# Option 2: Run compiled binary\n./fix-md-client\n```\n\n### Available Commands\n\n#### Market Data Request\n```bash\nmd \u003csymbol1\u003e [symbol2 symbol3 ...] [flags...]\n```\n\n**Subscription Types:**\n- `--snapshot` - Get a one-time snapshot\n- `--subscribe` - Subscribe to real-time updates\n- `--unsubscribe` - Stop real-time updates\n\n**Depth Control (for order books):**\n- `--depth 0` - Full order book (all available price levels)\n- `--depth 1` - Top of book L1 (best bid + best offer only)  \n- `--depth N` - LN book (best N bids + best N offers, e.g., L5, L10, L25)\n                Automatically includes both bids and offers\n\n**Data Types:**\n- `--trades` - Trade executions\n- `--o` - Opening price\n- `--c` - Closing price\n- `--h` - High price\n- `--l` - Low price\n- `--v` - Trading volume\n\n#### Unsubscribe Commands\n```bash\nunsubscribe \u003csymbol|reqId\u003e\n```\n\n**Unsubscribe Options:**\n- `unsubscribe BTC-USD` - Cancel ALL active subscriptions for BTC-USD\n- `unsubscribe md_1234567890` - Cancel specific subscription by reqId  \n- `unsubscribe --reqid md_123` - Cancel specific subscription (explicit flag)\n\n**Auto-detection**: Inputs starting with \"md_\" are treated as reqIds, otherwise as symbols.\n\n#### Other Commands\n- `status` - Show active subscriptions with reqIds (live streams only)\n- `help` - Display help information\n- `version` - Show version\n- `exit` - Quit application\n\n### Example Commands\n\n```bash\n# Trade snapshot (100 most recent trades)\nmd BTC-USD --snapshot --trades\n\n# Full order book snapshot (all available levels)\nmd BTC-USD --snapshot --depth 0\n\n# First level order book snapshot (best bid + best offer)\nmd BTC-USD --snapshot --depth 1\n\n# First 10 levels order book snapshot (best 10 bids + 10 offers)\nmd BTC-USD --snapshot --depth 10\n\n# Subscribe to live trades\nmd BTC-USD --subscribe --trades\n\n# Subscribe to live Level 5 order book (5 bids + 5 offers)\nmd BTC-USD --subscribe --depth 5\n\n# OHLCV snapshot\nmd ETH-USD --snapshot --o --c --h --l --v\n\n# Subscribe to live candle updates (allow 30s for connection to establish)\nmd BTC-USD --subscribe --o --c --h --l --v\n\n# Multi-symbol examples\nmd BTC-USD ETH-USD --snapshot --trades            # Multiple symbol trade snapshot\nmd BTC-USD ETH-USD SOL-USD --snapshot --depth 1   # Top of book for 3 symbols\nmd BTC-USD ETH-USD --subscribe --trades           # Live trades for multiple symbols\n\n# Unsubscribe examples\nunsubscribe BTC-USD                    # Cancel ALL BTC-USD subscriptions\nunsubscribe md_1757035274634111000     # Cancel specific subscription by reqId\nunsubscribe --reqid md_123456789       # Cancel specific subscription (explicit)\nmd BTC-USD --unsubscribe               # Alternative: cancel ALL BTC-USD subscriptions\n\n# Check active subscriptions\nstatus\n```\n\n## Subscription Management\n\n### Multiple Subscriptions\nYou can have multiple active subscriptions per symbol. For example:\n```bash\nmd BTC-USD --subscribe --trades              # Live trades (reqId: md_123)\nmd BTC-USD --subscribe --depth 5             # Live L5 bids+offers (5 bids + 5 offers, reqId: md_456)\n```\n\n### Subscription Tracking\n- **Snapshots** (`--snapshot`) are not tracked (one-time requests)\n- **Subscriptions** (`--subscribe`) are tracked in the `status` display\n- Each subscription gets a unique `reqId` for precise control\n\n### Unsubscribe Behavior\n- **Symbol-based**: `unsubscribe BTC-USD` cancels ALL BTC-USD subscriptions\n- **ReqId-based**: `unsubscribe md_123` cancels only that specific subscription\n- **Auto-detection**: Inputs starting with \"md_\" are treated as reqIds\n\n### Status Display\n```bash\nFIX-MD\u003e status\nActive Subscriptions:\n┌─────────────┬──────────────────┬─────────────┬─────────────┬──────────────┬──────────────────┐\n│ Symbol      │ Type             │ Status      │ Updates     │ Last Update  │ ReqID            │\n├─────────────┼──────────────────┼─────────────┼─────────────┼──────────────┼──────────────────┤\n│ BTC-USD     │ Snapshot + Updates │ Active    │ 150         │ 14:23:45     │ ...4111000       │\n│             │ Snapshot + Updates │ Active    │ 89          │ 14:23:45     │ ...4222000       │\n│ ETH-USD     │ Snapshot + Updates │ Active    │ 45          │ 14:22:10     │ ...4333000       │\n└─────────────┴──────────────────┴─────────────┴─────────────┴──────────────┴──────────────────┘\n```\n\n## Data Capabilities\n\n### Depth Support\n- **Trades**: Always returns ~100 most recent (depth parameter ignored)\n- **Order Book (bids/offers)**: Supports L1, L5, L10, L25, etc.  \n- **OHLCV**: Always returns ~100 entries (depth parameter ignored)\n\n### Subscription Support\n- **Trades**: Supports real-time streaming\n- **Order Book (bids/offers)**: Supports real-time streaming\n- **OHLCV**: Supports real-time candle updates\n\n## Understanding Market Data\n\n### Order Book Depth Subscriptions\nWhen you subscribe to order book depth (e.g., `--depth 3`), you'll receive incremental updates as market conditions change:\n\n- **Depth 3** means \"up to 3 best price levels\" on each side\n- You may not always see exactly 3 bids and 3 offers due to:\n  - Price levels being removed when size reaches zero\n  - New price levels appearing within the top N levels\n  - Market gaps where fewer than N levels exist\n- Updates show real-time changes: new levels, size changes, level removals\n- Track position numbers to understand level ranking (1=best, 2=second best, etc.)\n\n### Snapshot vs Live Data\n- **Snapshots** (`--snapshot`) - One-time current state, not tracked\n- **Subscriptions** (`--subscribe`) - Continuous live updates, tracked in `status`\n\n## Data Storage\n\nMarket data is stored in `marketdata.db` (SQLite) with tables for:\n- **trades** - Trade executions with price, size, and timestamps\n- **order_book** - Bid/offer levels with position and depth\n- **ohlcv** - Open, high, low, close, and volume data\n- **sessions** - Request metadata and subscription tracking\n\n## Output Format\n\n### Snapshot Display\nSnapshots are displayed in formatted tables showing all received data.\n\n### Streaming Display  \nReal-time updates are shown as individual lines:\n\n```\nMarket Data Incremental for BTC-USD (ReqID: md_1234567890, Entries: 2, Seq: 42)\nBTC-USD Trade: 50000.00 | Size: 0.1 | Aggressor: Buy\nBTC-USD Trade: 50001.00 | Size: 0.05 | Aggressor: Sell\n────────────────────────────────────────────────\n\nBTC-USD Bid: 49995.00 | Size: 1.5 | Pos: 1\nBTC-USD Offer: 50005.00 | Size: 2.0 | Pos: 1\n────────────────────────────────────────────────\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase-samples%2Fprime-fix-md-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase-samples%2Fprime-fix-md-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase-samples%2Fprime-fix-md-go/lists"}