Skip to content

Conversation

@cto-new
Copy link

@cto-new cto-new bot commented Oct 18, 2025

Summary

This PR introduces a new FastAPI endpoint to retrieve the latest traded price and core trading statistics for a specified A-share (SZ/SH) stock symbol, such as sz002549, with flexible symbol normalization and a schema-based JSON response.

Details

  • Adds aktools/core/api/quotes.py with a /quotes/latest endpoint and a Pydantic response model.
  • Accepts symbol as either a plain 6-digit code or with exchange prefix; defaults: sz for 0/3, sh for 6.
  • Maps AKShare snapshot data fields to structured JSON; parses percentage fields as floats.
  • Implements a short in-memory cache (~5s) per symbol to limit repeated heavy snapshot queries.
  • Wires new router in main.py (not under /api) and exposes via import in package.
  • Adds tests using FastAPI TestClient with mocking, verifying both success and not-found paths.

Add a new FastAPI router providing GET /quotes/latest which returns the latest
traded price and relevant quote info for a specified A-share symbol
(e.g., sz002549 or 002549). Uses AKShare's snapshot data, normalizes inputs
with or without exchange prefix, and responds with Pydantic schema.
Implements short in-memory cache to reduce load. Includes unit tests with
monkeypatch for AKShare data. Wires new router directly into main app.

This feature improves real-time access to individual A-share quote data
via a direct, lightweight HTTP endpoint, returning structured and
type-safe results. No breaking changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant