onesecondtrader 0.23.0__py3-none-any.whl → 0.25.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.
@@ -0,0 +1,33 @@
1
+ __all__ = [
2
+ "EventBase",
3
+ "MarketEvent",
4
+ "BrokerRequestEvent",
5
+ "BrokerResponseEvent",
6
+ "BarReceived",
7
+ "BarProcessed",
8
+ "OrderSubmission",
9
+ "OrderModification",
10
+ "OrderCancellation",
11
+ "OrderSubmissionAccepted",
12
+ "OrderSubmissionRejected",
13
+ "OrderModificationAccepted",
14
+ "OrderModificationRejected",
15
+ "OrderCancellationAccepted",
16
+ "OrderCancellationRejected",
17
+ "OrderFilled",
18
+ "OrderExpired",
19
+ ]
20
+
21
+ from .bases import EventBase, MarketEvent, BrokerRequestEvent, BrokerResponseEvent
22
+ from .market import BarReceived, BarProcessed
23
+ from .requests import OrderSubmission, OrderModification, OrderCancellation
24
+ from .responses import (
25
+ OrderSubmissionAccepted,
26
+ OrderSubmissionRejected,
27
+ OrderModificationAccepted,
28
+ OrderModificationRejected,
29
+ OrderCancellationAccepted,
30
+ OrderCancellationRejected,
31
+ OrderFilled,
32
+ OrderExpired,
33
+ )
@@ -0,0 +1,29 @@
1
+ from __future__ import annotations
2
+
3
+ import dataclasses
4
+ import pandas as pd
5
+ import uuid
6
+
7
+
8
+ @dataclasses.dataclass(kw_only=True, frozen=True)
9
+ class EventBase:
10
+ ts_event: pd.Timestamp
11
+ ts_created: pd.Timestamp = dataclasses.field(
12
+ default_factory=lambda: pd.Timestamp.now(tz="UTC")
13
+ )
14
+
15
+
16
+ @dataclasses.dataclass(kw_only=True, frozen=True)
17
+ class MarketEvent(EventBase):
18
+ pass
19
+
20
+
21
+ @dataclasses.dataclass(kw_only=True, frozen=True)
22
+ class BrokerRequestEvent(EventBase):
23
+ system_order_id: uuid.UUID
24
+
25
+
26
+ @dataclasses.dataclass(kw_only=True, frozen=True)
27
+ class BrokerResponseEvent(EventBase):
28
+ ts_broker: pd.Timestamp
29
+ associated_order_id: uuid.UUID
@@ -0,0 +1,22 @@
1
+ from __future__ import annotations
2
+
3
+ import dataclasses
4
+
5
+ from onesecondtrader import models
6
+ from . import bases
7
+
8
+
9
+ @dataclasses.dataclass(kw_only=True, frozen=True)
10
+ class BarReceived(bases.MarketEvent):
11
+ symbol: str
12
+ bar_period: models.data.BarPeriod
13
+ open: float
14
+ high: float
15
+ low: float
16
+ close: float
17
+ volume: int | None = None
18
+
19
+
20
+ @dataclasses.dataclass(kw_only=True, frozen=True)
21
+ class BarProcessed(BarReceived):
22
+ indicators: dict[str, float] = dataclasses.field(default_factory=dict)
@@ -0,0 +1,31 @@
1
+ from __future__ import annotations
2
+
3
+ import dataclasses
4
+ import uuid
5
+
6
+ from onesecondtrader import models
7
+ from . import bases
8
+
9
+
10
+ @dataclasses.dataclass(kw_only=True, frozen=True)
11
+ class OrderSubmission(bases.BrokerRequestEvent):
12
+ system_order_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
13
+ symbol: str
14
+ order_type: models.orders.OrderType
15
+ side: models.orders.OrderSide
16
+ quantity: float
17
+ limit_price: float | None = None
18
+ stop_price: float | None = None
19
+
20
+
21
+ @dataclasses.dataclass(kw_only=True, frozen=True)
22
+ class OrderCancellation(bases.BrokerRequestEvent):
23
+ symbol: str
24
+
25
+
26
+ @dataclasses.dataclass(kw_only=True, frozen=True)
27
+ class OrderModification(bases.BrokerRequestEvent):
28
+ symbol: str
29
+ quantity: float | None = None
30
+ limit_price: float | None = None
31
+ stop_price: float | None = None
@@ -0,0 +1,54 @@
1
+ from __future__ import annotations
2
+
3
+ import dataclasses
4
+ import uuid
5
+
6
+ from onesecondtrader import models
7
+ from . import bases
8
+
9
+
10
+ @dataclasses.dataclass(kw_only=True, frozen=True)
11
+ class OrderSubmissionAccepted(bases.BrokerResponseEvent):
12
+ broker_order_id: str | None = None
13
+
14
+
15
+ @dataclasses.dataclass(kw_only=True, frozen=True)
16
+ class OrderSubmissionRejected(bases.BrokerResponseEvent):
17
+ reason: str | None = None
18
+
19
+
20
+ @dataclasses.dataclass(kw_only=True, frozen=True)
21
+ class OrderModificationAccepted(bases.BrokerResponseEvent):
22
+ broker_order_id: str | None = None
23
+
24
+
25
+ @dataclasses.dataclass(kw_only=True, frozen=True)
26
+ class OrderModificationRejected(bases.BrokerResponseEvent):
27
+ reason: str | None = None
28
+
29
+
30
+ @dataclasses.dataclass(kw_only=True, frozen=True)
31
+ class OrderCancellationAccepted(bases.BrokerResponseEvent):
32
+ pass
33
+
34
+
35
+ @dataclasses.dataclass(kw_only=True, frozen=True)
36
+ class OrderCancellationRejected(bases.BrokerResponseEvent):
37
+ reason: str | None = None
38
+
39
+
40
+ @dataclasses.dataclass(kw_only=True, frozen=True)
41
+ class OrderFilled(bases.BrokerResponseEvent):
42
+ fill_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
43
+ broker_fill_id: str | None = None
44
+ symbol: str
45
+ side: models.orders.OrderSide
46
+ quantity_filled: float
47
+ fill_price: float
48
+ commission: float
49
+ exchange: str = "SIMULATED"
50
+
51
+
52
+ @dataclasses.dataclass(kw_only=True, frozen=True)
53
+ class OrderExpired(bases.BrokerResponseEvent):
54
+ pass
@@ -0,0 +1,7 @@
1
+ __all__ = [
2
+ "EventBus",
3
+ "EventSubscriberLike",
4
+ ]
5
+
6
+ from .eventbus import EventBus
7
+ from .contracts import EventSubscriberLike
@@ -0,0 +1,11 @@
1
+ from __future__ import annotations
2
+
3
+ import typing
4
+
5
+ from onesecondtrader import events
6
+
7
+
8
+ @typing.runtime_checkable
9
+ class EventSubscriberLike(typing.Protocol):
10
+ def receive(self, event: events.bases.EventBase) -> None: ...
11
+ def wait_until_idle(self) -> None: ...
@@ -0,0 +1,43 @@
1
+ from __future__ import annotations
2
+
3
+ import collections
4
+ import threading
5
+
6
+ from onesecondtrader import events
7
+ from . import contracts
8
+
9
+
10
+ class EventBus:
11
+ def __init__(self) -> None:
12
+ self._per_event_subscriptions: collections.defaultdict[
13
+ type[events.bases.EventBase], set[contracts.EventSubscriberLike]
14
+ ] = collections.defaultdict(set)
15
+ self._subscribers: set[contracts.EventSubscriberLike] = set()
16
+ self._lock: threading.Lock = threading.Lock()
17
+
18
+ def subscribe(
19
+ self,
20
+ subscriber: contracts.EventSubscriberLike,
21
+ event_type: type[events.bases.EventBase],
22
+ ) -> None:
23
+ with self._lock:
24
+ self._subscribers.add(subscriber)
25
+ self._per_event_subscriptions[event_type].add(subscriber)
26
+
27
+ def unsubscribe(self, subscriber: contracts.EventSubscriberLike) -> None:
28
+ with self._lock:
29
+ for set_of_event_subscribers in self._per_event_subscriptions.values():
30
+ set_of_event_subscribers.discard(subscriber)
31
+ self._subscribers.discard(subscriber)
32
+
33
+ def publish(self, event: events.bases.EventBase) -> None:
34
+ with self._lock:
35
+ subscribers = self._per_event_subscriptions[type(event)].copy()
36
+ for subscriber in subscribers:
37
+ subscriber.receive(event)
38
+
39
+ def wait_until_system_idle(self) -> None:
40
+ with self._lock:
41
+ subscribers = self._subscribers.copy()
42
+ for subscriber in subscribers:
43
+ subscriber.wait_until_idle()
@@ -0,0 +1,8 @@
1
+ __all__ = [
2
+ "BarPeriod",
3
+ "OrderSide",
4
+ "OrderType",
5
+ ]
6
+
7
+ from .data import BarPeriod
8
+ from .orders import OrderSide, OrderType
@@ -0,0 +1,10 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class BarPeriod(enum.Enum):
7
+ SECOND = enum.auto()
8
+ MINUTE = enum.auto()
9
+ HOUR = enum.auto()
10
+ DAY = enum.auto()
@@ -0,0 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ import enum
4
+
5
+
6
+ class OrderType(enum.Enum):
7
+ LIMIT = enum.auto()
8
+ MARKET = enum.auto()
9
+ STOP = enum.auto()
10
+ STOP_LIMIT = enum.auto()
11
+
12
+
13
+ class OrderSide(enum.Enum):
14
+ BUY = enum.auto()
15
+ SELL = enum.auto()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onesecondtrader
3
- Version: 0.23.0
3
+ Version: 0.25.0
4
4
  Summary: The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place.
