Skip to main content

futu_mcp/handlers/proto_json/
kline_pattern.rs

1use std::sync::Arc;
2
3use anyhow::Result;
4use futu_net::client::FutuClient;
5
6use super::{finish_response, send_proto};
7
8macro_rules! handler {
9    ($fn_name:ident, $label:literal, $proto_const:ident, $module:ident) => {
10        pub async fn $fn_name(
11            client: &Arc<FutuClient>,
12            c2s: futu_proto::$module::C2s,
13        ) -> Result<String> {
14            let response: futu_proto::$module::Response = send_proto(
15                client,
16                futu_core::proto_id::$proto_const,
17                futu_proto::$module::Request { c2s },
18            )
19            .await?;
20            finish_response(
21                $label,
22                response.ret_type,
23                response.ret_msg.as_deref(),
24                response.err_code,
25                &response,
26            )
27        }
28    };
29}
30
31handler!(
32    kline_pattern,
33    "kline-pattern",
34    QOT_GET_KLINE_PATTERN,
35    qot_get_kline_pattern
36);
37handler!(
38    kline_pattern_statistics,
39    "kline-pattern-statistics",
40    QOT_GET_KLINE_PATTERN_STATISTICS,
41    qot_get_kline_pattern_statistics
42);
43handler!(
44    kline_pattern_stocks,
45    "kline-pattern-stocks",
46    QOT_GET_KLINE_PATTERN_STOCKS,
47    qot_get_kline_pattern_stocks
48);
49handler!(
50    kline_pattern_performance,
51    "kline-pattern-performance",
52    QOT_GET_KLINE_PATTERN_PERFORMANCE,
53    qot_get_kline_pattern_performance
54);
55handler!(
56    kline_pattern_catalog,
57    "kline-pattern-catalog",
58    QOT_GET_KLINE_PATTERN_CATALOG,
59    qot_get_kline_pattern_catalog
60);