onesecondtrader 0.45.0__tar.gz → 0.47.0__tar.gz
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.
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/PKG-INFO +1 -1
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/pyproject.toml +1 -1
- onesecondtrader-0.47.0/src/onesecondtrader/events/base.py +21 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/market/__init__.py +7 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/market/bar_processed.py +29 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/market/bar_received.py +34 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/orders/__init__.py +9 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/orders/base.py +30 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/orders/expirations.py +23 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/orders/fills.py +41 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/requests/__init__.py +11 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/requests/base.py +25 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/requests/order_cancellation.py +21 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/requests/order_modification.py +26 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/requests/order_submission.py +35 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/responses/__init__.py +14 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/responses/base.py +26 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/responses/cancellations.py +42 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/responses/modifications.py +43 -0
- onesecondtrader-0.47.0/src/onesecondtrader/events/responses/orders.py +42 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/__init__.py +23 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/bar_fields.py +23 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/bar_period.py +21 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/order_types.py +21 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/rejection_reasons.py +48 -0
- onesecondtrader-0.47.0/src/onesecondtrader/models/trade_sides.py +20 -0
- onesecondtrader-0.45.0/src/onesecondtrader/events/base.py +0 -19
- onesecondtrader-0.45.0/src/onesecondtrader/models/__init__.py +0 -10
- onesecondtrader-0.45.0/src/onesecondtrader/models/bar_fields.py +0 -23
- onesecondtrader-0.45.0/src/onesecondtrader/models/bar_period.py +0 -21
- onesecondtrader-0.45.0/src/onesecondtrader/models/order_types.py +0 -21
- onesecondtrader-0.45.0/src/onesecondtrader/models/trade_sides.py +0 -20
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/LICENSE +0 -0
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/README.md +0 -0
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/src/onesecondtrader/__init__.py +0 -0
- {onesecondtrader-0.45.0 → onesecondtrader-0.47.0}/src/onesecondtrader/events/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.47.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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "onesecondtrader"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.47.0"
|
|
4
4
|
description = "The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Nils P. Kujath",email = "63961429+NilsKujath@users.noreply.github.com"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
8
|
+
class EventBase:
|
|
9
|
+
"""
|
|
10
|
+
Base class for immutable event message objects, using Unix epoch nanoseconds.
|
|
11
|
+
|
|
12
|
+
| Field | Type | Semantics |
|
|
13
|
+
|-----------------|--------|------------------------------------------------------------------------|
|
|
14
|
+
| `ts_event_ns` | `int` | Time at which the represented fact occurred, as UTC epoch nanoseconds. |
|
|
15
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
16
|
+
|
|
17
|
+
If not provided, `ts_created_ns` is assigned automatically at object creation.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
ts_event_ns: int
|
|
21
|
+
ts_created_ns: int = dataclasses.field(default_factory=time.time_ns)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader.events.market.bar_received import BarReceived
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
9
|
+
class BarProcessed(BarReceived):
|
|
10
|
+
"""
|
|
11
|
+
Event representing a market data bar with computed indicator values.
|
|
12
|
+
|
|
13
|
+
This event extends `BarReceived` by attaching indicator values derived from the bar data.
|
|
14
|
+
|
|
15
|
+
| Field | Type | Semantics |
|
|
16
|
+
|-----------------|-------------------------|----------------------------------------------------------------------------|
|
|
17
|
+
| `ts_event_ns` | `int` | Time at which the bar was observed by the system, as UTC epoch nanoseconds.|
|
|
18
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
19
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
20
|
+
| `bar_period` | `models.data.BarPeriod` | Time interval represented by the bar. |
|
|
21
|
+
| `open` | `float` | Opening price of the bar period. |
|
|
22
|
+
| `high` | `float` | Highest traded price during the bar period. |
|
|
23
|
+
| `low` | `float` | Lowest traded price during the bar period. |
|
|
24
|
+
| `close` | `float` | Closing price of the bar period. |
|
|
25
|
+
| `volume` | `int` or `None` | Traded volume during the bar period, if available. |
|
|
26
|
+
| `indicators` | `dict[str, float]` | Mapping of indicator names to computed indicator values. |
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
indicators: dict[str, float] = dataclasses.field(default_factory=dict)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader import events, models
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
9
|
+
class BarReceived(events.EventBase):
|
|
10
|
+
"""
|
|
11
|
+
Event representing the reception of a completed market data bar.
|
|
12
|
+
|
|
13
|
+
This event represents a time-aggregated bar as received from a market data source or produced by a resampling process.
|
|
14
|
+
|
|
15
|
+
| Field | Type | Semantics |
|
|
16
|
+
|-----------------|--------------------------|-----------------------------------------------------------------------------|
|
|
17
|
+
| `ts_event_ns` | `int` | Time at which the bar was observed by the system, as UTC epoch nanoseconds. |
|
|
18
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
19
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
20
|
+
| `bar_period` | `models.data.BarPeriod` | Time interval represented by the bar. |
|
|
21
|
+
| `open` | `float` | Opening price of the bar period. |
|
|
22
|
+
| `high` | `float` | Highest traded price during the bar period. |
|
|
23
|
+
| `low` | `float` | Lowest traded price during the bar period. |
|
|
24
|
+
| `close` | `float` | Closing price of the bar period. |
|
|
25
|
+
| `volume` | `int` or `None` | Traded volume during the bar period, if available. |
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
symbol: str
|
|
29
|
+
bar_period: models.BarPeriod
|
|
30
|
+
open: float
|
|
31
|
+
high: float
|
|
32
|
+
low: float
|
|
33
|
+
close: float
|
|
34
|
+
volume: int | None = None
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
from onesecondtrader import events
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
10
|
+
class OrderBase(events.EventBase):
|
|
11
|
+
"""
|
|
12
|
+
Base class for broker-originated order events.
|
|
13
|
+
|
|
14
|
+
Order events are broker-originated facts about the state or execution of an order.
|
|
15
|
+
Each order event is correlated to a system order identifier via `associated_order_id`.
|
|
16
|
+
|
|
17
|
+
| Field | Type | Semantics |
|
|
18
|
+
|-----------------------|-----------------|---------------------------------------------------------------------------------------|
|
|
19
|
+
| `ts_event_ns` | `int` | Time at which the response event was observed by the system, as UTC epoch nanoseconds.|
|
|
20
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
21
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the response, as UTC epoch nanoseconds. |
|
|
22
|
+
| `associated_order_id` | `uuid.UUID`. | Identifier of the order associated with the broker response. |
|
|
23
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the order, if reported. |
|
|
24
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
ts_broker_ns: int
|
|
28
|
+
associated_order_id: uuid.UUID
|
|
29
|
+
broker_order_id: str | None = None
|
|
30
|
+
symbol: str
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader.events.orders.base import OrderBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
9
|
+
class OrderExpired(OrderBase):
|
|
10
|
+
"""
|
|
11
|
+
Event indicating that the order is no longer active at the venue due to expiration according to broker- or venue-specific rules (e.g. time-in-force constraints).
|
|
12
|
+
|
|
13
|
+
| Field | Type | Semantics |
|
|
14
|
+
|-----------------------|-----------------|------------------------------------------------------------------------------------|
|
|
15
|
+
| `ts_event_ns` | `int` | Time at which the expiration was observed by the system, as UTC epoch nanoseconds. |
|
|
16
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
17
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the expiration, as UTC epoch nanoseconds. |
|
|
18
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the expired order. |
|
|
19
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the expired order, if reported. |
|
|
20
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
pass
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
from onesecondtrader import models
|
|
7
|
+
from onesecondtrader.events.orders.base import OrderBase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
11
|
+
class FillEvent(OrderBase):
|
|
12
|
+
"""
|
|
13
|
+
Event representing the execution of a trade resulting in a fill.
|
|
14
|
+
|
|
15
|
+
A fill event records the execution of a quantity of an order at a specific price.
|
|
16
|
+
Multiple fill events may be associated with the same order in the case of partial execution.
|
|
17
|
+
|
|
18
|
+
| Field | Type | Semantics |
|
|
19
|
+
|-----------------------|---------------------|---------------------------------------------------------------------------------|
|
|
20
|
+
| `ts_event_ns` | `int` | Time at which the fill was observed by the system, as UTC epoch nanoseconds. |
|
|
21
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
22
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the fill, as UTC epoch nanoseconds. |
|
|
23
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the order associated with the fill. |
|
|
24
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the order associated with the fill, if available. |
|
|
25
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
26
|
+
| `fill_id` | `uuid.UUID` | System-assigned unique identifier of the fill event. |
|
|
27
|
+
| `broker_fill_id` | `str` or `None` | Broker-assigned identifier of the execution record, if available. |
|
|
28
|
+
| `side` | `models.TradeSide` | Trade direction of the executed quantity. |
|
|
29
|
+
| `quantity_filled` | `float` | Quantity executed in this fill. |
|
|
30
|
+
| `fill_price` | `float` | Execution price of the fill. |
|
|
31
|
+
| `commission` | `float` | Commission or fee associated with the fill. |
|
|
32
|
+
| `exchange` | `str` | Identifier of the execution venue. |
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
fill_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
|
|
36
|
+
broker_fill_id: str | None = None
|
|
37
|
+
side: models.TradeSide
|
|
38
|
+
quantity_filled: float
|
|
39
|
+
fill_price: float
|
|
40
|
+
commission: float
|
|
41
|
+
exchange: str = "SIMULATED"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from .base import RequestBase
|
|
2
|
+
from .order_submission import OrderSubmissionRequest
|
|
3
|
+
from .order_cancellation import OrderCancellationRequest
|
|
4
|
+
from .order_modification import OrderModificationRequest
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"RequestBase",
|
|
8
|
+
"OrderSubmissionRequest",
|
|
9
|
+
"OrderCancellationRequest",
|
|
10
|
+
"OrderModificationRequest",
|
|
11
|
+
]
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
from onesecondtrader import events
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
10
|
+
class RequestBase(events.EventBase):
|
|
11
|
+
"""
|
|
12
|
+
Base class for request events.
|
|
13
|
+
|
|
14
|
+
This class defines attributes common to all requests issued to a broker.
|
|
15
|
+
|
|
16
|
+
| Field | Type | Semantics |
|
|
17
|
+
|-------------------|-------------|----------------------------------------------------------------------------|
|
|
18
|
+
| `ts_event_ns` | `int` | Time at which the request was issued, as UTC epoch nanoseconds. |
|
|
19
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
20
|
+
| `system_order_id` | `uuid.UUID` | System-assigned identifier of the order associated with the request. |
|
|
21
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
system_order_id: uuid.UUID
|
|
25
|
+
symbol: str
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader.events.requests.base import RequestBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
9
|
+
class OrderCancellationRequest(RequestBase):
|
|
10
|
+
"""
|
|
11
|
+
Event representing a request to cancel an existing order.
|
|
12
|
+
|
|
13
|
+
| Field | Type | Semantics |
|
|
14
|
+
|-------------------|-------------|------------------------------------------------------------------------------|
|
|
15
|
+
| `ts_event_ns` | `int` | Time at which the cancellation request was issued, as UTC epoch nanoseconds. |
|
|
16
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
17
|
+
| `system_order_id` | `uuid.UUID` | System-assigned identifier of the order to be cancelled. |
|
|
18
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
pass
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader.events.requests.base import RequestBase
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
9
|
+
class OrderModificationRequest(RequestBase):
|
|
10
|
+
"""
|
|
11
|
+
Event representing a request to modify an existing order.
|
|
12
|
+
|
|
13
|
+
| Field | Type | Semantics |
|
|
14
|
+
|-------------------|-------------------|------------------------------------------------------------------------------|
|
|
15
|
+
| `ts_event_ns` | `int` | Time at which the modification request was issued, as UTC epoch nanoseconds. |
|
|
16
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
17
|
+
| `system_order_id` | `uuid.UUID` | System-assigned identifier of the order to be modified. |
|
|
18
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
19
|
+
| `quantity` | `float` or `None` | Updated order quantity, if modified. |
|
|
20
|
+
| `limit_price` | `float` or `None` | Updated limit price, if modified. |
|
|
21
|
+
| `stop_price` | `float` or `None` | Updated stop price, if modified. |
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
quantity: float | None = None
|
|
25
|
+
limit_price: float | None = None
|
|
26
|
+
stop_price: float | None = None
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
from onesecondtrader import models
|
|
7
|
+
from onesecondtrader.events.requests.base import RequestBase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
11
|
+
class OrderSubmissionRequest(RequestBase):
|
|
12
|
+
"""
|
|
13
|
+
Event representing a request to submit a new order to a broker.
|
|
14
|
+
|
|
15
|
+
The `system_order_id` is a unique identifier assigned by the system to the order submission request by default at object creation.
|
|
16
|
+
|
|
17
|
+
| Field | Type | Semantics |
|
|
18
|
+
|-------------------|--------------------------|----------------------------------------------------------------------------|
|
|
19
|
+
| `ts_event_ns` | `int` | Time at which the submission request was issued, as UTC epoch nanoseconds. |
|
|
20
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
21
|
+
| `system_order_id` | `uuid.UUID` | System-assigned unique identifier for the order submission. |
|
|
22
|
+
| `symbol` | `str` | Identifier of the traded instrument. |
|
|
23
|
+
| `order_type` | `models.OrderType` | Execution constraint of the order. |
|
|
24
|
+
| `side` | `models.TradeSide` | Direction of the trade. |
|
|
25
|
+
| `quantity` | `float` | Requested order quantity. |
|
|
26
|
+
| `limit_price` | `float` or `None` | Limit price, if applicable to the order type. |
|
|
27
|
+
| `stop_price` | `float` or `None` | Stop price, if applicable to the order type. |
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
system_order_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
|
|
31
|
+
order_type: models.OrderType
|
|
32
|
+
side: models.TradeSide
|
|
33
|
+
quantity: float
|
|
34
|
+
limit_price: float | None = None
|
|
35
|
+
stop_price: float | None = None
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
from .base import ResponseBase
|
|
2
|
+
from .orders import OrderAccepted, OrderRejected
|
|
3
|
+
from .modifications import ModificationAccepted, ModificationRejected
|
|
4
|
+
from .cancellations import CancellationAccepted, CancellationRejected
|
|
5
|
+
|
|
6
|
+
__all__ = [
|
|
7
|
+
"ResponseBase",
|
|
8
|
+
"OrderAccepted",
|
|
9
|
+
"OrderRejected",
|
|
10
|
+
"ModificationAccepted",
|
|
11
|
+
"ModificationRejected",
|
|
12
|
+
"CancellationAccepted",
|
|
13
|
+
"CancellationRejected",
|
|
14
|
+
]
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
from onesecondtrader import events
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
11
|
+
class ResponseBase(events.EventBase):
|
|
12
|
+
"""
|
|
13
|
+
Base class for broker response events.
|
|
14
|
+
|
|
15
|
+
This class defines attributes common to all responses received from a broker in reaction to previously issued requests.
|
|
16
|
+
|
|
17
|
+
| Field | Type | Semantics |
|
|
18
|
+
|-----------------------|-------------|---------------------------------------------------------------------------------------|
|
|
19
|
+
| `ts_event_ns` | `int` | Time at which the response event was observed by the system, as UTC epoch nanoseconds.|
|
|
20
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
21
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the response, as UTC epoch nanoseconds. |
|
|
22
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the order associated with the broker response. |
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
ts_broker_ns: int
|
|
26
|
+
associated_order_id: uuid.UUID
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader import models
|
|
6
|
+
from onesecondtrader.events.responses.base import ResponseBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
10
|
+
class CancellationAccepted(ResponseBase):
|
|
11
|
+
"""
|
|
12
|
+
Event indicating that the order cancellation has been acknowledged by the broker and the order is no longer active at the execution venue.
|
|
13
|
+
|
|
14
|
+
| Field | Type | Semantics |
|
|
15
|
+
|-----------------------|-----------------|----------------------------------------------------------------------------------------|
|
|
16
|
+
| `ts_event_ns` | `int` | Time at which the cancellation was observed by the system, as UTC epoch nanoseconds. |
|
|
17
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
18
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the cancellation, as UTC epoch nanoseconds. |
|
|
19
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the cancelled order. |
|
|
20
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the cancelled order, if reported. |
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
broker_order_id: str | None = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
27
|
+
class CancellationRejected(ResponseBase):
|
|
28
|
+
"""
|
|
29
|
+
Event indicating that the order cancellation has been rejected by the broker.
|
|
30
|
+
|
|
31
|
+
| Field | Type | Semantics |
|
|
32
|
+
|-----------------------|--------------------------------------|------------------------------------------------------------------------------------|
|
|
33
|
+
| `ts_event_ns` | `int` | Time at which the rejection was observed by the system, as UTC epoch nanoseconds. |
|
|
34
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
35
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the rejection, as UTC epoch nanoseconds. |
|
|
36
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the order associated with the rejected cancellation. |
|
|
37
|
+
| `rejection_reason` | `models.CancellationRejectionReason` | Canonical classification of the cancellation rejection cause. |
|
|
38
|
+
| `rejection_message` | `str` | Human-readable explanation provided by the broker. |
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
rejection_reason: models.CancellationRejectionReason
|
|
42
|
+
rejection_message: str
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader import models
|
|
6
|
+
from onesecondtrader.events.responses.base import ResponseBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
10
|
+
class ModificationAccepted(ResponseBase):
|
|
11
|
+
"""
|
|
12
|
+
Event indicating that the requested modification has been acknowledged by
|
|
13
|
+
the broker and that the updated order parameters are active at the execution venue.
|
|
14
|
+
|
|
15
|
+
| Field | Type | Semantics |
|
|
16
|
+
|-----------------------|-----------------|----------------------------------------------------------------------------------------|
|
|
17
|
+
| `ts_event_ns` | `int` | Time at which the acceptance was observed by the system, as UTC epoch nanoseconds. |
|
|
18
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
19
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the modification acceptance, as UTC epoch nanoseconds. |
|
|
20
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the modified order. |
|
|
21
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the order after modification, if reported. |
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
broker_order_id: str | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
28
|
+
class ModificationRejected(ResponseBase):
|
|
29
|
+
"""
|
|
30
|
+
Event indicating that the requested modification has been rejected by the broker.
|
|
31
|
+
|
|
32
|
+
| Field | Type | Semantics |
|
|
33
|
+
|-----------------------|--------------------------------------|------------------------------------------------------------------------------------|
|
|
34
|
+
| `ts_event_ns` | `int` | Time at which the rejection was observed by the system, as UTC epoch nanoseconds. |
|
|
35
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
36
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the rejection, as UTC epoch nanoseconds. |
|
|
37
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the order associated with the rejected modification. |
|
|
38
|
+
| `rejection_reason` | `models.ModificationRejectionReason` | Canonical classification of the modification rejection cause. |
|
|
39
|
+
| `rejection_message` | `str` | Human-readable explanation provided by the broker. |
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
rejection_reason: models.ModificationRejectionReason
|
|
43
|
+
rejection_message: str
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import dataclasses
|
|
4
|
+
|
|
5
|
+
from onesecondtrader import models
|
|
6
|
+
from onesecondtrader.events.responses.base import ResponseBase
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
10
|
+
class OrderAccepted(ResponseBase):
|
|
11
|
+
"""
|
|
12
|
+
Event indicating that the order has been accepted by the broker and is active at the execution venue.
|
|
13
|
+
|
|
14
|
+
| Field | Type | Semantics |
|
|
15
|
+
|-----------------------|-----------------|------------------------------------------------------------------------------------|
|
|
16
|
+
| `ts_event_ns` | `int` | Time at which the acceptance was observed by the system, as UTC epoch nanoseconds. |
|
|
17
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
18
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the acceptance, as UTC epoch nanoseconds. |
|
|
19
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the accepted order. |
|
|
20
|
+
| `broker_order_id` | `str` or `None` | Broker-assigned identifier of the accepted order. |
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
broker_order_id: str | None = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
27
|
+
class OrderRejected(ResponseBase):
|
|
28
|
+
"""
|
|
29
|
+
Event indicating that the order has been rejected by the broker.
|
|
30
|
+
|
|
31
|
+
| Field | Type | Semantics |
|
|
32
|
+
|-----------------------|-------------------------------|------------------------------------------------------------------------------------|
|
|
33
|
+
| `ts_event_ns` | `int` | Time at which the rejection was observed by the system, as UTC epoch nanoseconds. |
|
|
34
|
+
| `ts_created_ns` | `int` | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
35
|
+
| `ts_broker_ns` | `int` | Time reported by the broker for the rejection, as UTC epoch nanoseconds. |
|
|
36
|
+
| `associated_order_id` | `uuid.UUID` | Identifier of the rejected order. |
|
|
37
|
+
| `rejection_reason` | `models.OrderRejectionReason` | Canonical classification of the rejection cause. |
|
|
38
|
+
| `rejection_message` | `str` | Human-readable explanation provided by the broker. |
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
rejection_reason: models.OrderRejectionReason
|
|
42
|
+
rejection_message: str
|
|
@@ -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()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import dataclasses
|
|
4
|
-
import time
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
|
|
8
|
-
class EventBase:
|
|
9
|
-
"""
|
|
10
|
-
Base class for immutable event message objects, using Unix epoch nanoseconds.
|
|
11
|
-
|
|
12
|
-
| Field | Type | Semantics |
|
|
13
|
-
|---------------|------|------------------------------------------------------------------------|
|
|
14
|
-
| ts_event_ns | int | Time at which the represented fact occurred, as UTC epoch nanoseconds. |
|
|
15
|
-
| ts_created_ns | int | Time at which the event object was created, as UTC epoch nanoseconds. |
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
ts_event_ns: int
|
|
19
|
-
ts_created_ns: int = dataclasses.field(default_factory=time.time_ns)
|
|
@@ -1,10 +0,0 @@
|
|
|
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 .trade_sides import TradeSide
|
|
9
|
-
|
|
10
|
-
__all__ = ["BarField", "BarPeriod", "OrderType", "TradeSide"]
|
|
@@ -1,23 +0,0 @@
|
|
|
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()
|
|
@@ -1,21 +0,0 @@
|
|
|
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()
|
|
@@ -1,21 +0,0 @@
|
|
|
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()
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TradeSide(enum.Enum):
|
|
7
|
-
"""
|
|
8
|
-
Enumeration of trade direction.
|
|
9
|
-
|
|
10
|
-
`OrderSide` 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()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|