5
5
  License-File: LICENSE
6
6
  Author: Nils P. Kujath
@@ -0,0 +1,16 @@
1
+ onesecondtrader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ onesecondtrader/events/__init__.py,sha256=IOlFRdiOXz93SpvkpKL8wr1954d_8olKSB1n9mlTL3Y,898
3
+ onesecondtrader/events/bases.py,sha256=g-ykq2jgcitIAueRurUlqAq0jINQwuhSWi_khAniPHw,662
4
+ onesecondtrader/events/market.py,sha256=IfHuIGfp_IUiw-dFay4c4RYmkoNzshxbhuWTglBqfN0,509
5
+ onesecondtrader/events/requests.py,sha256=2KXwSckiar9-fy8wkN3vcSIeOkeBfeo_XhUhrNKEd2Q,831
6
+ onesecondtrader/events/responses.py,sha256=w_BH1nkkPyxQjh30EXEVFcUGDoMprFc2PuAaqpVrQ8A,1436
7
+ onesecondtrader/messaging/__init__.py,sha256=9yLobI20ZmqipPHG_pwVgdGOEoj-sIAdGWhH17MKSu4,132
8
+ onesecondtrader/messaging/contracts.py,sha256=_LCDtwqgCqNZ5Js1Ht5iFvqNqZUMzi83RVeJgXpTeno,267
9
+ onesecondtrader/messaging/eventbus.py,sha256=J36tmuemRjDATHikSSzL3-7Kmx5fu_sX09X7tb94IF0,1522
10
+ onesecondtrader/models/__init__.py,sha256=cH5xyniz78MQjM9_-fFdP1ZW6FFLTmayMwQauFO23bU,135
11
+ onesecondtrader/models/data.py,sha256=TqUvTtjpmzTJT8ZdTYnlVoyI7Qck2IsseCazWZxJgD0,173
12
+ onesecondtrader/models/orders.py,sha256=y6Ar-6fMqaOd_hRnRGvfWUF0Z13H_2hfTOW3ROOk0A8,254
13
+ onesecondtrader-0.25.0.dist-info/METADATA,sha256=eWtsWhZOEqTGaEubNmJhXnWFtYxSfhYwJheci2HAwkI,9682
14
+ onesecondtrader-0.25.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
15
+ onesecondtrader-0.25.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
16
+ onesecondtrader-0.25.0.dist-info/RECORD,,
File without changes
@@ -1,119 +0,0 @@
1
- """
2
- Read first: [`events.py`](./events.md), [`eventbus.py`](./eventbus.md).
3
-
4
- ---
5
- This module defines the `Component` class.
6
-
7
- In an event-driven system, components interact exclusively via event messages.
8
- The `Component` class is an abstract base class that defines a common interface for
9
- publishing and receiving such messages and is intended to be subclassed by all system
10
- components.
11
- ---
12
- """
13
-
14
- import abc
15
- import queue
16
- import threading
17
-
18
- from .events import Event
19
- from .eventbus import EventBus
20
-
21
-
22
- class Component(abc.ABC):
23
- """
24
- Abstract base class for all system components.
25
-
26
- Incoming events are delivered via `receive()` and stored in an internal queue.
27
- A dedicated thread runs an event loop that consumes queued events and dispatches
28
- them to `_process()`, which subclasses must implement.
29
- For publication, `publish()` forwards events to the event bus.
30
- The `join_queue()` method is used by the event bus to block until all queued events
31
- have been processed, which is useful for deterministic, stepwise execution in
32
- backtesting.
33
- """
34
-
35
- def __init__(self, eventbus: EventBus) -> None:
36
- """
37
- Initialize the component and start its event-loop thread.
38
-
39
- Stores a reference to the event bus, creates an internal queue for incoming
40
- events, and starts a non-daemon thread for the event loop that runs until
41
- shutdown.
42
- """
43
- self._event_bus = eventbus
44
- self._incoming_event_queue: queue.Queue[Event | None] = queue.Queue()
45
- self._thread: threading.Thread = threading.Thread(
46
- target=self._event_loop,
47
- name=self.__class__.__name__,
48
- daemon=False,
49
- )
50
- self._thread.start()
51
-
52
- def publish(self, event: Event) -> None:
53
- """
54
- Wrapper for the event bus's `publish()` method.
55
-
56
- For convenience, this method can be used by subclasses to publish events via the
57
- event bus's publication mechanism.
58
- """
59
- self._event_bus.publish(event)
60
-
61
- def receive(self, event: Event) -> None:
62
- """
63
- Store incoming events in the component's queue.
64
-
65
- This method is typically called by the event bus when an event is published that
66
- the component has subscribed to.
67
- It simply puts the event in the queue for processing by the subscribed
68
- component.
69
- """
70
- self._incoming_event_queue.put(event)
71
-
72
- def join_queue(self) -> None:
73
- """
74
- Block until all queued events have been processed.
75
-
76
- This method is used by the event bus to block until all queued events have been
77
- processed.
78
- This is useful for deterministic, stepwise execution in backtesting.
79
- """
80
- self._incoming_event_queue.join()
81
-
82
- def _event_loop(self) -> None:
83
- """
84
- Event-processing loop executed in the component’s dedicated thread.
85
-
86
- The loop continuously retrieves events from the `incoming_event_queue`,
87
- processes each event via `_process()`, and signals completion with
88
- `task_done()`.
89
- Execution terminates upon receipt of a `None` sentinel, at which point
90
- `_shutdown()` is invoked before exiting the thread to ensure proper cleanup.
91
- """
92
- while True:
93
- incoming_event = self._incoming_event_queue.get()
94
- if incoming_event is None:
95
- self._shutdown()
96
- self._incoming_event_queue.task_done()
97
- break
98
- self._process(incoming_event)
99
- self._incoming_event_queue.task_done()
100
-
101
- @abc.abstractmethod
102
- def _process(self, event: Event) -> None:
103
- """
104
- Process a single event.
105
-
106
- This method is invoked by the event loop for each incoming event.
107
- Subclasses must implement it to define event-handling behavior.
108
- """
109
- pass
110
-
111
- def _shutdown(self) -> None:
112
- """
113
- Perform cleanup when the component is shutting down.
114
-
115
- Called by `_event_loop()` when a `None` sentinel is received.
116
- Subclasses may override this method to perform cleanup tasks such as closing
117
- files or connections before the thread exits.
118
- """
119
- pass
@@ -1,85 +0,0 @@
1
- """
2
- Read first: [`events.py`](./events.md), [`component.py`](./component.md).
3
-
4
- ---
5
- This module defines the `EventBus` class.
6
-
7
- The event bus provides a publish–subscribe mechanism for event-driven systems.
8
- It maintains subscriptions between event types and components and delivers
9
- published events to all subscribed components in a thread-safe manner.
10
- ---
11
- """
12
-
13
- import collections
14
- import threading
15
-
16
- from .component import Component
17
- from .events import Event
18
-
19
-
20
- class EventBus:
21
- """
22
- Central event-dispatch mechanism for the system.
23
-
24
- The event bus manages subscriptions between event types and components and
25
- forwards published events to all subscribed components.
26
- """
27
-
28
- def __init__(self) -> None:
29
- """
30
- Initialize the event bus.
31
-
32
- Sets up internal data structures for managing subscriptions and registered
33
- components and initializes a lock to ensure thread-safe access.
34
- """
35
- self._subscriptions: collections.defaultdict[type[Event], set[Component]] = (
36
- collections.defaultdict(set)
37
- )
38
- self._components: set[Component] = set()
39
- self._lock: threading.Lock = threading.Lock()
40
-
41
- def subscribe(self, subscriber: Component, *event_types: type[Event]) -> None:
42
- """
43
- Subscribe a component to one or more event types.
44
-
45
- The subscriber will receive all future events whose type matches one of the
46
- specified event types.
47
- """
48
- with self._lock:
49
- self._components.add(subscriber)
50
- for event_type in event_types:
51
- self._subscriptions[event_type].add(subscriber)
52
-
53
- def unsubscribe(self, subscriber: Component) -> None:
54
- """
55
- Remove a component from all event subscriptions.
56
-
57
- After unsubscription, the component will no longer receive published events.
58
- """
59
- with self._lock:
60
- for component_set in self._subscriptions.values():
61
- component_set.discard(subscriber)
62
- self._components.discard(subscriber)
63
-
64
- def publish(self, event: Event) -> None:
65
- """
66
- Publish an event to all subscribed components.
67
-
68
- The event is delivered to each subscriber by invoking its `receive()` method.
69
- """
70
- with self._lock:
71
- components = self._subscriptions[type(event)].copy()
72
- for component in components:
73
- component.receive(event)
74
-
75
- def wait_until_idle(self) -> None:
76
- """
77
- Block until all components have processed their queued events.
78
-
79
- This method is primarily used in backtesting to enforce deterministic,
80
- system-wide synchronization.
81
- """
82
- with self._lock:
83
- components = self._components.copy()
84
- for component in components:
85
- component.join_queue()
@@ -1,224 +0,0 @@
1
- """
2
- Read first: [`models.py`](./models.md).
3
-
4
- ---
5
- This module provides all event message classes used in the system.
6
-
7
- In an event-driven system, components communicate by sending event messages to each
8
- other. An event message is an immutable object that contains all information relevant
9
- to a specific occurrence, such as incoming market data, order submissions, fills, or
10
- other domain-specific events.
11
- ---
12
- """
13
-
14
- import dataclasses
15
- import uuid
16
-
17
- import pandas as pd
18
-
19
- from .models import BarPeriod, OrderType, OrderSide
20
-
21
-
22
- @dataclasses.dataclass(kw_only=True, frozen=True)
23
- class Event:
24
- """
25
- Base class for all event messages in the system.
26
-
27
- All events include a timestamp indicating when the event was created or received.
28
- Subclasses define specific event types with additional fields relevant to that
29
- event.
30
- """
31
-
32
- ts_event: pd.Timestamp = dataclasses.field(
33
- default_factory=lambda: pd.Timestamp.now(tz="UTC")
34
- )
35
-
36
-
37
- @dataclasses.dataclass(kw_only=True, frozen=True)
38
- class ReceivedNewBar(Event):
39
- """
40
- Event indicating a new bar of market data has been received.
41
-
42
- Contains OHLCV data for a specific symbol and bar period. This event is typically
43
- emitted by data feed components when new market data arrives.
44
- """
45
-
46
- ts_event: pd.Timestamp
47
- symbol: str
48
- bar_period: BarPeriod
49
- open: float
50
- high: float
51
- low: float
52
- close: float
53
- volume: int | None = None
54
-
55
-
56
- @dataclasses.dataclass(kw_only=True, frozen=True)
57
- class ProcessedBar(Event):
58
- """
59
- Event indicating a bar has been processed and enriched with indicator values.
60
-
61
- Contains the same OHLCV data as ReceivedNewBar, plus a dictionary of computed
62
- indicator values. This event is typically emitted after strategies or other
63
- components have calculated technical indicators for the bar.
64
- """
65
-
66
- ts_event: pd.Timestamp
67
- symbol: str
68
- bar_period: BarPeriod
69
- open: float
70
- high: float
71
- low: float
72
- close: float
73
- volume: int | None = None
74
- indicators: dict[str, float] = dataclasses.field(default_factory=dict)
75
-
76
-
77
- @dataclasses.dataclass(kw_only=True, frozen=True)
78
- class RequestOrderSubmission(Event):
79
- """
80
- Event requesting submission of a new order with the broker.
81
-
82
- Contains all parameters needed to submit an order, including symbol, order type,
83
- side, quantity, and optional limit/stop prices. A unique order_id is automatically
84
- generated if not provided.
85
- """
86
-
87
- order_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
88
- symbol: str
89
- order_type: OrderType
90
- side: OrderSide
91
- quantity: float
92
- limit_price: float | None = None
93
- stop_price: float | None = None
94
-
95
-
96
- @dataclasses.dataclass(kw_only=True, frozen=True)
97
- class RequestOrderModification(Event):
98
- """
99
- Event requesting modification of an existing order.
100
-
101
- Identifies the order to modify by order_id and symbol. Any of quantity, limit_price,
102
- or stop_price can be updated by providing new values.
103
- """
104
-
105
- symbol: str
106
- order_id: uuid.UUID
107
- quantity: float | None = None
108
- limit_price: float | None = None
109
- stop_price: float | None = None
110
-
111
-
112
- @dataclasses.dataclass(kw_only=True, frozen=True)
113
- class RequestOrderCancellation(Event):
114
- """
115
- Event requesting cancellation of an existing order.
116
-
117
- Identifies the order to cancel by order_id and symbol.
118
- """
119
-
120
- symbol: str
121
- order_id: uuid.UUID
122
-
123
-
124
- @dataclasses.dataclass(kw_only=True, frozen=True)
125
- class AcceptedOrderSubmission(Event):
126
- """
127
- Event indicating the broker has accepted an order submission.
128
-
129
- Contains the system's order_id and optionally the broker's order_id if provided
130
- by the broker.
131
- """
132
-
133
- order_id: uuid.UUID
134
- broker_order_id: str | None = None
135
-
136
-
137
- @dataclasses.dataclass(kw_only=True, frozen=True)
138
- class AcceptedOrderModification(Event):
139
- """
140
- Event indicating the broker has accepted an order modification.
141
-
142
- Contains the system's order_id and optionally the broker's order_id if provided
143
- by the broker.
144
- """
145
-
146
- order_id: uuid.UUID
147
- broker_order_id: str | None = None
148
-
149
-
150
- @dataclasses.dataclass(kw_only=True, frozen=True)
151
- class AcceptedOrderCancellation(Event):
152
- """
153
- Event indicating the broker has accepted an order cancellation.
154
-
155
- Contains the system's order_id for the cancelled order.
156
- """
157
-
158
- order_id: uuid.UUID
159
-
160
-
161
- @dataclasses.dataclass(kw_only=True, frozen=True)
162
- class RejectedOrderSubmission(Event):
163
- """
164
- Event indicating the broker has rejected an order submission.
165
-
166
- Contains the system's order_id for the rejected order.
167
- """
168
-
169
- order_id: uuid.UUID
170
-
171
-
172
- @dataclasses.dataclass(kw_only=True, frozen=True)
173
- class RejectedOrderModification(Event):
174
- """
175
- Event indicating the broker has rejected an order modification.
176
-
177
- Contains the system's order_id for the order that could not be modified.
178
- """
179
-
180
- order_id: uuid.UUID
181
-
182
-
183
- @dataclasses.dataclass(kw_only=True, frozen=True)
184
- class RejectedOrderCancellation(Event):
185
- """
186
- Event indicating the broker has rejected an order cancellation.
187
-
188
- Contains the system's order_id for the order that could not be cancelled.
189
- """
190
-
191
- order_id: uuid.UUID
192
-
193
-
194
- @dataclasses.dataclass(kw_only=True, frozen=True)
195
- class OrderFilled(Event):
196
- """
197
- Event indicating an order has been filled (fully or partially).
198
-
199
- Contains details about the fill including quantity, price, commission, and the
200
- associated order. A unique fill_id is automatically generated if not provided.
201
- The broker may optionally provide a broker_fill_id.
202
- """
203
-
204
- fill_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
205
- broker_fill_id: str | None = None
206
- associated_order_id: uuid.UUID
207
- symbol: str
208
- side: OrderSide
209
- quantity_filled: float
210
- fill_price: float
211
- commission: float
212
- exchange: str = "SIMULATED"
213
-
214
-
215
- @dataclasses.dataclass(kw_only=True, frozen=True)
216
- class OrderExpired(Event):
217
- """
218
- Event indicating an order has expired without being filled.
219
-
220
- Contains the system's order_id for the expired order. This typically occurs for
221
- time-limited orders that were not filled before their expiration time.
222
- """
223
-
224
- order_id: uuid.UUID
@@ -1,70 +0,0 @@
1
- """
2
- ---
3
- This module provides core domain models used throughout the system.
4
-
5
- Domain models are enumerations that define the vocabulary and valid values for key
6
- concepts in the trading system. These models are used across all components to ensure
7
- type safety and consistency when representing domain-specific concepts.
8
- ---
9
- """
10
-
11
- import enum
12
-
13
-
14
- class BarPeriod(enum.Enum):
15
- """
16
- Time period for aggregating market data into bars.
17
-
18
- Defines the standard time intervals used for OHLCV bar data.
19
- Each bar represents market activity aggregated over the specified period.
20
- """
21
-
22
- SECOND = 32
23
- MINUTE = 33
24
- HOUR = 34
25
- DAY = 35
26
-
27
-
28
- class OrderType(enum.Enum):
29
- """
30
- Type of order to submit to the broker.
31
-
32
- Defines the execution behavior for an order.
33
- Market orders execute immediately at current market price.
34
- Limit orders execute only at a specified price or better.
35
- Stop orders become market orders when a trigger price is reached.
36
- Stop-limit orders become limit orders when a trigger price is reached.
37
- """
38
-
39
- MARKET = enum.auto()
40
- LIMIT = enum.auto()
41
- STOP = enum.auto()
42
- STOP_LIMIT = enum.auto()
43
-
44
-
45
- class OrderSide(enum.Enum):
46
- """
47
- Direction of an order or position.
48
-
49
- Indicates whether an order is buying or selling a security.
50
- """
51
-
52
- BUY = enum.auto()
53
- SELL = enum.auto()
54
-
55
-
56
- class InputSource(enum.Enum):
57
- """
58
- Source field from bar data to use as input for indicators.
59
-
60
- Specifies which component of OHLCV bar data should be used when calculating
61
- technical indicators.
62
- For example, many indicators use CLOSE prices per default, but could also be
63
- calculated based on other fields.
64
- """
65
-
66
- OPEN = enum.auto()
67
- HIGH = enum.auto()
68
- LOW = enum.auto()
69
- CLOSE = enum.auto()
70
- VOLUME = enum.auto()
@@ -1,10 +0,0 @@
1
- onesecondtrader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- onesecondtrader/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- onesecondtrader/core/component.py,sha256=I1pO48qT6yAuSQMAbte9YubGxK1FVzv0HJ-qsIWyanU,4193
4
- onesecondtrader/core/eventbus.py,sha256=o4cQ6FR61TXdDYC3K_tdKCWYbK5UOPfHSYflNfsCANQ,2818
5
- onesecondtrader/core/events.py,sha256=tRtanpMVcBEfcl7Wcw9CLR-gd6wFf7yABajnnXVGXJM,6167
6
- onesecondtrader/core/models.py,sha256=wdp3bFlvu21o5vsEHT2Lk_3kb2Vk5N0RmgcnZXelAxo,1806
7
- onesecondtrader-0.23.0.dist-info/METADATA,sha256=LlsTFMLyQYjSY2yec848Y5cln9x4ADwxuhFUiMzttxc,9682
8
- onesecondtrader-0.23.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
9
- onesecondtrader-0.23.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
10
- onesecondtrader-0.23.0.dist-info/RECORD,,