{"id":24089446,"url":"https://github.com/longbridge/stock-parser","last_synced_at":"2026-06-17T10:32:13.277Z","repository":{"id":65950273,"uuid":"602972132","full_name":"longbridge/stock-parser","owner":"longbridge","description":"Stock parser","archived":false,"fork":false,"pushed_at":"2026-02-10T07:54:02.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2026-02-10T13:39:55.797Z","etag":null,"topics":[],"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/longbridge.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-02-17T10:43:59.000Z","updated_at":"2026-02-10T07:51:37.000Z","dependencies_parsed_at":"2024-01-12T09:43:00.163Z","dependency_job_id":"cfd600dd-b6d6-4689-a4e5-dc073f259d74","html_url":"https://github.com/longbridge/stock-parser","commit_stats":null,"previous_names":["longbridge/stock-parser"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/longbridge/stock-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fstock-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fstock-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fstock-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fstock-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/longbridge","download_url":"https://codeload.github.com/longbridge/stock-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/longbridge%2Fstock-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34445179,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"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-01-10T04:13:18.677Z","updated_at":"2026-06-17T10:32:13.172Z","avatar_url":"https://github.com/longbridge.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stock Parser\n\nThis is [Ticker symbol](https://en.wikipedia.org/wiki/Ticker_symbol) parse example to show how to write a parser in Go and Rust (Pest, Nom, rust-peg).\nAnd run benchmarks to compare the performance.\n\n## Usage\n\n```go\n// social-service example\npackage main\n\nimport (\n  \"fmt\"\n\n  stock_parser \"github.com/longbridgeapp/stock-parser\"\n)\n\nfunc main() {\n  out := Parse(\"看好 $BABA 和 $XPEV 未来有好的增长\")\n  fmt.Println(out)\n  // 看好 \u003cspan type=\"security-tag\" counter_id=\"ST/US/BABA\" name=\"阿里巴巴\"\u003e$阿里巴巴.US\u003c/span\u003e 和 \u003cspan type=\"security-tag\" counter_id=\"ST/US/XPEV\" name=\"小鹏汽车\"\u003e$X小鹏汽车.US\u003c/span\u003e 未来有好的增长\n}\n\n\nfunc Parse(ctx context.Context, body string) string {\n  // preproccess\n  out := body\n  body = preprocess(body)\n\n  // Use with StockInfo SDK\n  _ = stock_parser.Parse(body, func(code, market, match string) string {\n    if stock, ok := StockInfoSDK.GetCounterId(code, market); ok {\n      s := fmt.Sprintf(`\u003cspan type=\"security-tag\" counter_id=\"%s\" name=\"%s\"\u003e$%s.%s\u003c/span\u003e`, stock.CounterId, stock.Name, stock.Name, stock.Market)\n      // 替换\n      out = strings.ReplaceAll(out, match, s)\n    }\n    return out\n  })\n\n  return out\n}\n```\n\n### Benchmark in Go\n\n```\nBenchmark-8         \t  489860\t      2729 ns/op\nBenchmark_long-8    \t   64664\t     21624 ns/op\nBenchmark_large-8   \t    1910\t    589914 ns/op\n```\n\n## Development in Go\n\nUse [https://github.com/pointlander/peg](https://github.com/pointlander/peg)\n\n```sh\ngo install github.com/pointlander/peg\n```\n\nAnd then run `make` to generate `grammar.peg` into `grammar.go`.\n\n\u003e NOTE: Please do not change `grammar.go`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongbridge%2Fstock-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flongbridge%2Fstock-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flongbridge%2Fstock-parser/lists"}