{"id":30313893,"url":"https://github.com/keuin/orderbook","last_synced_at":"2025-08-17T18:53:15.592Z","repository":{"id":304995483,"uuid":"1020275619","full_name":"keuin/orderbook","owner":"keuin","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-17T16:50:36.000Z","size":33,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-17T18:06:19.436Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keuin.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}},"created_at":"2025-07-15T15:59:28.000Z","updated_at":"2025-07-17T16:50:39.000Z","dependencies_parsed_at":"2025-07-17T21:16:43.485Z","dependency_job_id":"a151b677-0ef6-46b9-9782-6b867709b6b2","html_url":"https://github.com/keuin/orderbook","commit_stats":null,"previous_names":["keuin/orderbook"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/keuin/orderbook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keuin%2Forderbook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keuin%2Forderbook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keuin%2Forderbook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keuin%2Forderbook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keuin","download_url":"https://codeload.github.com/keuin/orderbook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keuin%2Forderbook/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270892212,"owners_count":24663543,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"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":"2025-08-17T18:53:12.520Z","updated_at":"2025-08-17T18:53:15.567Z","avatar_url":"https://github.com/keuin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Orderbook\n\nLimit Order Book implementations backed by different data structures:\n\n- Naive HashMap\n- Sorted array\n- BTree (non-generic and generic versions from `github.com/emirpasic/gods`, `github.com/google/btree`)\n\n## Interface\n\nThe `OrderBook` interface is defined in `orderbook.go`:\n\n```go\npackage orderbook\n\n\ntype OrderBook interface {\n\tSnapshot(depth int) Snapshot\n\tBid(price Price, amount int)\n\tAsk(price Price, amount int)\n\tGetBid(price Price) (amount int)\n\tGetAsk(price Price) (amount int)\n}\n\ntype Price int\n\ntype PriceAmount struct {\n\tPrice  Price\n\tAmount int\n}\n\ntype Snapshot struct {\n\tBestBids []PriceAmount\n\tBestAsks []PriceAmount\n}\n```\n\n## Benchmark\n\n```\ngoos: linux\ngoarch: amd64\npkg: github.com/keuin/orderbook\ncpu: 12th Gen Intel(R) Core(TM) i9-12900K\nBenchmarkArrayOrderBook-24               8621535               133.6 ns/op\nBenchmarkNaiveOrderBook-24                146120              8072 ns/op\nBenchmarkBTreeOrderBook-24               2425657               473.4 ns/op\nBenchmarkBTreeRefOrderBook-24            2425458               495.5 ns/op\nBenchmarkBTreeGoogleOrderBook-24         4143693               286.9 ns/op\nBenchmarkBTreeGoogleNoGOrderBook-24      2424078               493.5 ns/op\nPASS\nok      github.com/keuin/orderbook      9.973s\n```\n\n## TODO\n\n- More benchmark scenarios (e.g. drastically price shifting)\n- Reduce redundant search operations in BTree using custom implementation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeuin%2Forderbook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeuin%2Forderbook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeuin%2Forderbook/lists"}