onesecondtrader 0.14.0__py3-none-any.whl → 0.49.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. onesecondtrader/__init__.py +0 -12
  2. onesecondtrader/events/__init__.py +8 -0
  3. onesecondtrader/events/base.py +21 -0
  4. onesecondtrader/events/market/__init__.py +7 -0
  5. onesecondtrader/events/market/bar_processed.py +29 -0
  6. onesecondtrader/events/market/bar_received.py +34 -0
  7. onesecondtrader/events/orders/__init__.py +9 -0
  8. onesecondtrader/events/orders/base.py +30 -0
  9. onesecondtrader/events/orders/expirations.py +23 -0
  10. onesecondtrader/events/orders/fills.py +41 -0
  11. onesecondtrader/events/requests/__init__.py +11 -0
  12. onesecondtrader/events/requests/base.py +25 -0
  13. onesecondtrader/events/requests/order_cancellation.py +21 -0
  14. onesecondtrader/events/requests/order_modification.py +26 -0
  15. onesecondtrader/events/requests/order_submission.py +35 -0
  16. onesecondtrader/events/responses/__init__.py +14 -0
  17. onesecondtrader/events/responses/base.py +26 -0
  18. onesecondtrader/events/responses/cancellations.py +42 -0
  19. onesecondtrader/events/responses/modifications.py +43 -0
  20. onesecondtrader/events/responses/orders.py +42 -0
  21. onesecondtrader/indicators/__init__.py +17 -0
  22. onesecondtrader/indicators/base.py +142 -0
  23. onesecondtrader/indicators/market_fields.py +166 -0
  24. onesecondtrader/indicators/moving_averages.py +78 -106
  25. onesecondtrader/models/__init__.py +23 -0
  26. onesecondtrader/models/bar_fields.py +23 -0
  27. onesecondtrader/models/bar_period.py +21 -0
  28. onesecondtrader/models/order_types.py +21 -0
  29. onesecondtrader/models/rejection_reasons.py +48 -0
  30. onesecondtrader/models/trade_sides.py +20 -0
  31. {onesecondtrader-0.14.0.dist-info → onesecondtrader-0.49.0.dist-info}/METADATA +9 -2
  32. onesecondtrader-0.49.0.dist-info/RECORD +34 -0
  33. {onesecondtrader-0.14.0.dist-info → onesecondtrader-0.49.0.dist-info}/WHEEL +1 -1
  34. onesecondtrader/core/__init__.py +0 -0
  35. onesecondtrader/core/models.py +0 -188
  36. onesecondtrader/core/py.typed +0 -0
  37. onesecondtrader/datafeeds/__init__.py +0 -0
  38. onesecondtrader/datafeeds/base_datafeed.py +0 -54
  39. onesecondtrader/datafeeds/csv_datafeed.py +0 -297
  40. onesecondtrader/indicators/base_indicator.py +0 -136
  41. onesecondtrader/messaging/__init__.py +0 -9
  42. onesecondtrader/messaging/eventbus.py +0 -499
  43. onesecondtrader/messaging/events.py +0 -800
  44. onesecondtrader/monitoring/__init__.py +0 -0
  45. onesecondtrader/monitoring/console.py +0 -14
  46. onesecondtrader/monitoring/py.typed +0 -0
  47. onesecondtrader/py.typed +0 -0
  48. onesecondtrader-0.14.0.dist-info/RECORD +0 -21
  49. {onesecondtrader-0.14.0.dist-info → onesecondtrader-0.49.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,142 @@
1
+ from __future__ import annotations
2
+
3
+ import abc
4
+ import collections
5
+ import threading
6
+
7
+ import numpy as np
8
+
9
+ from onesecondtrader import events
10
+
11
+
12
+ class IndicatorBase(abc.ABC):
13
+ """
14
+ Base class for scalar technical indicators with per-symbol history.
15
+
16
+ The class provides a thread-safe mechanism for storing and retrieving indicator values computed from incoming market bars, keyed by symbol.
17
+ It does not manage input windows or rolling computation state.
18
+
19
+ Subclasses define a stable indicator identifier via the `name` property and implement `_compute_indicator`, which computes a single scalar value per incoming bar.
20
+ Indicators with multiple conceptual outputs must be implemented as multiple single-output indicators (e.g. Bollinger Bands must be implemented via three separate indicators `BBUpper`, `BBMiddle`, and `BBLower`).
21
+
22
+ The update mechanism is thread-safe.
23
+ Indicator computation is performed outside the internal lock.
24
+ Subclasses that maintain internal state are responsible for ensuring its thread safety and must not access `_history_data`.
25
+
26
+ Indicator values are stored per symbol in bounded FIFO buffers.
27
+ Missing data and out-of-bounds access yield `numpy.nan`.
28
+
29
+ The `plot_at` attribute is an opaque identifier forwarded to the charting backend and has no intrinsic meaning within the indicator subsystem.
30
+ """
31
+
32
+ def __init__(self, max_history: int = 100, plot_at: int = 99) -> None:
33
+ """
34
+ Parameters:
35
+ max_history:
36
+ Maximum number of indicator values retained per symbol.
37
+ Cannot be less than 1.
38
+ plot_at:
39
+ Opaque plotting identifier forwarded to the charting backend.
40
+ """
41
+ self._lock = threading.Lock()
42
+ self._max_history = max(1, int(max_history))
43
+ self._history_data: dict[str, collections.deque[float]] = {}
44
+ self._plot_at = plot_at
45
+
46
+ @property
47
+ @abc.abstractmethod
48
+ def name(self) -> str:
49
+ """
50
+ Canonical indicator name.
51
+
52
+ Returns:
53
+ Stable identifier used for charting and downstream integration.
54
+ """
55
+ pass
56
+
57
+ @abc.abstractmethod
58
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
59
+ """
60
+ Compute the indicator value for a single market bar.
61
+
62
+ This method is executed outside the internal lock.
63
+ Implementations must not access `_history_data` and must ensure thread safety of any internal computation state.
64
+
65
+ Parameters:
66
+ incoming_bar:
67
+ Market bar used as input for indicator computation.
68
+
69
+ Returns:
70
+ Computed indicator value.
71
+ """
72
+ pass
73
+
74
+ def update(self, incoming_bar: events.market.BarReceived) -> None:
75
+ """
76
+ Update the indicator with a new market bar.
77
+
78
+ The computed value is appended to the per-symbol history buffer.
79
+
80
+ Parameters:
81
+ incoming_bar:
82
+ Market bar triggering the update.
83
+ """
84
+ symbol = incoming_bar.symbol
85
+
86
+ value = self._compute_indicator(incoming_bar)
87
+
88
+ with self._lock:
89
+ if symbol not in self._history_data:
90
+ self._history_data[symbol] = collections.deque(maxlen=self._max_history)
91
+
92
+ self._history_data[symbol].append(value)
93
+
94
+ def latest(self, symbol: str) -> float:
95
+ """
96
+ Return the most recent indicator value for a symbol.
97
+
98
+ Parameters:
99
+ symbol:
100
+ Symbol identifier.
101
+
102
+ Returns:
103
+ Most recent value, or `numpy.nan` if unavailable.
104
+ """
105
+ return self[symbol, -1]
106
+
107
+ def __getitem__(self, key: tuple[str, int]) -> float:
108
+ """
109
+ Retrieve an indicator value by symbol and index.
110
+
111
+ Indexing follows standard Python sequence semantics.
112
+ Negative indices refer to positions relative to the most recent value.
113
+
114
+ Parameters:
115
+ key:
116
+ `(symbol, index)` pair specifying the symbol and history offset.
117
+
118
+ Returns:
119
+ Indicator value at the specified position, or `numpy.nan` if unavailable.
120
+ """
121
+ symbol, index = key
122
+
123
+ with self._lock:
124
+ history = self._history_data.get(symbol)
125
+
126
+ if history is None:
127
+ return np.nan
128
+
129
+ try:
130
+ return history[index]
131
+ except IndexError:
132
+ return np.nan
133
+
134
+ @property
135
+ def plot_at(self) -> int:
136
+ """
137
+ Plotting identifier.
138
+
139
+ Returns:
140
+ Opaque identifier consumed by the charting backend.
141
+ """
142
+ return self._plot_at
@@ -0,0 +1,166 @@
1
+ from __future__ import annotations
2
+
3
+ import numpy as np
4
+
5
+ from onesecondtrader import events, indicators
6
+
7
+
8
+ class Open(indicators.IndicatorBase):
9
+ """
10
+ Open price indicator.
11
+
12
+ This indicator exposes the open price of each incoming market bar as a scalar time series.
13
+ Values are stored per symbol and can be accessed historically via the indicator interface.
14
+ """
15
+
16
+ @property
17
+ def name(self) -> str:
18
+ """
19
+ Canonical indicator name.
20
+
21
+ Returns:
22
+ Fixed identifier for the open price indicator.
23
+ """
24
+ return "OPEN"
25
+
26
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
27
+ """
28
+ Extract the open price from an incoming market bar.
29
+
30
+ Parameters:
31
+ incoming_bar:
32
+ Market bar used as input.
33
+
34
+ Returns:
35
+ Open price of the bar.
36
+ """
37
+ return incoming_bar.open
38
+
39
+
40
+ class High(indicators.IndicatorBase):
41
+ """
42
+ High price indicator.
43
+
44
+ This indicator exposes the high price of each incoming market bar as a scalar time series.
45
+ Values are stored per symbol and can be accessed historically via the indicator interface.
46
+ """
47
+
48
+ @property
49
+ def name(self) -> str:
50
+ """
51
+ Canonical indicator name.
52
+
53
+ Returns:
54
+ Fixed identifier for the high price indicator.
55
+ """
56
+ return "HIGH"
57
+
58
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
59
+ """
60
+ Extract the high price from an incoming market bar.
61
+
62
+ Parameters:
63
+ incoming_bar:
64
+ Market bar used as input.
65
+
66
+ Returns:
67
+ High price of the bar.
68
+ """
69
+ return incoming_bar.high
70
+
71
+
72
+ class Low(indicators.IndicatorBase):
73
+ """
74
+ Low price indicator.
75
+
76
+ This indicator exposes the low price of each incoming market bar as a scalar time series.
77
+ Values are stored per symbol and can be accessed historically via the indicator interface.
78
+ """
79
+
80
+ @property
81
+ def name(self) -> str:
82
+ """
83
+ Canonical indicator name.
84
+
85
+ Returns:
86
+ Fixed identifier for the low price indicator.
87
+ """
88
+ return "LOW"
89
+
90
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
91
+ """
92
+ Extract the low price from an incoming market bar.
93
+
94
+ Parameters:
95
+ incoming_bar:
96
+ Market bar used as input.
97
+
98
+ Returns:
99
+ Low price of the bar.
100
+ """
101
+ return incoming_bar.low
102
+
103
+
104
+ class Close(indicators.IndicatorBase):
105
+ """
106
+ Close price indicator.
107
+
108
+ This indicator exposes the close price of each incoming market bar as a scalar time series.
109
+ Values are stored per symbol and can be accessed historically via the indicator interface.
110
+ """
111
+
112
+ @property
113
+ def name(self) -> str:
114
+ """
115
+ Canonical indicator name.
116
+
117
+ Returns:
118
+ Fixed identifier for the close price indicator.
119
+ """
120
+ return "CLOSE"
121
+
122
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
123
+ """
124
+ Extract the close price from an incoming market bar.
125
+
126
+ Parameters:
127
+ incoming_bar:
128
+ Market bar used as input.
129
+
130
+ Returns:
131
+ Close price of the bar.
132
+ """
133
+ return incoming_bar.close
134
+
135
+
136
+ class Volume(indicators.IndicatorBase):
137
+ """
138
+ Volume indicator.
139
+
140
+ This indicator exposes the traded volume of each incoming market bar as a scalar time series.
141
+ Values are stored per symbol and can be accessed historically via the indicator interface.
142
+ Missing volume values yield `numpy.nan`.
143
+ """
144
+
145
+ @property
146
+ def name(self) -> str:
147
+ """
148
+ Canonical indicator name.
149
+
150
+ Returns:
151
+ Fixed identifier for the volume indicator.
152
+ """
153
+ return "VOLUME"
154
+
155
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
156
+ """
157
+ Extract the volume from an incoming market bar.
158
+
159
+ Parameters:
160
+ incoming_bar:
161
+ Market bar used as input.
162
+
163
+ Returns:
164
+ Volume of the bar, or `numpy.nan` if unavailable.
165
+ """
166
+ return float(incoming_bar.volume) if incoming_bar.volume is not None else np.nan
@@ -1,132 +1,104 @@
1
- """
2
- This module provides various moving average indicators.
3
- """
1
+ from __future__ import annotations
4
2
 
5
- import numpy as np
6
3
  import collections
7
- from onesecondtrader.indicators import base_indicator
8
- from onesecondtrader.core import models
9
- from onesecondtrader.monitoring import console
4
+ import numpy as np
5
+
6
+ from onesecondtrader import events, indicators, models
10
7
 
11
8
 
12
- class SimpleMovingAverage(base_indicator.BaseIndicator):
9
+ class SimpleMovingAverage(indicators.IndicatorBase):
13
10
  """
14
- Simple Moving Average (SMA) indicator for different OHLC-data related time series,
15
- the possible modes for the SMA calculation are indicated in the
16
- `core.models.XMAMode` enum (currently: `open`, `high`, `low`, `close`,
17
- `typical_price`, `weighted close`).
18
-
19
- Examples:
20
- >>> from onesecondtrader.indicators import moving_averages
21
- >>> from onesecondtrader.core import models
22
- >>> sma = moving_averages.SimpleMovingAverage(
23
- ... period=3, mode=models.XMAMode.CLOSE
24
- ... )
25
- >>> bar1 = models.Bar(
26
- ... open=100.0, high=101.0, low=99.0, close=100.0, volume=1000
27
- ... )
28
- >>> sma.update(bar1)
29
- >>> import numpy as np
30
- >>> np.isnan(sma.latest)
31
- True
32
- >>> bar2 = models.Bar(
33
- ... open=100.0, high=102.0, low=100.0, close=101.0, volume=1500
34
- ... )
35
- >>> sma.update(bar2)
36
- >>> np.isnan(sma.latest)
37
- True
38
- >>> bar3 = models.Bar(
39
- ... open=101.0, high=103.0, low=101.0, close=102.0, volume=2000
40
- ... )
41
- >>> sma.update(bar3)
42
- >>> np.isnan(sma.latest)
43
- False
44
- >>> sma.latest
45
- 101.0
11
+ Simple Moving Average (SMA) indicator.
12
+
13
+ This indicator computes the arithmetic mean of a selected bar field over a fixed rolling window.
14
+ One scalar value is produced per incoming bar and stored per symbol.
15
+
16
+ The rolling window is maintained independently for each symbol.
17
+ Until the window is fully populated, the indicator yields `numpy.nan`.
46
18
  """
47
19
 
48
20
  def __init__(
49
21
  self,
50
- period: int,
51
- mode: models.XMAMode = models.XMAMode.CLOSE,
22
+ period: int = 200,
52
23
  max_history: int = 100,
24
+ bar_field: models.BarField = models.BarField.CLOSE,
25
+ plot_at: int = 0,
53
26
  ) -> None:
54
27
  """
55
- Initialize the indicator with a period and a mode.
56
-
57
- Args:
58
- period (int): Period of the moving average. Will be set to 1 if < 1.
59
- mode (models.XMAMode): Mode of the moving average. Defaults to `CLOSE`.
60
- max_history (int): Maximum lookback history length. Defaults to 100.
61
-
62
- Attributes:
63
- self.period (int): Period of the moving average.
64
- self.mode (models.XMAMode): Mode of the moving average.
28
+ Parameters:
29
+ period:
30
+ Window size used to compute the moving average.
31
+ max_history:
32
+ Maximum number of computed indicator values retained per symbol.
33
+ bar_field:
34
+ Bar field used as the input series.
35
+ plot_at:
36
+ Opaque plotting identifier forwarded to the charting backend.
65
37
  """
66
- if period < 1:
67
- console.logger.warning(
68
- f"Period must be >= 1, got {period}; defaulting to 1"
69
- )
70
- period = 1
38
+ super().__init__(max_history=max_history, plot_at=plot_at)
71
39
 
72
- super().__init__(max_history=max_history)
73
- self.period: int = period
74
- self.mode: models.XMAMode = mode
75
- self._window: collections.deque[float] = collections.deque(maxlen=self.period)
40
+ self.period: int = max(1, int(period))
41
+ self.bar_field: models.BarField = bar_field
42
+ self._window: dict[str, collections.deque[float]] = {}
76
43
 
77
44
  @property
78
45
  def name(self) -> str:
79
- return f"SMA_{self.period}_{self.mode.name}"
46
+ """
47
+ Canonical indicator name.
48
+
49
+ Returns:
50
+ Identifier encoding the indicator type, period, and bar field.
51
+ """
52
+ return f"SMA_{self.period}_{self.bar_field.name}"
80
53
 
81
- def _compute_indicator(self, incoming_bar: models.Bar) -> float:
54
+ def _compute_indicator(self, incoming_bar: events.market.BarReceived) -> float:
82
55
  """
83
- Compute the specified simple moving average based on the incoming bar.
56
+ Compute the simple moving average for a single received bar.
84
57
 
85
- Args:
86
- incoming_bar (models.Bar): Incoming bar with OHLCV data.
58
+ Parameters:
59
+ incoming_bar:
60
+ Market bar used as input for the computation.
87
61
 
88
62
  Returns:
89
- float: Simple moving average value, or np.nan if insufficient data or
90
- errors occur.
63
+ Simple moving average value, or `numpy.nan` if the rolling window is not yet fully populated.
91
64
  """
92
- try:
93
- mode = self.mode
94
- if mode is models.XMAMode.OPEN:
95
- current_value = incoming_bar.open
96
- elif mode is models.XMAMode.HIGH:
97
- current_value = incoming_bar.high
98
- elif mode is models.XMAMode.LOW:
99
- current_value = incoming_bar.low
100
- elif mode is models.XMAMode.CLOSE:
101
- current_value = incoming_bar.close
102
- elif mode is models.XMAMode.TYPICAL_PRICE:
103
- current_value = (
104
- incoming_bar.high + incoming_bar.low + incoming_bar.close
105
- ) / 3.0
106
- elif mode is models.XMAMode.WEIGHTED_CLOSE:
107
- current_value = (
108
- incoming_bar.high + incoming_bar.low + 2.0 * incoming_bar.close
109
- ) / 4.0
110
- else:
111
- console.logger.warning(
112
- f"Unsupported XMAMode: {mode}; using close price"
113
- )
114
- current_value = incoming_bar.close
115
-
116
- if not np.isfinite(current_value):
117
- console.logger.warning(
118
- f"Invalid value extracted: {current_value} (mode={mode.name}); "
119
- f"using np.nan"
120
- )
121
- return np.nan
65
+ symbol = incoming_bar.symbol
66
+ if symbol not in self._window:
67
+ self._window[symbol] = collections.deque(maxlen=self.period)
122
68
 
123
- with self._lock:
124
- self._window.append(current_value)
125
- if len(self._window) < self.period:
126
- return np.nan
127
- sma_value = sum(self._window) / self.period
128
- return sma_value
69
+ window = self._window[symbol]
70
+ value = self._extract_field(incoming_bar)
71
+ window.append(value)
129
72
 
130
- except Exception as e:
131
- console.logger.warning(f"SMA calculation failed: {e}; returning np.nan")
73
+ if len(window) < self.period:
132
74
  return np.nan
75
+ return sum(window) / self.period
76
+
77
+ def _extract_field(self, incoming_bar: events.market.BarReceived) -> float:
78
+ """
79
+ Extract the configured bar field from an incoming bar.
80
+
81
+ Parameters:
82
+ incoming_bar:
83
+ Market bar providing the input data.
84
+
85
+ Returns:
86
+ Extracted field value, or `numpy.nan` if unavailable.
87
+ """
88
+ match self.bar_field:
89
+ case models.BarField.OPEN:
90
+ return incoming_bar.open
91
+ case models.BarField.HIGH:
92
+ return incoming_bar.high
93
+ case models.BarField.LOW:
94
+ return incoming_bar.low
95
+ case models.BarField.CLOSE:
96
+ return incoming_bar.close
97
+ case models.BarField.VOLUME:
98
+ return (
99
+ float(incoming_bar.volume)
100
+ if incoming_bar.volume is not None
101
+ else np.nan
102
+ )
103
+ case _:
104
+ return incoming_bar.close
@@ -0,0 +1,23 @@
1
+ """
2
+ Defines the fundamental domain concepts used throughout the trading system.
3
+ """
4
+
5
+ from .bar_fields import BarField
6
+ from .bar_period import BarPeriod
7
+ from .order_types import OrderType
8
+ from .rejection_reasons import (
9
+ OrderRejectionReason,
10
+ CancellationRejectionReason,
11
+ ModificationRejectionReason,
12
+ )
13
+ from .trade_sides import TradeSide
14
+
15
+ __all__ = [
16
+ "BarField",
17
+ "BarPeriod",
18
+ "OrderType",
19
+ "TradeSide",
20
+ "OrderRejectionReason",
21
+ "CancellationRejectionReason",
22
+ "ModificationRejectionReason",
23
+ ]
@@ -0,0 +1,23 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class BarField(enum.Enum):
7
+ """
8
+ Enumeration of bar fields used as indicator inputs.
9
+
10
+ | Value | Semantics |
11
+ |----------|------------------------------------|
12
+ | `OPEN` | Bar's opening value. |
13
+ | `HIGH` | Bar's highest value. |
14
+ | `LOW` | Bar's lowest value. |
15
+ | `CLOSE` | Bar's closing value. |
16
+ | `VOLUME` | Bar's traded volume. |
17
+ """
18
+
19
+ OPEN = enum.auto()
20
+ HIGH = enum.auto()
21
+ LOW = enum.auto()
22
+ CLOSE = enum.auto()
23
+ VOLUME = enum.auto()
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class BarPeriod(enum.Enum):
7
+ """
8
+ Enumeration of bar aggregation periods.
9
+
10
+ | Value | Semantics |
11
+ |----------|----------------------|
12
+ | `SECOND` | Duration of 1 second.|
13
+ | `MINUTE` | Duration of 1 minute.|
14
+ | `HOUR` | Duration of 1 hour. |
15
+ | `DAY` | Duration of 1 day. |
16
+ """
17
+
18
+ SECOND = enum.auto()
19
+ MINUTE = enum.auto()
20
+ HOUR = enum.auto()
21
+ DAY = enum.auto()
@@ -0,0 +1,21 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class OrderType(enum.Enum):
7
+ """
8
+ Enumeration of order execution types.
9
+
10
+ | Value | Semantics |
11
+ |--------------|-------------------------------------------------------------|
12
+ | `LIMIT` | Executable only at the specified limit price or better. |
13
+ | `MARKET` | Executable immediately at the best available market price. |
14
+ | `STOP` | Becomes a market order once the stop price is reached. |
15
+ | `STOP_LIMIT` | Becomes a limit order once the stop price is reached. |
16
+ """
17
+
18
+ LIMIT = enum.auto()
19
+ MARKET = enum.auto()
20
+ STOP = enum.auto()
21
+ STOP_LIMIT = enum.auto()
@@ -0,0 +1,48 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class OrderRejectionReason(enum.Enum):
7
+ """
8
+ Enumeration of canonical order rejection reasons.
9
+
10
+ This enumeration defines the system-level classification of order rejection causes.
11
+ It provides a stable, broker-agnostic taxonomy for programmatic handling of rejected orders.
12
+
13
+ | Value | Semantics |
14
+ |-----------|---------------------------------------------------------------------------|
15
+ | `UNKNOWN` | The rejection reason could not be classified into a known category. |
16
+ """
17
+
18
+ UNKNOWN = enum.auto()
19
+
20
+
21
+ class ModificationRejectionReason(enum.Enum):
22
+ """
23
+ Enumeration of canonical order modification rejection reasons.
24
+
25
+ This enumeration defines the system-level classification of reasons for which an order modification request may be rejected by a broker.
26
+ It provides a stable, broker-agnostic taxonomy intended for programmatic handling and observability of modification rejections.
27
+
28
+ | Value | Semantics |
29
+ |-----------|----------------------------------------------------------------------------------|
30
+ | `UNKNOWN` | The modification rejection reason could not be classified into a known category. |
31
+ """
32
+
33
+ UNKNOWN = enum.auto()
34
+
35
+
36
+ class CancellationRejectionReason(enum.Enum):
37
+ """
38
+ Enumeration of canonical order cancellation rejection reasons.
39
+
40
+ This enumeration defines the system-level classification of reasons for which an order cancellation request may be rejected by a broker.
41
+ It provides a stable, broker-agnostic taxonomy intended for programmatic handling and observability of cancellation rejections.
42
+
43
+ | Value | Semantics |
44
+ |-----------|----------------------------------------------------------------------------------|
45
+ | `UNKNOWN` | The cancellation rejection reason could not be classified into a known category. |
46
+ """
47
+
48
+ UNKNOWN = enum.auto()
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class TradeSide(enum.Enum):
7
+ """
8
+ Enumeration of trade direction.
9
+
10
+ `TradeSide` specifies the direction of change applied to the (net) signed position
11
+ quantity from the perspective of the trading account.
12
+
13
+ | Value | Semantics |
14
+ |---------|------------------------------------------------|
15
+ | `BUY` | Increases the signed position quantity. |
16
+ | `SELL` | Decreases the signed position quantity. |
17
+ """
18
+
19
+ BUY = enum.auto()
20
+ SELL = enum.auto()