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
// ! Signal definitions for registry entries.
//!
//! This module provides the core structure for defining signals in the registry system.
//! A signal represents a specific asset or data point that can be computed from various
//! sources, processed according to a defined strategy, and optionally transformed through
//! post-processing steps.
//!
//! The module provides:
//!
//! - The [`Signal`] struct which defines the complete specification for a signal
//! - Methods for creating and managing signal definitions
//!
//! # Signal Structure
//!
//! Each signal consists of:
//!
//! - Source queries that specify where to obtain input data
//! - A processor that defines how to combine data from different sources
//! - Optional post-processors that apply transformations to the processed value
//!
//! Signals form the fundamental building blocks of the registry system, enabling
//! the computation of asset information from various data sources in a structured
//! and configurable way.
use ;
use ;
use cratePostProcessor;
use crateProcessor;
use crateSourceQuery;
/// A complete definition for computing a signal value.
///
/// The `Signal` struct encapsulates all the information required to compute a signal value:
/// the sources to query for input data, the processing strategy to apply, and any
/// post-processing transformations to perform on the result.
///
/// Signals are the fundamental building blocks of the registry system, allowing for
/// flexible and configurable computation of asset information from various data sources.
///
/// # Components
///
/// * `source_queries` - Definitions of where and how to obtain input data
/// * `processor` - Strategy for combining data from different sources
/// * `post_processors` - Optional transformations to apply to the processed value
///
/// # Examples
///
/// ```
/// use bothan_lib::registry::signal::Signal;
/// use bothan_lib::registry::source::{SourceQuery, OperationRoute, Operation};
/// use bothan_lib::registry::processor::{Processor, median::MedianProcessor};
/// use bothan_lib::registry::post_processor::{PostProcessor, tick::TickPostProcessor};
///
/// // Create a BTC-USD signal that uses data from multiple sources
/// let signal = Signal::new(
/// // Source queries
/// vec![
/// SourceQuery::new(
/// "binance".to_string(),
/// "btcusdt".to_string(),
/// vec![
/// // Apply USDT-USD conversion route
/// OperationRoute::new("USDT-USD".to_string(), Operation::Multiply),
/// ],
/// ),
/// SourceQuery::new(
/// "coinbase".to_string(),
/// "BTC-USD".to_string(),
/// vec![],
/// ),
/// ],
/// // Processor (median with at least 1 source required)
/// Processor::Median(MedianProcessor { min_source_count: 1 }),
/// // Post-processors (convert to tick value)
/// vec![PostProcessor::TickConvertor(TickPostProcessor {})],
/// );
/// ```