{"id":15324932,"url":"https://github.com/bruce-mig/stock-exchange","last_synced_at":"2026-01-28T14:32:38.413Z","repository":{"id":207322002,"uuid":"718174727","full_name":"bruce-mig/stock-exchange","owner":"bruce-mig","description":"a stock-exchange with a working matching engine, orderbooks and market maker written in golang. ","archived":false,"fork":false,"pushed_at":"2024-11-19T12:47:15.000Z","size":1750,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-02T07:26:29.886Z","etag":null,"topics":["echo-server","finance-application","go","golang","stock-exchange","stock-market"],"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/bruce-mig.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-11-13T14:38:08.000Z","updated_at":"2025-07-25T19:09:47.000Z","dependencies_parsed_at":"2024-12-06T09:40:40.405Z","dependency_job_id":"6c5e069e-9503-452a-909c-e4ed3b34ecb4","html_url":"https://github.com/bruce-mig/stock-exchange","commit_stats":{"total_commits":55,"total_committers":2,"mean_commits":27.5,"dds":0.1454545454545455,"last_synced_commit":"59e63ff64e80e5450b30150dba2ba5fa75b63678"},"previous_names":["bruce-mig/stock-exchange"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bruce-mig/stock-exchange","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fstock-exchange","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fstock-exchange/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fstock-exchange/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fstock-exchange/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bruce-mig","download_url":"https://codeload.github.com/bruce-mig/stock-exchange/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bruce-mig%2Fstock-exchange/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28846058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T13:02:32.985Z","status":"ssl_error","status_checked_at":"2026-01-28T13:02:04.945Z","response_time":57,"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":["echo-server","finance-application","go","golang","stock-exchange","stock-market"],"created_at":"2024-10-01T09:28:49.385Z","updated_at":"2026-01-28T14:32:38.401Z","avatar_url":"https://github.com/bruce-mig.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stock-exchange\n\nAn exchange with a working matching engine, orderbooks and market maker.\n\n---\n\n### How to Start application\n\nClone the application using the below command\n\n```bash\ngit clone git@github.com:bruce-mig/stock-exchange.git\n```\n\n### Start ganache sandbox server\n\nEnsure docker is running then run\n\n```bash\ncd stock-exchange\\\ndocker compose up\n```\n\nGanache server will provide wallets to the users so they can trade on the exchange.  \nGanache server will be listening on port `:8545`\n\n### Test the Stock Exchange Application\n\n```bash\ncd stock-exchange\nmake test\n```\n\n### Start the Stock Exchange Application\n\nFirst create a `.env` file at the root of the project with the following keys:\n```bash\n# retrieve the private keys from the ganache server logs\nEXCHANGE_PK=\"\" # exchange private key\nUSER_1_PK=\"\" # user private key\nUSER_2_PK=\"\" # user private key\nUSER_3_PK=\"\" # user private key\n\nSERVER_ENDPOINT=\"http://localhost:3000\"\nCSD_ENDPOINT=\"http://localhost:8545\"\n```\n\nThen start the application with the following command\n\n```bash\ncd stock-exchange\nmake run\n```\n\nThe app will start listening on port `:3000`\n\n```bash\ngo build -o bin/exchange\n./bin/exchange\nINFO[0000] new exchange user                             id=8\nINFO[0000] new exchange user                             id=7\nINFO[0000] new exchange user                             id=6\n\n   ____    __\n  / __/___/ /  ___\n / _// __/ _ \\/ _ \\\n/___/\\__/_//_/\\___/ v4.11.3\nHigh performance, minimalist Go web framework\nhttps://echo.labstack.com\n____________________________________O/_______\n                                    O\\\n⇨ http server started on [::]:3000\nINFO[0001] starting market maker                         id=8 makeInterval=1s minSpread=20 orderSize=200 priceOffset=10\nINFO[0001] orderbooks empty =\u003e seeding market!           currentINNPrice=1000 seedOffset=40\nINFO[0001] new limit order                               price=960 size=200 type=BID userID=8\nINFO[0001] new limit order                               price=1040 size=200 type=ASK userID=8\nINFO[0001] new limit order                               price=970 size=200 type=BID userID=8\nINFO[0001] new limit order                               price=1030 size=200 type=ASK userID=8\nINFO[0002] new limit order                               price=980 size=200 type=BID userID=8\nINFO[0002] new limit order                               price=1020 size=200 type=ASK userID=8\nINFO[0003]                                               currentPrice=980\nINFO[0003] filled MARKET order                           avgPrice=980 size=10 type=ASK\nINFO[0003] new limit order                               price=990 size=200 type=BID userID=8\nINFO[0003] new limit order                               price=1010 size=200 type=ASK userID=8\nINFO[0003]                                               currentPrice=990\nINFO[0003] filled MARKET order                           avgPrice=990 size=10 type=ASK\nINFO[0004]                                               currentPrice=1010\nINFO[0004] filled MARKET order                           avgPrice=1010 size=10 type=BID\nINFO[0004]                                               currentPrice=990\nINFO[0004] filled MARKET order                           avgPrice=990 size=10 type=ASK\nINFO[0005]                                               currentPrice=990\n```\n\n![Application Start](static/starting-app.png)\n\n\n---\n\n## APIs\n\n#### Place Limit Order \n\n```bash\nmigeri@DESKTOP-D1MQC11:~/Projects/stock-exchange$ http POST localhost:3000/order \\\n   UserID:=6 \\\n   Type=LIMIT \\\n   Bid:=true \\\n   Price:=990 \\\n   Size:=37 \\\n   Market=INN\n```\nBelow is the success response with the order Id.\n\n```bash\nHTTP/1.1 200 OK\nContent-Length: 21\nContent-Type: application/json; charset=UTF-8\nDate: Mon, 18 Nov 2024 15:31:20 GMT\n\n{\n    \"OrderID\": 60464691\n}\n\n```\n\n Below we can see the order was placed successfully:\n\n ![Order Placed Successfully](static/order-placed-successfully.png)\n\n#### Get all user's orders\n\n```bash\nmigeri@DESKTOP-D1MQC11:~$ http :3000/order/user/6\nHTTP/1.1 200 OK\nContent-Length: 205\nContent-Type: application/json; charset=UTF-8\nDate: Mon, 18 Nov 2024 14:59:52 GMT\n\n{\n    \"Asks\": [],\n    \"Bids\": [\n        {\n            \"Bid\": true,\n            \"ID\": 47996242,\n            \"Price\": 990,\n            \"Size\": 37,\n            \"Timestamp\": 1731941984832909182,\n            \"UserID\": 6\n        },\n        {\n            \"Bid\": true,\n            \"ID\": 64503204,\n            \"Price\": 990,\n            \"Size\": 37,\n            \"Timestamp\": 1731941985561347132,\n            \"UserID\": 6\n        }\n    ]\n}\n```\n\n#### Get Best Ask for a counter\n\n```bash\nmigeri@DESKTOP-D1MQC11:~$ http :3000/book/INN/bestAsk\nHTTP/1.1 200 OK\nContent-Length: 67\nContent-Type: application/json; charset=UTF-8\nDate: Mon, 18 Nov 2024 15:00:36 GMT\n\n{\n    \"Bid\": false,\n    \"ID\": 0,\n    \"Price\": 990,\n    \"Size\": 0,\n    \"Timestamp\": 0,\n    \"UserID\": 8\n}\n```\n\n#### Get Best Bid for a counter\n\n```bash\nmigeri@DESKTOP-D1MQC11:~$ http :3000/book/INN/bestBid\nHTTP/1.1 200 OK\nContent-Length: 67\nContent-Type: application/json; charset=UTF-8\nDate: Mon, 18 Nov 2024 15:01:03 GMT\n\n{\n    \"Bid\": false,\n    \"ID\": 0,\n    \"Price\": 970,\n    \"Size\": 0,\n    \"Timestamp\": 0,\n    \"UserID\": 8\n}\n```\n\n####  Get all trades from counter INN\n\n```bash\nmigeri@DESKTOP-D1MQC11:~$ http :3000/trades/INN\nHTTP/1.1 200 OK\nContent-Length: 1362\nContent-Type: application/json; charset=UTF-8\nDate: Mon, 18 Nov 2024 15:02:17 GMT\n\n[\n    {\n        \"Bid\": false,\n        \"Price\": 980,\n        \"Size\": 10,\n        \"Timestamp\": 1731942127526835511\n    },\n    {\n        \"Bid\": false,\n        \"Price\": 990,\n        \"Size\": 10,\n        \"Timestamp\": 1731942128027074145\n    },\n    {\n        \"Bid\": true,\n        \"Price\": 1010,\n        \"Size\": 10,\n        \"Timestamp\": 1731942128526714030\n    },\n    {\n        \"Bid\": false,\n        \"Price\": 990,\n        \"Size\": 10,\n        \"Timestamp\": 1731942129027916243\n    },\n    {\n        \"Bid\": false,\n        \"Price\": 990,\n        \"Size\": 10,\n        \"Timestamp\": 1731942129526623452\n    },\n    {\n        \"Bid\": true,\n        \"Price\": 1010,\n        \"Size\": 10,\n        \"Timestamp\": 1731942130024043735\n    }\n]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fstock-exchange","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruce-mig%2Fstock-exchange","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-mig%2Fstock-exchange/lists"}