{"id":17912649,"url":"https://github.com/danielgatis/go-orderbook","last_synced_at":"2025-07-25T20:43:12.220Z","repository":{"id":41136136,"uuid":"437147919","full_name":"danielgatis/go-orderbook","owner":"danielgatis","description":"The pkg go-orderbook implements a limit order book for high-frequency trading (HFT), as described by WK Selph.","archived":false,"fork":false,"pushed_at":"2023-08-08T02:41:25.000Z","size":29,"stargazers_count":22,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T00:06:42.324Z","etag":null,"topics":["exchange","matching-engine","orderbook"],"latest_commit_sha":null,"homepage":"","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/danielgatis.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}},"created_at":"2021-12-11T00:14:08.000Z","updated_at":"2025-01-17T06:45:30.000Z","dependencies_parsed_at":"2024-06-19T17:10:19.867Z","dependency_job_id":"6fb23d03-3de0-40d4-ae73-46c130c4a4f4","html_url":"https://github.com/danielgatis/go-orderbook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-orderbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-orderbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-orderbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgatis%2Fgo-orderbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgatis","download_url":"https://codeload.github.com/danielgatis/go-orderbook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245180320,"owners_count":20573646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["exchange","matching-engine","orderbook"],"created_at":"2024-10-28T19:46:21.827Z","updated_at":"2025-03-23T22:34:49.110Z","avatar_url":"https://github.com/danielgatis.png","language":"Go","funding_links":["https://www.buymeacoffee.com/danielgatis"],"categories":[],"sub_categories":[],"readme":"# Go - Orderbook\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/danielgatis/go-orderbook?style=flat-square)](https://goreportcard.com/report/github.com/danielgatis/go-orderbook)\n[![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/danielgatis/go-orderbook/master/LICENSE)\n[![Go Doc](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/danielgatis/go-orderbook)\n\nThe pkg `go-orderbook` implements a limit order book for high-frequency trading (HFT), as described by WK Selph.\n\nBased on WK Selph's Blogpost:\nhttps://goo.gl/KF1SRm\n\n## Install\n\n```bash\ngo get -u github.com/danielgatis/go-orderbook\n```\n\nAnd then import the package in your code:\n\n```go\nimport \"github.com/danielgatis/go-orderbook\"\n```\n\n### Example\n\nAn example described below is one of the use cases.\n\n```go\npackage main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"math/rand\"\n\t\"time\"\n\n\t\"github.com/danielgatis/go-orderbook\"\n\t\"github.com/google/uuid\"\n\t\"github.com/shopspring/decimal\"\n)\n\nfunc main() {\n\tbook := orderbook.NewOrderBook(\"BTC/BRL\")\n\n\tfor i := 0; i \u003c 10; i++ {\n\t\trand.Seed(time.Now().UnixNano())\n\t\tside := []orderbook.Side{orderbook.Buy, orderbook.Sell}[rand.Intn(2)]\n\n\t\tbook.ProcessPostOnlyOrder(uuid.New().String(), uuid.New().String(), side, decimal.NewFromInt(rand.Int63n(1000)), decimal.NewFromInt(rand.Int63n(1000)))\n\t}\n\n\tdepth, _ := json.Marshal(book.Depth())\n\tvar buf bytes.Buffer\n\tjson.Indent(\u0026buf, depth, \"\", \"  \")\n\tfmt.Println(buf.String())\n}\n```\n\n```\n❯ go run main.go\n{\n  \"bids\": [\n    {\n      \"amount\": \"392\",\n      \"price\": \"930\"\n    },\n    {\n      \"amount\": \"872\",\n      \"price\": \"907\"\n    },\n    {\n      \"amount\": \"859\",\n      \"price\": \"790\"\n    },\n    {\n      \"amount\": \"643\",\n      \"price\": \"424\"\n    },\n    {\n      \"amount\": \"269\",\n      \"price\": \"244\"\n    },\n    {\n      \"amount\": \"160\",\n      \"price\": \"83\"\n    },\n    {\n      \"amount\": \"74\",\n      \"price\": \"65\"\n    }\n  ],\n  \"asks\": [\n    {\n      \"amount\": \"178\",\n      \"price\": \"705\"\n    },\n    {\n      \"amount\": \"253\",\n      \"price\": \"343\"\n    },\n    {\n      \"amount\": \"805\",\n      \"price\": \"310\"\n    }\n  ]\n}\n```\n\n## License\n\nCopyright (c) 2020-present [Daniel Gatis](https://github.com/danielgatis)\n\nLicensed under [MIT License](./LICENSE)\n\n### Buy me a coffee\n\nLiked some of my work? Buy me a coffee (or more likely a beer)\n\n\u003ca href=\"https://www.buymeacoffee.com/danielgatis\" target=\"_blank\"\u003e\u003cimg src=\"https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\"\u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-orderbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgatis%2Fgo-orderbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgatis%2Fgo-orderbook/lists"}