{"id":50141977,"url":"https://github.com/antonygiomarxdev/greedy","last_synced_at":"2026-05-24T02:00:49.621Z","repository":{"id":359459365,"uuid":"1246127982","full_name":"antonygiomarxdev/greedy","owner":"antonygiomarxdev","description":null,"archived":false,"fork":false,"pushed_at":"2026-05-22T05:00:21.000Z","size":128,"stargazers_count":1,"open_issues_count":14,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-22T09:44:02.900Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonygiomarxdev.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":"2026-05-21T22:43:30.000Z","updated_at":"2026-05-22T05:00:24.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/antonygiomarxdev/greedy","commit_stats":null,"previous_names":["antonygiomarxdev/greedy"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/antonygiomarxdev/greedy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonygiomarxdev%2Fgreedy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonygiomarxdev%2Fgreedy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonygiomarxdev%2Fgreedy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonygiomarxdev%2Fgreedy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonygiomarxdev","download_url":"https://codeload.github.com/antonygiomarxdev/greedy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonygiomarxdev%2Fgreedy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33418550,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T22:14:44.296Z","status":"online","status_checked_at":"2026-05-24T02:00:06.296Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-05-24T02:00:48.867Z","updated_at":"2026-05-24T02:00:49.615Z","avatar_url":"https://github.com/antonygiomarxdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Greedy\n\n[![CI](https://github.com/antonygiomarxdev/greedy/actions/workflows/ci.yml/badge.svg)](https://github.com/antonygiomarxdev/greedy/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/antonygiomarxdev/greedy/branch/main/graph/badge.svg)](https://codecov.io/gh/antonygiomarxdev/greedy)\n[![Go Report Card](https://goreportcard.com/badge/github.com/antonygiomarxdev/greedy)](https://goreportcard.com/report/github.com/antonygiomarxdev/greedy)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/antonygiomarxdev/greedy)](https://golang.org/dl/)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Downloads](https://img.shields.io/github/downloads/antonygiomarxdev/greedy/total)](https://github.com/antonygiomarxdev/greedy/releases)\n\n**Sovereign, local-first algorithmic trading engine. Single static binary. AI-native via MCP.**\n\n## Features\n\n- **AI-Native MCP Server**: 14 tools, 4 resources, 3 prompts. Claude Desktop, Cursor, or any MCP client can monitor and control your strategies.\n- **Multi-Strategy**: DCA, GRID, Signal — run dozens concurrently with per-bot isolation.\n- **Real Exchange Support**: Coinbase, Binance — same interface, zero code changes.\n- **Local-First**: 100% local execution. No cloud, no telemetry, no third-party servers.\n- **Encrypted at Rest**: API keys encrypted with NaCl secretbox + Argon2id. Keys never leave your machine.\n- **Enterprise Crypto**: Argon2id key derivation, NaCl secretbox encryption, constant-time comparisons.\n- **Order Persistence**: All orders automatically stored in SQLite WAL — queryable via MCP or CLI.\n- **Backtesting**: CSV-driven backtester with Sharpe ratio, max drawdown, win rate.\n- **Ultra-Low Latency**: Go-native goroutines per bot. Tick-to-decision in microseconds.\n- **Failsafe**: Per-bot isolation. Crash in one strategy never touches others. Circuit breakers prevent runaway trading.\n- **Single Binary**: ~15 MB statically linked, zero runtime dependencies.\n- **Idempotent Order Placement**: Prevents duplicate orders across restarts.\n\n## Supported Platforms\n\n| OS | Arch | Status |\n|---|---|---|\n| Linux | amd64 | ✅ Production |\n| Linux | arm64 | ✅ Production |\n| macOS | amd64 | ✅ Production |\n| macOS | arm64 | ✅ Production |\n| Windows | amd64 | ✅ Production |\n\n**Requirements**: Go 1.23+ (to build from source), or download the prebuilt binary for your platform.\n\n## Quick Start\n\n### Install\n\n**Binary download** (recommended):\n```bash\n# Linux amd64\ncurl -fsSL https://github.com/antonygiomarxdev/greedy/releases/latest/download/greedy-linux-amd64.tar.gz | tar xz\nsudo install greedy-linux-amd64 /usr/local/bin/greedy\n\n# macOS arm64 (Apple Silicon)\ncurl -fsSL https://github.com/antonygiomarxdev/greedy/releases/latest/download/greedy-darwin-arm64.tar.gz | tar xz\nsudo install greedy-darwin-arm64 /usr/local/bin/greedy\n```\n\n**One-liner** (auto-detect OS/arch):\n```bash\ncurl -fsSL https://github.com/antonygiomarxdev/greedy/releases/latest/download/greedy-linux-amd64.tar.gz \\\n  | tar xz \u0026\u0026 sudo install greedy-linux-amd64 /usr/local/bin/greedy\n```\n\n**Or via make**:\n```bash\nsudo make install\n```\n\n**Build from source**:\n```bash\ngit clone https://github.com/antonygiomarxdev/greedy.git\ncd greedy\nmake build\n```\n\n### Run a Strategy\n\n```bash\ngreedy run --strategy examples/dca_btc.yaml\n# Press Ctrl+C to stop gracefully\n```\n\n## MCP Protocol Reference\n\n### Tools (14)\n\n| Tool | Exchange param | Input | Description |\n|---|---|---|---|\n| `get_ticker` | ✅ | `symbol`, `exchange?` | Current price for a symbol |\n| `get_order_book` | ✅ | `symbol`, `depth?`, `exchange?` | Bids + asks order book |\n| `get_candles` | ✅ | `symbol`, `interval?`, `limit?`, `exchange?` | OHLCV history |\n| `place_order` | ✅ | `symbol`, `side`, `type`, `quantity`, `price?`, `exchange?` | Place market or limit order |\n| `cancel_order` | ✅ | `order_id`, `exchange?` | Cancel by order ID |\n| `get_positions` | ✅ | `exchange?` | All positions + P\u0026L |\n| `get_balances` | ✅ | `exchange?` | Account balances |\n| `get_order_history` | ❌ | `bot_id?`, `symbol?`, `limit?` | Historical orders |\n| `start_bot` | ❌ | `strategy_file?` or `type` + `symbol` + `params` | Launch a bot |\n| `stop_bot` | ❌ | `bot_id` | Stop a running bot |\n| `list_bots` | ❌ | (none) | Active bots + P\u0026L |\n| `set_credential` | ❌ | `exchange`, `label`, `api_key`, `api_secret`, `passphrase?` | Store encrypted API keys |\n| `list_credentials` | ❌ | (none) | List stored credential identifiers |\n| `delete_credential` | ❌ | `exchange`, `label` | Remove stored credential |\n\nDefault exchange is `paper` when `exchange` is omitted.\n\n### Resources (4)\n\n| URI | Description |\n|---|---|\n| `portfolio://summary` | Full portfolio snapshot: balances, positions, total P\u0026L |\n| `bot://{id}/status` | Bot status, strategy config, P\u0026L, open orders |\n| `bot://{id}/history` | Complete order history for a bot |\n| `market://prices/{symbol}` | Real-time price for any symbol |\n\n### Prompts (3)\n\n| Name | Description |\n|---|---|\n| `analyze_portfolio` | Portfolio risk and exposure analysis |\n| `review_trades` | Today's trading activity with P\u0026L breakdown |\n| `suggest_strategy` | Suggest DCA/GRID params based on market conditions |\n\n### E2E Walkthrough\n\n```\nAgent → greedy:  tools/list                          → 14 tools with schemas\nAgent → greedy:  tools/call get_ticker BTC-USD       → price: 50000\nAgent → greedy:  tools/call get_balances             → USD: 100,000\nAgent → greedy:  tools/call place_order buy 0.01 BTC → filled at 50049.99\nAgent → greedy:  tools/call get_positions            → 0.01 BTC @ 50100 avg\nAgent → greedy:  tools/call get_order_history        → 3 orders found\nAgent → greedy:  tools/call start_bot                → started: bot dca-btc-01\nAgent → greedy:  tools/call list_bots                → 1 bot running (DCA)\nAgent → greedy:  tools/call start_bot grid_eth       → started: bot grid-eth-01\nAgent → greedy:  tools/call start_bot signal_btc     → started: bot signal-btc-01\nAgent → greedy:  tools/call list_bots                → 3 bots running (+P\u0026L)\nAgent → greedy:  tools/call stop_bot \u003cid\u003e            → stopped: bot removed\nAgent → greedy:  tools/call list_bots                → 0 bots\n```\n\n### Real Exchange Support\n\nGreedy connects to Coinbase and Binance via encrypted credentials. Start the daemon:\n\n```bash\nexport GREEDY_MASTER_PASSWORD=\"your-strong-password\"\ngreedy serve --config examples/greedy_with_exchanges.yaml\n```\n\n`GREEDY_MASTER_PASSWORD` is required for credential encryption using Argon2id + NaCl secretbox. Without it, only paper trading is available.\n\nSet API keys via MCP:\n\n```json\n{\"exchange\": \"coinbase\", \"label\": \"default\", \"api_key\": \"...\", \"api_secret\": \"...\", \"passphrase\": \"...\"}\n```\n\nOr configure exchanges in YAML (credentials must exist in the store):\n\n```yaml\nexchanges:\n  - name: \"Binance Spot\"\n    provider: binance\n    label: default\n  - name: \"Coinbase\"\n    provider: coinbase\n    label: default\n```\n\n**Symbol format**: Binance uses `BTCUSDT` (no dash), Coinbase uses `BTC-USD`. Pass the format your exchange expects.\n\n### Claude Desktop Setup\n\n1. Build or download the binary\n2. Copy config: `cp examples/claude_desktop_config.json ~/.config/Claude/claude_desktop_config.json`\n3. Update the binary path and `GREEDY_HOME` in the config\n4. If using real exchanges, add `GREEDY_MASTER_PASSWORD` to the env\n5. Restart Claude Desktop\n\nClaude can now say: *\"Start a DCA bot buying $100 of BTC on Binance every hour\"* and Greedy executes it.\n\n## Production\n\n### Systemd Service (Linux)\n\n```bash\nsudo make install-service          # build + install unit\nsudo systemctl enable greedy       # auto-start on boot\nsudo systemctl start greedy        # start now\nsudo systemctl status greedy       # verify\n```\n\nLogs: `journalctl -u greedy -f`\n\nManual config path: `/etc/systemd/system/greedy.service` (see `build/greedy.service`).\n\n### CLI Credential Management\n\nSet API keys from a headless terminal (no MCP server needed):\n\n```bash\nexport GREEDY_MASTER_PASSWORD=\"your-strong-password\"\n\n# Direct flags\ngreedy credential set --exchange binance --label default --api-key XXX --api-secret YYY\n\n# Via env vars (safer — keys don't appear in process list)\ngreedy credential set --exchange coinbase --label default \\\n  --api-key-env COINBASE_API_KEY --api-secret-env COINBASE_API_SECRET\n\ngreedy credential list\ngreedy credential get --exchange binance --label default\ngreedy credential delete --exchange binance --label default\n```\n\nAll commands use the same encrypted SQLite store as the MCP server. `GREEDY_MASTER_PASSWORD` must match the one used at server startup.\n\n## Security Architecture\n\n### Credential Encryption\n\n```\nGREEDY_MASTER_PASSWORD\n  → Argon2id (mem=64MB, iter=3, threads=4, salt=nil)\n    → 32-byte key\n      → NaCl secretbox (XSalsa20-Poly1305)\n        → Encrypted blob in SQLite\n```\n\n- Keys are **never** logged or exposed via MCP `list_credentials`.\n- Store uses SQLite WAL mode — safe concurrent access.\n- Salt persistence for key derivation is planned (currently uses nil salt — upgrading requires re-encryption).\n\n### Exchange Isolation\n\n- Per-bot goroutines with independent context cancellation.\n- Circuit breaker stops all bot activity during extreme volatility.\n- Idempotency keys prevent duplicate orders after restart.\n- Debouncer rate-limits order placement per bot.\n\n## Strategy Configuration\n\n**Symbol format**: `BTC-USD` for paper/Coinbase, `BTCUSDT` for Binance.\n\n### DCA (Dollar-Cost Averaging)\n\n```yaml\nid: dca-btc-01\nname: \"BTC DCA Bot\"\nexchange: paper\nstrategy:\n  type: dca\n  symbol: BTC-USD\n  params:\n    base_order_size: 100\n    frequency: \"1h\"\n    max_safety_orders: 10\n    safety_orders:\n      - price_deviation_pct: -5\n        volume_scale: 1.5\n      - price_deviation_pct: -10\n        volume_scale: 2.0\n```\n\nBinance version:\n```yaml\nid: dca-btc-binance\nname: \"BTC DCA Bot\"\nexchange: binance\nstrategy:\n  type: dca\n  symbol: BTCUSDT\n  params:\n    base_order_size: 100\n    frequency: \"1h\"\n```\n\n### GRID (Limit Order Grid)\n\n```yaml\nid: grid-eth-01\nname: \"ETH GRID Bot\"\nstrategy:\n  type: grid\n  symbol: ETH-USD\n  params:\n    lower_bound: 2000\n    upper_bound: 4000\n    grid_levels: 10\n    order_size: 0.5\n```\n\n### Signal (Trigger-Based)\n\n```yaml\nid: signal-btc-01\nname: \"BTC Signal Bot\"\nstrategy:\n  type: signal\n  symbol: BTC-USD\n  params:\n    position_size: 1000\n    entry_condition: \"ema_cross_above\"\n    exit_condition: \"ema_cross_below\"\n```\n\n## Backtesting\n\n```bash\n./build/greedy backtest \\\n  --strategy examples/dca_backtest.yaml \\\n  --data examples/btc_sample.csv \\\n  --report json\n```\n\nReports include: total return, max drawdown, Sharpe ratio, win rate, profit factor.\n\n## Architecture\n\nGreedy follows **Clean Architecture** with **Vertical Slicing**. Every feature is a complete vertical through all layers: domain → infrastructure → use cases → delivery.\n\n```\ncmd/greedy/                     # Composition root (DI wiring only)\ninternal/\n  domain/                       # Enterprise business rules\n    exchange/                   # Exchange interface + types\n    bot/                        # Bot + Supervisor interfaces\n    strategy/                   # Strategy interface + config types\n    stream/                     # PriceStreamer, MarketTracker, RateLimiter...\n  usecases/                     # Application business rules\n    start_bot.go                # StartBotUseCase\n    place_order.go              # PlaceOrderUseCase (idempotent)\n    get_portfolio.go            # GetPortfolioUseCase\n  infrastructure/               # Concrete implementations\n    exchange/paper/             # Paper trading (10 tests)\n    db/                         # SQLite WAL + migrations + repos (11 tests)\n    config/                     # YAML loading + validation (18 tests)\n    stream/                     # RateLimiter, PriceStreamer, MarketTracker impls\n  delivery/                     # Input adapters\n    mcp/                        # JSON-RPC 2.0 stdio server (9 tests)\n    cli/                        # CLI subcommand handlers\n├── docs/\n│   └── architecture.md         # Full architecture reference\n├── examples/                   # Strategy YAML + Claude config + sample data\n├── .github/workflows/ci.yml    # 4 CI jobs (lint, test, security, build)\n└── .golangci.yml               # Strict linting config\n```\n\n**Key rules:**\n- `domain/` imports nothing from other layers\n- `usecases/` depends only on `domain/` interfaces\n- `infrastructure/` implements `domain/` interfaces\n- `delivery/` delegates to use cases\n- `cmd/greedy/main.go` is pure DI wiring — zero business logic\n\nRead the full architecture reference: **[docs/architecture.md](docs/architecture.md)**\n\n## Roadmap\n\nTracked on [GitHub Issues](https://github.com/antonygiomarxdev/greedy/issues).\n\n- [x] **Phase 1**: Core engine, paper trading, DCA, SQLite, CLI\n- [x] **Phase 2**: MCP server — 10 tools, 3 resources, 3 prompts\n- [x] **Phase 3**: GRID + Signal strategies, multi-bot concurrency\n- [x] **Phase 4**: Backtesting engine with CSV data\n- [x] **Phase 5**: Real exchange connectors + MCP credentials — 14 tools, inline bot params, exchange targeting, order persistence\n- [ ] **Phase 6**: Market making, trailing stops, performance dashboards\n\n**15 test suites, 4 CI jobs (lint, test, security, build), zero external runtime dependencies.**\n\n## Requirements\n\n- Go 1.23+ (to build from source)\n- Prebuilt binaries available for Linux (amd64/arm64), macOS (amd64/arm64), Windows (amd64)\n- Single static binary. No Docker, no runtime dependencies.\n\n## Environment Variables\n\n| Variable | Required | Description |\n|---|---|---|\n| `GREEDY_MASTER_PASSWORD` | For real exchanges | Master key for credential encryption/decryption |\n| `GREEDY_HOME` | No | Data directory (default: `~/.greedy`) |\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feat/my-feature`\n3. Run tests: `make test`\n4. Ensure lint passes: `gofmt -l .` and `go vet ./...`\n5. Open a Pull Request\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonygiomarxdev%2Fgreedy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonygiomarxdev%2Fgreedy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonygiomarxdev%2Fgreedy/lists"}