{"id":24787809,"url":"https://github.com/fang2hou/markets","last_synced_at":"2025-03-24T11:14:28.917Z","repository":{"id":92609683,"uuid":"461565880","full_name":"fang2hou/markets","owner":"fang2hou","description":"Local high performance cryptocurrency price data provider.","archived":false,"fork":false,"pushed_at":"2023-09-26T00:39:52.000Z","size":111,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T20:42:14.329Z","etag":null,"topics":["cryptocurrency","cryptocurrency-api","cryptocurrency-exchanges","cryptocurrency-prices"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fang2hou.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-20T17:40:56.000Z","updated_at":"2023-09-26T00:38:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2b5107f-7759-4d3f-be3b-1ed665b9a6f4","html_url":"https://github.com/fang2hou/markets","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/fang2hou%2Fmarkets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fang2hou%2Fmarkets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fang2hou%2Fmarkets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fang2hou%2Fmarkets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fang2hou","download_url":"https://codeload.github.com/fang2hou/markets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245258220,"owners_count":20585977,"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":["cryptocurrency","cryptocurrency-api","cryptocurrency-exchanges","cryptocurrency-prices"],"created_at":"2025-01-29T16:13:50.074Z","updated_at":"2025-03-24T11:14:28.895Z","avatar_url":"https://github.com/fang2hou.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# markets\n\n## Introduction\n\nThis project is used to build a real-time cross-exchange price database. In addition to the prices, the program also automatically stores the commission information obtained through the exchange API. Based on the information in the database, you can set up strategies to trade robotically.\n\nIt's a free work for everyone, but if you use this library, the code you write need to be open source.\n\n```\nLICENSE: LGPL version 3\n```\n\n## Features\n\n1. Support WebSocket API of various exchanges with very high performance.\n2. Support for using both Rest API and WebSocket API in a single thread.\n3. Multiple exchanges can be polled at the same time.\n4. It is easy to extend the program to support more exchanges.\n\n## Storage\n\nThe program only provides two types of storage:\n1. Simply save in memory.\n2. Redis\n\nThe other databases are also supported, but you need to write a connector for them in golang.  \nCheck the files in `pkg/database` if you want to know how to create a connector.\n\n## Usage\n\nHere is the sample code, just set your API token in the `config.yaml` file, and then run the program.\n\n```go\npackage main\n\nimport (\n\t\"os\"\n\n\t\"github.com/go-redis/redis/v8\"\n\n\t\"markets/internal/pkg/config\"\n\t\"markets/pkg/database\"\n\t\"markets/pkg/exchange\"\n)\n\nfunc pollExchange(e exchange.Exchanger) {\n\tforever := make(chan bool)\n\n\tif err := e.Start(); err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer func() {\n\t\tif err := e.Stop(); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t}()\n\n\t\u003c-forever\n}\n\nfunc main() {\n\tdataBytes, err := os.ReadFile(\"configs/config.yaml\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcfg := config.Config{}\n\n\tif err := cfg.Load(dataBytes); err != nil {\n\t\tpanic(err)\n\t}\n\n\tvar currencies []string\n\n\tif value, err := cfg.GetCurrenciesSetting(); err != nil {\n\t\tpanic(err)\n\t} else {\n\t\tcurrencies = value\n\t}\n\n\tif setting, err := cfg.GetExchangeSetting(\"okx\"); err != nil {\n\t\tpanic(err)\n\t} else {\n\t\te := exchange.NewOkx(\n\t\t\tsetting,\n\t\t\tcurrencies,\n\t\t\tdatabase.NewInteractor(database.NewRedisConnector(\u0026redis.Options{\n\t\t\t\tAddr: \"localhost:6379\",\n\t\t\t})),\n\t\t)\n\n\t\tgo pollExchange(e)\n\t}\n\n\tif setting, err := cfg.GetExchangeSetting(\"gateio\"); err != nil {\n\t\tpanic(err)\n\t} else {\n\t\te := exchange.NewGateio(\n\t\t\tsetting,\n\t\t\tcurrencies,\n\t\t\tdatabase.NewInteractor(database.NewRedisConnector(\u0026redis.Options{\n\t\t\t\tAddr: \"localhost:6379\",\n\t\t\t})),\n\t\t)\n\n\t\tgo pollExchange(e)\n\t}\n\n\tforever := make(chan bool)\n\t\u003c-forever\n}\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffang2hou%2Fmarkets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffang2hou%2Fmarkets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffang2hou%2Fmarkets/lists"}