feat(selection): show gold brick chart below volume in stock detail panel
Add an optional brick_chart series to the selection chart API, computed from the shared gold-brick formula when strategy=gold_brick, and render a fourth grid with red/green brick bars between the volume and J grids.
This commit is contained in:
@@ -13,11 +13,13 @@ import {
|
||||
export function getSelectionChart(
|
||||
tsCode: string,
|
||||
targetTradeDate: string,
|
||||
strategy?: SelectionStrategy,
|
||||
signal?: AbortSignal,
|
||||
) {
|
||||
const params = new URLSearchParams({
|
||||
target_trade_date: targetTradeDate,
|
||||
})
|
||||
if (strategy) params.set("strategy", strategy)
|
||||
return requestJson<SelectionChart>(
|
||||
`/api/v1/selection/stocks/${encodeURIComponent(tsCode)}/chart?${params.toString()}`,
|
||||
{ signal },
|
||||
|
||||
@@ -31,8 +31,15 @@ const defaultListQuery: SelectionResultsListQuery = {
|
||||
export const selectionChartQueryKey = (
|
||||
tsCode?: string,
|
||||
targetTradeDate?: string,
|
||||
strategy?: SelectionStrategy,
|
||||
) =>
|
||||
["selection", "chart", tsCode ?? "none", targetTradeDate ?? "none"] as const
|
||||
[
|
||||
"selection",
|
||||
"chart",
|
||||
tsCode ?? "none",
|
||||
targetTradeDate ?? "none",
|
||||
strategy ?? "none",
|
||||
] as const
|
||||
|
||||
export const selectionResultsQueryKey = (
|
||||
strategy: SelectionStrategy,
|
||||
@@ -100,12 +107,16 @@ export function useSelectionResults(
|
||||
})
|
||||
}
|
||||
|
||||
export function useSelectionChart(tsCode?: string, targetTradeDate?: string) {
|
||||
export function useSelectionChart(
|
||||
tsCode?: string,
|
||||
targetTradeDate?: string,
|
||||
strategy?: SelectionStrategy,
|
||||
) {
|
||||
return useQuery({
|
||||
enabled: Boolean(tsCode && targetTradeDate),
|
||||
queryFn: ({ signal }) =>
|
||||
getSelectionChart(tsCode ?? "", targetTradeDate ?? "", signal),
|
||||
queryKey: selectionChartQueryKey(tsCode, targetTradeDate),
|
||||
getSelectionChart(tsCode ?? "", targetTradeDate ?? "", strategy, signal),
|
||||
queryKey: selectionChartQueryKey(tsCode, targetTradeDate, strategy),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ export interface SelectionChartPoint {
|
||||
j: number | null
|
||||
trend_white: number | null
|
||||
trend_yellow: number | null
|
||||
brick_chart: number | null
|
||||
}
|
||||
|
||||
export interface SelectionChart {
|
||||
|
||||
Reference in New Issue
Block a user