1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! Post-processing transformations for signal values.
//!
//! This module provides post-processors that apply transformations to signal values
//! after they have been processed from source data. Post-processors can be used to
//! adjust, normalize, or otherwise transform the values produced by the main processor.
//!
//! The module provides:
//!
//! - The [`PostProcessor`] enum which represents different post-processing strategies
//! - Specialized post-processor implementations in submodules
//! - Error handling for the post-processing operations
//!
//! # Available Post-Processors
//!
//! The following post-processing strategies are available:
//!
//! - [`TickConvertor`](tick::TickPostProcessor) - Converts values to specific tick sizes
//!
//! # Extensibility
//!
//! This module is designed to be extensible. New post-processing strategies can be added by:
//!
//! 1. Creating a new post-processor implementation in a submodule
//! 2. Adding a new variant to the [`PostProcessor`] enum
//! 3. Implementing the necessary logic in the `name` and `post_process` methods
//!
//! # Usage in Registry
//!
//! Post-processors are used within the registry system to define how signal values
//! should be transformed after the main processing step. Each signal can specify
//! multiple post-processors that are applied in sequence.
use ;
use Decimal;
use ;
use Error;
/// Error type for post-processor operations.
///
/// This error is returned when a post-processor encounters an issue while
/// transforming a value, such as invalid input or mathematical errors.
///
/// # Examples
///
/// ```
/// use bothan_lib::registry::post_processor::PostProcessError;
///
/// let error = PostProcessError::new("Invalid tick size");
/// assert_eq!(error.to_string(), "Invalid tick size");
/// ```
/// Represents different strategies for post-processing signal values.
///
/// The `PostProcessor` enum encapsulates different algorithms for transforming
/// signal values after they have been processed from source data. Each variant
/// contains its own configuration parameters.
///
/// # Variants
///
/// * `TickConvertor` - Converts values to specific tick sizes
///
/// # Examples
///
/// Creating a tick convertor post-processor:
///
/// ```
/// use bothan_lib::registry::post_processor::{PostProcessor, tick::TickPostProcessor};
/// use serde_json::json;
///
/// // Create a post-processor from JSON
/// let json_data = json!({
/// "function": "tick_convertor",
/// "params": {}
/// });
///
/// let post_processor: PostProcessor = serde_json::from_value(json_data).unwrap();
/// assert_eq!(post_processor.name(), "tick_convertor");
/// ```
///
/// Using a post-processor:
///
/// ```
/// use bothan_lib::registry::post_processor::{PostProcessor, tick::TickPostProcessor};
/// use rust_decimal::Decimal;
///
/// // Create a tick convertor post-processor
/// let post_processor = PostProcessor::TickConvertor(TickPostProcessor {});
///
/// // Apply the post-processor to a value
/// let value = Decimal::new(1234, 0);
/// let result = post_processor.post_process(value).unwrap();
/// ```