{"id":24786835,"url":"https://github.com/porcelaincode/tradehub","last_synced_at":"2025-09-05T20:44:31.974Z","repository":{"id":246418649,"uuid":"820055157","full_name":"porcelaincode/tradehub","owner":"porcelaincode","description":"This aims to be an adaptor over your preferred broker or just a mock broker server for paper trading. Using Sqlite3, written in Go. ","archived":false,"fork":false,"pushed_at":"2024-06-27T18:56:50.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T15:17:07.938Z","etag":null,"topics":["golang","trading"],"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/porcelaincode.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":"2024-06-25T17:52:41.000Z","updated_at":"2024-06-27T18:58:26.000Z","dependencies_parsed_at":"2024-06-27T22:10:16.682Z","dependency_job_id":"89d91468-18f3-4701-a36c-dc9eddaccd62","html_url":"https://github.com/porcelaincode/tradehub","commit_stats":null,"previous_names":["porcelaincode/tradehub"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porcelaincode%2Ftradehub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porcelaincode%2Ftradehub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porcelaincode%2Ftradehub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porcelaincode%2Ftradehub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porcelaincode","download_url":"https://codeload.github.com/porcelaincode/tradehub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245248745,"owners_count":20584495,"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":["golang","trading"],"created_at":"2025-01-29T15:17:12.491Z","updated_at":"2025-03-24T09:45:21.244Z","avatar_url":"https://github.com/porcelaincode.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TradeHub: Mock Broker Server\n\nThis project is a mock broker server built with FastAPI, allowing you to paper trade using simulated market data. The server handles instruments, orders, positions, and emits relevant events via WebSockets.\n\n## Features\n\n- Downloads instruments from an external API and stores them in an SQLite database.\n- Provides endpoints for subscribing to instrument tokens and placing orders.\n- Simulates live market data and emits events for subscribed instruments.\n- Handles orders and updates positions, including GTT and regular orders.\n\n## Endpoints\n\n### POST /subscribe\n\nSubscribe to an array of instrument tokens to receive simulated market data.\n\nRequest body:\n\n```json\n[{ \"instrument_token\": \"11536\", \"exchange_segment\": \"nse_cm\" }]\n```\n\n### POST /orders\n\nPlace an order with the specified parameters.\n\nRequest body:\n\n```json\n{\n  \"am\": \"YES\",\n  \"dq\": \"0\",\n  \"es\": \"nse_cm\",\n  \"mp\": \"0\",\n  \"pc\": \"NRML\",\n  \"pf\": \"N\",\n  \"pr\": \"100.5\",\n  \"pt\": \"L\",\n  \"qt\": \"10\",\n  \"rt\": \"DAY\",\n  \"tp\": \"0\",\n  \"ts\": \"YESBANK-EQ\",\n  \"tt\": \"B\",\n  \"ig\": \"order_tag\"\n}\n```\n\n### GET /positions\n\nRetrieve the current positions.\n\nResponse:\n\n```json\n{\n  \"stat\": \"Ok\",\n  \"stCode\": 200,\n  \"data\": [\n    {\n      \"buyAmt\": \"2625.00\",\n      \"cfSellAmt\": \"0.00\",\n      \"prod\": \"NRML\",\n      \"exSeg\": \"nse_fo\",\n      \"sqrFlg\": \"Y\",\n      \"actId\": \"PRS2206\",\n      \"cfBuyQty\": \"0\",\n      \"cfSellQty\": \"0\",\n      \"tok\": \"53179\",\n      \"flBuyQty\": \"25\",\n      \"flSellQty\": \"25\",\n      \"sellAmt\": \"2625.00\",\n      \"posFlg\": \"true\",\n      \"cfBuyAmt\": \"0.00\",\n      \"stkPrc\": \"0.00\",\n      \"trdSym\": \"BANKNIFTY21JULFUT\",\n      \"sym\": \"BANKNIFTY\",\n      \"expDt\": \"29 Jul, 2021\",\n      \"type\": \"FUTIDX\",\n      \"series\": \"XX\",\n      \"brdLtQty\": \"25\",\n      \"exp\": \"1627569000\",\n      \"optTp\": \"XX\",\n      \"genNum\": \"1\",\n      \"genDen\": \"1\",\n      \"prcNum\": \"1\",\n      \"prcDen\": \"1\",\n      \"lotSz\": \"25\",\n      \"multiplier\": \"1\",\n      \"precision\": \"2\",\n      \"hsUpTm\": \"2021/07/13 18:34:44\"\n    }\n  ]\n}\n```\n\n## TODO\n\n\u003cinput type=\"checkbox\" disabled /\u003e Write better random LTP generation logic\n\n\u003cinput type=\"checkbox\" disabled /\u003e Move the database to Aerospike or Redis for better performance\n\n\u003cinput type=\"checkbox\" disabled /\u003e \u003cb\u003eHandle concurrency and transaction Handling\u003c/b\u003e such that all database operations are performed within proper transactions to maintain data integrity.\n\n\u003cinput type=\"checkbox\" disabled /\u003e \u003cb\u003eAdd detailed error handling\u003c/b\u003e and logging to capture and debug issues effectively.\n\n\u003cinput type=\"checkbox\" disabled /\u003e Implement \u003cb\u003enecessary security measures\u003c/b\u003e such as authentication and authorization if required.\n\n\u003cinput type=\"checkbox\" disabled /\u003e \u003cb\u003eOptimize database queries\u003c/b\u003e and WebSocket handling for better performance under load.\n\n\u003cinput type=\"checkbox\" disabled checked/\u003e Write the entire thing in Go lang\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporcelaincode%2Ftradehub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporcelaincode%2Ftradehub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporcelaincode%2Ftradehub/lists"}