onesecondtrader 0.3.0__py3-none-any.whl → 0.4.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.
- onesecondtrader/__init__.py +0 -4
- {onesecondtrader-0.3.0.dist-info → onesecondtrader-0.4.0.dist-info}/METADATA +1 -1
- onesecondtrader-0.4.0.dist-info/RECORD +6 -0
- onesecondtrader/domain_models.py +0 -157
- onesecondtrader-0.3.0.dist-info/RECORD +0 -7
- {onesecondtrader-0.3.0.dist-info → onesecondtrader-0.4.0.dist-info}/LICENSE +0 -0
- {onesecondtrader-0.3.0.dist-info → onesecondtrader-0.4.0.dist-info}/WHEEL +0 -0
onesecondtrader/__init__.py
CHANGED
|
@@ -8,12 +8,8 @@ Research, simulate, and deploy algorithmic trading strategies — all in one pla
|
|
|
8
8
|
from .log_config import logger
|
|
9
9
|
|
|
10
10
|
# Domain models
|
|
11
|
-
from .domain_models import MarketData, PositionManagement
|
|
12
11
|
|
|
13
12
|
__all__ = [
|
|
14
13
|
# Core infrastructure
|
|
15
14
|
"logger",
|
|
16
|
-
# Domain models
|
|
17
|
-
"MarketData",
|
|
18
|
-
"PositionManagement",
|
|
19
15
|
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: The Trading Infrastructure Toolkit for Python. Research, simulate, and deploy algorithmic trading strategies — all in one place.
|
|
5
5
|
Author: Nils P. Kujath
|
|
6
6
|
Author-email: 63961429+NilsKujath@users.noreply.github.com
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
onesecondtrader/__init__.py,sha256=3Z8l96x_53aq-SANaJocCjMIGngDobKaFJ6sw1B6L7E,266
|
|
2
|
+
onesecondtrader/log_config.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
3
|
+
onesecondtrader-0.4.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
4
|
+
onesecondtrader-0.4.0.dist-info/METADATA,sha256=p3X85tWNJa_LlQp2eLxjP97MJPNTxmWRk0qIaQTzEA4,1220
|
|
5
|
+
onesecondtrader-0.4.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
6
|
+
onesecondtrader-0.4.0.dist-info/RECORD,,
|
onesecondtrader/domain_models.py
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Domain models for trading infrastructure.
|
|
3
|
-
|
|
4
|
-
This module defines the core domain models used across the trading infrastructure.
|
|
5
|
-
The design follows Domain-Driven Design (DDD) principles to structure domain logic
|
|
6
|
-
into semantically cohesive and type-safe groupings. The models reflect foundational
|
|
7
|
-
concepts such as orders, execution states, and position lifecycles. This establishes a
|
|
8
|
-
ubiquitous language that is shared across modules, interfaces, and system components.
|
|
9
|
-
|
|
10
|
-
Using enums to define these domain models provides the following benefits:
|
|
11
|
-
|
|
12
|
-
1. **Type Safety** – Prevents invalid states (e.g., avoids `"buy"` vs `"BUY"` bugs)
|
|
13
|
-
2. **Compile-Time Validation** – Enables early detection of missing cases (e.g., in match statements)
|
|
14
|
-
3. **Semantic Precision** – Improves self-documentation and system comprehensibility
|
|
15
|
-
4. **Refactor Robustness** – Reduces breakage when business rules evolve
|
|
16
|
-
5. **Performance** – More efficient than string comparisons at runtime
|
|
17
|
-
6. **Domain Vocabulary** – Aligns code with trading terminology
|
|
18
|
-
(e.g., `OrderType.LIMIT`)
|
|
19
|
-
|
|
20
|
-
All enums use `enum.auto()` to delegate value assignment unless interoperability with
|
|
21
|
-
external systems requires explicit values. This minimizes maintenance overhead and
|
|
22
|
-
ensures uniqueness without manual management.
|
|
23
|
-
|
|
24
|
-
The domain models are grouped into the following classes:
|
|
25
|
-
|
|
26
|
-
- **MarketData** – Market data feeds, aggregated bars, record metadata
|
|
27
|
-
- **PositionManagement** – Orders, execution states, trade lifecycle controls
|
|
28
|
-
"""
|
|
29
|
-
|
|
30
|
-
import collections
|
|
31
|
-
import enum
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class MarketData:
|
|
35
|
-
"""
|
|
36
|
-
Domain model for market data representation.
|
|
37
|
-
|
|
38
|
-
This namespace defines core data structures and enums related to market data,
|
|
39
|
-
such as aggregated price bars and data record types.
|
|
40
|
-
"""
|
|
41
|
-
|
|
42
|
-
OHLCV = collections.namedtuple("OHLCV", ["open", "high", "low", "close", "volume"])
|
|
43
|
-
|
|
44
|
-
class RecordType(enum.Enum):
|
|
45
|
-
"""
|
|
46
|
-
Market data record type identifiers using Databento rtype integers.
|
|
47
|
-
|
|
48
|
-
The `MarketData.RecordType` enum preserves compatibility with format by using
|
|
49
|
-
their specified `rtype` integer assignments. This allows tight integration with
|
|
50
|
-
Databento data streams while remaining agnostic to any specific vendor.
|
|
51
|
-
|
|
52
|
-
Values:
|
|
53
|
-
- OHLCV_1S (32): 1-second bars
|
|
54
|
-
- OHLCV_1M (33): 1-minute bars
|
|
55
|
-
- OHLCV_1H (34): 1-hour bars
|
|
56
|
-
- OHLCV_1D (35): Daily bars
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
OHLCV_1S = 32
|
|
60
|
-
OHLCV_1M = 33
|
|
61
|
-
OHLCV_1H = 34
|
|
62
|
-
OHLCV_1D = 35
|
|
63
|
-
|
|
64
|
-
@classmethod
|
|
65
|
-
def to_string(cls, rtype: int) -> str:
|
|
66
|
-
"""Convert record type integer to human-readable description."""
|
|
67
|
-
match rtype:
|
|
68
|
-
case cls.OHLCV_1S.value:
|
|
69
|
-
return "1-second bars"
|
|
70
|
-
case cls.OHLCV_1M.value:
|
|
71
|
-
return "1-minute bars"
|
|
72
|
-
case cls.OHLCV_1H.value:
|
|
73
|
-
return "1-hour bars"
|
|
74
|
-
case cls.OHLCV_1D.value:
|
|
75
|
-
return "daily bars"
|
|
76
|
-
case _:
|
|
77
|
-
return f"unknown ({rtype})"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
class PositionManagement:
|
|
81
|
-
"""
|
|
82
|
-
Trading domain concepts for managing orders and positions.
|
|
83
|
-
|
|
84
|
-
This namespace defines core abstractions related to the lifecycle of orders.
|
|
85
|
-
"""
|
|
86
|
-
|
|
87
|
-
class OrderType(enum.Enum):
|
|
88
|
-
"""
|
|
89
|
-
Order execution types.
|
|
90
|
-
|
|
91
|
-
Values:
|
|
92
|
-
- MARKET: Execute immediately at best available price
|
|
93
|
-
- LIMIT: Execute only at specified price or better
|
|
94
|
-
- STOP: Becomes market order when trigger price is reached
|
|
95
|
-
- STOP_LIMIT: Becomes limit order when trigger price is reached
|
|
96
|
-
"""
|
|
97
|
-
|
|
98
|
-
MARKET = enum.auto()
|
|
99
|
-
LIMIT = enum.auto()
|
|
100
|
-
STOP = enum.auto()
|
|
101
|
-
STOP_LIMIT = enum.auto()
|
|
102
|
-
|
|
103
|
-
class OrderState(enum.Enum):
|
|
104
|
-
"""
|
|
105
|
-
Order lifecycle states from creation to completion.
|
|
106
|
-
|
|
107
|
-
Values:
|
|
108
|
-
- NEW: Created but not submitted
|
|
109
|
-
- SUBMITTED: Sent to broker/exchange
|
|
110
|
-
- ACTIVE: Live in market
|
|
111
|
-
- PARTIALLY_FILLED: Partially executed
|
|
112
|
-
- FILLED: Completely executed
|
|
113
|
-
- CANCELLED: Cancelled before first fill
|
|
114
|
-
- CANCELLED_AT_PARTIAL_FILL: Cancelled after partial fill
|
|
115
|
-
- REJECTED: Rejected by broker/exchange
|
|
116
|
-
- EXPIRED: Expired due to time-in-force constraints
|
|
117
|
-
"""
|
|
118
|
-
|
|
119
|
-
NEW = enum.auto()
|
|
120
|
-
SUBMITTED = enum.auto()
|
|
121
|
-
ACTIVE = enum.auto()
|
|
122
|
-
PARTIALLY_FILLED = enum.auto()
|
|
123
|
-
FILLED = enum.auto()
|
|
124
|
-
CANCELLED = enum.auto()
|
|
125
|
-
CANCELLED_AT_PARTIAL_FILL = enum.auto()
|
|
126
|
-
REJECTED = enum.auto()
|
|
127
|
-
EXPIRED = enum.auto()
|
|
128
|
-
|
|
129
|
-
class Side(enum.Enum):
|
|
130
|
-
"""
|
|
131
|
-
Order direction - buy or sell.
|
|
132
|
-
|
|
133
|
-
Values:
|
|
134
|
-
- BUY: Buy the financial instrument
|
|
135
|
-
- SELL: Sell the financial instrument
|
|
136
|
-
"""
|
|
137
|
-
|
|
138
|
-
BUY = enum.auto()
|
|
139
|
-
SELL = enum.auto()
|
|
140
|
-
|
|
141
|
-
class TimeInForce(enum.Enum):
|
|
142
|
-
"""
|
|
143
|
-
Order time-in-force specifications.
|
|
144
|
-
|
|
145
|
-
Values:
|
|
146
|
-
- DAY: Valid until end of trading day
|
|
147
|
-
- FOK: Fill entire order immediately or cancel (Fill-or-Kill)
|
|
148
|
-
- GTC: Active until explicitly cancelled (Good-Till-Cancelled)
|
|
149
|
-
- GTD: Active until specified date (Good-Till-Date)
|
|
150
|
-
- IOC: Execute available quantity immediately, cancel rest (Immediate-or-Cancel)
|
|
151
|
-
"""
|
|
152
|
-
|
|
153
|
-
DAY = enum.auto()
|
|
154
|
-
FOK = enum.auto()
|
|
155
|
-
GTC = enum.auto()
|
|
156
|
-
GTD = enum.auto()
|
|
157
|
-
IOC = enum.auto()
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
onesecondtrader/__init__.py,sha256=YWe2rJwheKv4oytgJk3nODWfoMJAVzpMc9OJmNBGjc4,388
|
|
2
|
-
onesecondtrader/domain_models.py,sha256=01UEmX0S2WquspbMII826uS-Qo47XukvFl-niirviV4,5537
|
|
3
|
-
onesecondtrader/log_config.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
4
|
-
onesecondtrader-0.3.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
-
onesecondtrader-0.3.0.dist-info/METADATA,sha256=b_2UMpNoMHmtMhpqmhrV84YJxSURPBxbt5mbtVB5sqk,1220
|
|
6
|
-
onesecondtrader-0.3.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
7
|
-
onesecondtrader-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|