{"id":37136684,"url":"https://github.com/quick-trade/xoney","last_synced_at":"2026-01-14T15:55:53.995Z","repository":{"id":244620584,"uuid":"708187113","full_name":"quick-trade/xoney","owner":"quick-trade","description":"Algorithmic trading in Go","archived":false,"fork":false,"pushed_at":"2024-11-28T01:17:20.000Z","size":783,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-11-28T02:22:12.876Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quick-trade.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2023-10-21T19:32:04.000Z","updated_at":"2024-11-28T01:17:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd3d7751-3d6e-44ee-bd6b-374096b114a0","html_url":"https://github.com/quick-trade/xoney","commit_stats":null,"previous_names":["quick-trade/xoney"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/quick-trade/xoney","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-trade%2Fxoney","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-trade%2Fxoney/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-trade%2Fxoney/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-trade%2Fxoney/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quick-trade","download_url":"https://codeload.github.com/quick-trade/xoney/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-trade%2Fxoney/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28425574,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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-14T15:55:53.254Z","updated_at":"2026-01-14T15:55:53.988Z","avatar_url":"https://github.com/quick-trade.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"assets/logo.png\" width=\"340\" height=\"340\"\u003e\n\n# Xoney\n\u003c/div\u003e\n\nA simple, fast, and powerful library for algorithmic trading in Go, **with no dependencies**.\n\n## Table of Contents\n- [Features](#features)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Strategies](#strategies)\n  - [Bollinger Bands Strategy](#bollinger-bands-strategy)\n  - [Grid Trading Bot](#grid-trading-bot)\n  - [Custom Strategy](#custom-strategy)\n- [Backtesting](#backtesting)\n- [Portfolio Management](#portfolio-management)\n- [Exchange Simulation](#exchange-simulation)\n\n## Features\n- Zero external dependencies\n- Event-driven architecture\n- Built-in strategy implementations\n- Backtesting engine with market and limit orders support\n- Portfolio management tools\n- Exchange simulation for testing\n- Support for both spot and margin trading\n- Customizable commission rates\n- Performance metrics calculation (Sharpe ratio, CARA utility)\n\n## Installation\n\n```bash\ngo get github.com/quick-trade/xoney\n```\n\n## Quick Start\n\n```go\npackage main\n\nimport (\n    \"github.com/quick-trade/xoney/backtest\"\n    \"github.com/quick-trade/xoney/common\"\n    \"github.com/quick-trade/xoney/exchange\"\n)\n\nfunc main() {\n    // Create a portfolio with initial USD balance\n    currency := data.NewCurrency(\"USD\", \"BINANCE\")\n    portfolio := common.NewPortfolio(currency)\n    portfolio.Set(currency, 10000)\n\n    // Initialize exchange simulator with 0.1% commission\n    simulator := exchange.NewMarginSimulator(portfolio, 0.001)\n    \n    // Create backtester\n    tester := backtest.NewBacktester(\u0026simulator)\n    \n    // Run your strategy\n    equity, err := tester.Backtest(charts, strategy)\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n## Strategies\n\n### Bollinger Bands Strategy\n\nThe Bollinger Bands strategy is a popular technical analysis tool that uses standard deviations to determine overbought or oversold conditions.\n\n```go\npackage main\n\nimport (\n    \"github.com/quick-trade/xoney/strategy\"\n    \"github.com/quick-trade/xoney/common/data\"\n)\n\nfunc main() {\n    // Create BTC/USD instrument with 15-minute timeframe\n    btcUsd := data.NewSymbol(\"BTC\", \"USD\", \"BINANCE\")\n    timeframe, _ := data.NewTimeFrame(time.Minute*15, \"15m\")\n    instrument := data.NewInstrument(*btcUsd, *timeframe)\n    \n    // Initialize Bollinger Bands strategy\n    // Parameters: period=30 days, deviation=2\n    strategy := NewBBStrategy(60*24*30, 2, instrument)\n    \n    // Run backtest\n    equity, err := tester.Backtest(charts, \u0026strategy)\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n### Grid Trading Bot\n\nGrid trading is a strategy that places multiple orders at regular intervals above and below a set price, aiming to profit from market oscillations.\n\n```go\npackage main\n\nimport (\n    \"github.com/quick-trade/xoney/toolkit\"\n    \"github.com/quick-trade/xoney/common/data\"\n)\n\nfunc main() {\n    // Create auto grid generator\n    // Parameters: lookback=100 candles, levels=10, deviation=1.5, total_amount=0.5 (in base currency)\n    generator := NewAutoGrid(100, 10, 1.5, 0.5)\n    \n    // Initialize grid bot\n    bot := toolkit.NewGridBot(generator, instrument)\n    \n    // Run backtest\n    equity, err := tester.Backtest(charts, bot)\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n### Custom Strategy\n\nYou can create your own strategy by implementing the `Tradable` interface:\n\n```go\ntype Tradable interface {\n    Start(charts data.ChartContainer) error\n    Next(candle data.InstrumentCandle) (events.Event, error)\n    MinDurations() Durations\n}\n```\n\nExample of a simple moving average crossover strategy:\n\n```go\ntype MACrossStrategy struct {\n    instrument data.Instrument\n    shortPeriod int\n    longPeriod int\n    shortMA []float64\n    longMA []float64\n}\n\nfunc (m *MACrossStrategy) Next(candle data.InstrumentCandle) (events.Event, error) {\n    // Strategy logic here\n    return event, nil\n}\n```\n\n## Backtesting\n\nXoney provides a powerful backtesting engine that supports:\n- Market and limit orders\n- Custom commission rates\n- Portfolio tracking\n- Performance metrics\n\n```go\nfunc runBacktest() {\n    // Initialize simulator with 0.1% commission\n    simulator := exchange.NewMarginSimulator(portfolio, 0.001)\n    tester := backtest.NewBacktester(\u0026simulator)\n    \n    // Run backtest\n    equity, err := tester.Backtest(charts, strategy)\n    if err != nil {\n        panic(err)\n    }\n    \n    // Access performance metrics\n    history := equity.Deposit()\n    balanceHistory := equity.PortfolioHistory()\n}\n```\n\n## Portfolio Management\n\nXoney includes tools for portfolio management and rebalancing. All weights and orders are specified in base currency:\n\n```go\n// Create a rebalancing strategy with weights in base currency\nweights := map[data.Currency]float64{\n    btc:  0.4,  // 0.4 BTC\n    eth:  0.3,  // 0.3 ETH\n    usdt: 0.3,  // 0.3 USDT\n}\n\nrebalancer := toolkit.NewRebalancePortfolio(weights)\n```\n\n## Exchange Simulation\n\nTest your strategies with the built-in exchange simulator:\n\n```go\n// Create simulator with 0.1% commission\nsimulator := exchange.NewMarginSimulator(portfolio, 0.001)\n\n// Place market order\norder, _ := exchange.NewOrder(\n    symbol,\n    exchange.Market,\n    exchange.Buy,\n    price,\n    amount,\n)\nerr := simulator.PlaceOrder(order)\n```\n\nThe simulator supports:\n- Market and limit orders\n- Spot and margin trading\n- Custom commission rates\n- Portfolio tracking\n- Price feeds\n\nFor more examples and detailed documentation, visit our [documentation](https://github.com/quick-trade/xoney/docs).\n\n## Toolkit\n\n**Warning**: The toolkit package is currently in experimental stage and should be used with extreme caution. The functionality may be unstable and contain bugs.\n\n### Grid Trading Bot\n\nGrid trading is a strategy that places multiple orders at regular intervals above and below a set price, aiming to profit from market oscillations.\n\n```go\npackage main\n\nimport (\n    \"github.com/quick-trade/xoney/toolkit\"\n    \"github.com/quick-trade/xoney/common/data\"\n)\n\nfunc main() {\n    // Create auto grid generator\n    // Parameters: lookback=100 candles, levels=10, deviation=1.5, total_amount=0.5 (in base currency)\n    generator := NewAutoGrid(100, 10, 1.5, 0.5)\n    \n    // Initialize grid bot\n    bot := toolkit.NewGridBot(generator, instrument)\n    \n    // Run backtest\n    equity, err := tester.Backtest(charts, bot)\n    if err != nil {\n        panic(err)\n    }\n}\n```\n\n### Portfolio Management\n\nXoney includes tools for portfolio management and rebalancing. All weights and orders are specified in base currency:\n\n```go\n// Create a rebalancing strategy with weights in base currency\nweights := map[data.Currency]float64{\n    btc:  0.4,  // 0.4 BTC\n    eth:  0.3,  // 0.3 ETH\n    usdt: 0.3,  // 0.3 USDT\n}\n\nrebalancer := toolkit.NewRebalancePortfolio(weights)\n```\n\n### Custom Events\n\nYou can create custom events by implementing the Event interface:\n\n```go\ntype CustomEvent struct {\n    timestamp time.Time\n    data      interface{}\n}\n\nfunc (e *CustomEvent) Occur(connector exchange.Connector) error {\n    // Implement your event logic here\n    return nil\n}\n\n// Create sequential events (executed one after another)\nsequential := events.NewSequential(event1, event2, event3)\n\n// Create parallel events (executed simultaneously)\nparallel := events.NewParallel(event1, event2, event3)\n```\n\nExample of a custom order event:\n\n```go\ntype OrderEvent struct {\n    order exchange.Order\n}\n\nfunc (e *OrderEvent) Occur(connector exchange.Connector) error {\n    return connector.PlaceOrder(e.order)\n}\n\n// Create and use the event\norder, _ := exchange.NewOrder(\n    symbol,\n    exchange.Market,\n    exchange.Buy,\n    price,  // price in base currency\n    amount,  // amount in base currency\n)\nevent := \u0026OrderEvent{order: order}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquick-trade%2Fxoney","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquick-trade%2Fxoney","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquick-trade%2Fxoney/lists"}