mirror of
https://ghfast.top/https://github.com/aeroxw/tick-stock-panel.git
synced 2026-09-12 22:34:18 +08:00
DEFAULT_STRATEGY_NOTIFY_EVENTS 从买/卖信号改为进入/移出选股结果, 新建规则、类型切换、策略页创建监控三处默认随之生效; 与后端省略 notify_events 字段时的回填口径一致。旧规则空值回退(LEGACY)不变。
75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
import type { StrategyNotifyEvent } from './api'
|
|
|
|
export interface StrategyEventMeta {
|
|
label: string
|
|
action: string
|
|
className: string
|
|
}
|
|
|
|
const META: Record<string, StrategyEventMeta> = {
|
|
buy_signal: {
|
|
label: '买入',
|
|
action: '买入信号',
|
|
className: 'text-danger',
|
|
},
|
|
sell_signal: {
|
|
label: '卖出',
|
|
action: '卖出信号',
|
|
className: 'text-bear',
|
|
},
|
|
pool_entry: {
|
|
label: '进入',
|
|
action: '进入选股结果',
|
|
className: 'text-danger',
|
|
},
|
|
pool_exit: {
|
|
label: '移出',
|
|
action: '移出选股结果',
|
|
className: 'text-bear',
|
|
},
|
|
new_entry: {
|
|
label: '进入',
|
|
action: '进入选股结果',
|
|
className: 'text-danger',
|
|
},
|
|
dropped: {
|
|
label: '移出',
|
|
action: '移出选股结果',
|
|
className: 'text-bear',
|
|
},
|
|
}
|
|
|
|
/** 新建策略监控的默认通知事件: 选股结果(进入/移出), 与后端省略字段时的回填一致 */
|
|
export const DEFAULT_STRATEGY_NOTIFY_EVENTS: StrategyNotifyEvent[] = [
|
|
'pool_entry',
|
|
'pool_exit',
|
|
]
|
|
|
|
export const LEGACY_STRATEGY_NOTIFY_EVENTS: StrategyNotifyEvent[] = [
|
|
'pool_entry',
|
|
'pool_exit',
|
|
]
|
|
|
|
export const STRATEGY_NOTIFY_EVENT_OPTIONS: {
|
|
key: StrategyNotifyEvent
|
|
label: string
|
|
group: 'signal' | 'pool'
|
|
}[] = [
|
|
{ key: 'buy_signal', label: '买入信号', group: 'signal' },
|
|
{ key: 'sell_signal', label: '卖出信号', group: 'signal' },
|
|
{ key: 'pool_entry', label: '进入选股结果', group: 'pool' },
|
|
{ key: 'pool_exit', label: '移出选股结果', group: 'pool' },
|
|
]
|
|
|
|
export function strategyEventMeta(type: string): StrategyEventMeta {
|
|
return META[type] ?? {
|
|
label: '事件',
|
|
action: '策略事件',
|
|
className: 'text-secondary',
|
|
}
|
|
}
|
|
|
|
export function strategyName(message: string): string {
|
|
return message.match(/策略「([^」]+)」/)?.[1] ?? ''
|
|
}
|