feat(sector_radar): enhance sector radar functionality with active moneyflow and detailed metrics

- Introduced ActiveMoneyflowSource to fetch optional active-order flow, enhancing the sector radar's data capabilities.
- Updated StockFactRecord and DailyAggregateRecord to include pct_change and active_buy_net_amount_yuan for improved financial insights.
- Modified the build process to incorporate active moneyflow data without invalidating main rankings on failure.
- Enhanced the HTTP API to return detailed sector history and metrics, including pct_change and active buy metrics for members.
- Updated tests to validate the new functionality and ensure data integrity across various scenarios.
This commit is contained in:
yuxuanhui
2026-09-06 16:06:17 +08:00
parent 68282f5d46
commit 7f93d6b0f5
48 changed files with 4883 additions and 95 deletions
@@ -4,10 +4,17 @@ import {
type InfiniteData,
} from "@tanstack/react-query"
import { getSectorRadarDates, getSectorRadarRankings, getStockSectorMembership } from "./sector-radar.api"
import {
getSectorRadarDates,
getSectorRadarRankings,
getStockSectorMembership,
getSectorRadarHistory,
getSectorRadarDetail,
} from "./sector-radar.api"
import type {
RadarRankingsQuery,
RadarRankingsResponse,
RadarSectorQuery,
} from "./sector-radar.types"
export const sectorRadarDatesQueryKey = ["sectorRadar", "dates"] as const
@@ -92,3 +99,31 @@ export function useSectorRadarRankings(query: RadarRankingsQuery) {
queryKey: sectorRadarRankingsQueryKey(query),
})
}
export const sectorRadarSectorQueryKey = (
resource: "history" | "detail",
query: RadarSectorQuery,
) =>
[
"sectorRadar",
resource,
query.sectorType,
query.sectorCode,
query.tradeDate,
] as const
/** Keep on-demand history isolated by sector type, code and requested date. */
export function useSectorRadarHistory(query: RadarSectorQuery) {
return useQuery({
queryKey: sectorRadarSectorQueryKey("history", query),
queryFn: ({ signal }) => getSectorRadarHistory(query, signal),
})
}
/** Mount only while the detail dialog is open; never reuse another date as placeholder data. */
export function useSectorRadarDetail(query: RadarSectorQuery) {
return useQuery({
queryKey: sectorRadarSectorQueryKey("detail", query),
queryFn: ({ signal }) => getSectorRadarDetail(query, signal),
})
}