onesecondtrader 0.4.0__py3-none-any.whl → 0.5.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 +5 -0
- onesecondtrader/domain_models.py +216 -0
- {onesecondtrader-0.4.0.dist-info → onesecondtrader-0.5.0.dist-info}/METADATA +1 -1
- onesecondtrader-0.5.0.dist-info/RECORD +7 -0
- onesecondtrader-0.4.0.dist-info/RECORD +0 -6
- {onesecondtrader-0.4.0.dist-info → onesecondtrader-0.5.0.dist-info}/LICENSE +0 -0
- {onesecondtrader-0.4.0.dist-info → onesecondtrader-0.5.0.dist-info}/WHEEL +0 -0
onesecondtrader/__init__.py
CHANGED
|
@@ -8,8 +8,13 @@ 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, SystemManagement
|
|
11
12
|
|
|
12
13
|
__all__ = [
|
|
13
14
|
# Core infrastructure
|
|
14
15
|
"logger",
|
|
16
|
+
# Domain models
|
|
17
|
+
"MarketData",
|
|
18
|
+
"PositionManagement",
|
|
19
|
+
"SystemManagement",
|
|
15
20
|
]
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module defines the core domain models for trading infrastructure.
|
|
3
|
+
These models are organised into namespaces to provide clear semantic groupings
|
|
4
|
+
(e.g.: `PositionManagement.OrderType.MARKET`).
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import collections
|
|
8
|
+
import enum
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MarketData:
|
|
12
|
+
"""
|
|
13
|
+
Domain model namespace for market data related concepts.
|
|
14
|
+
|
|
15
|
+
???+ note "Market Data Record Types"
|
|
16
|
+
|
|
17
|
+
```mermaid
|
|
18
|
+
---
|
|
19
|
+
config:
|
|
20
|
+
themeVariables:
|
|
21
|
+
fontSize: "11px"
|
|
22
|
+
---
|
|
23
|
+
graph LR
|
|
24
|
+
A0[MarketData]
|
|
25
|
+
A[MarketData.OHLCV]
|
|
26
|
+
B[MarketData.RecordType]
|
|
27
|
+
A0 --> A
|
|
28
|
+
A0 --> B
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
OHLCV = collections.namedtuple("OHLCV", ["open", "high", "low", "close", "volume"])
|
|
34
|
+
|
|
35
|
+
class RecordType(enum.Enum):
|
|
36
|
+
"""
|
|
37
|
+
Market data record type identifiers that preserve compatibility with Databento's
|
|
38
|
+
rtype integers identifiers:
|
|
39
|
+
|
|
40
|
+
quote:
|
|
41
|
+
- `OHLCV_1S` (`32`): 1-second bars
|
|
42
|
+
- `OHLCV_1M` (`33`): 1-minute bars
|
|
43
|
+
- `OHLCV_1H` (`34`): 1-hour bars
|
|
44
|
+
- `OHLCV_1D` (`35`): Daily bars
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
OHLCV_1S = 32
|
|
48
|
+
OHLCV_1M = 33
|
|
49
|
+
OHLCV_1H = 34
|
|
50
|
+
OHLCV_1D = 35
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def to_string(cls, record_type: int) -> str:
|
|
54
|
+
"""Convert record type integer to human-readable description."""
|
|
55
|
+
match record_type:
|
|
56
|
+
case cls.OHLCV_1S.value:
|
|
57
|
+
return "1-second bars"
|
|
58
|
+
case cls.OHLCV_1M.value:
|
|
59
|
+
return "1-minute bars"
|
|
60
|
+
case cls.OHLCV_1H.value:
|
|
61
|
+
return "1-hour bars"
|
|
62
|
+
case cls.OHLCV_1D.value:
|
|
63
|
+
return "daily bars"
|
|
64
|
+
case _:
|
|
65
|
+
return f"unknown ({record_type})"
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class PositionManagement:
|
|
69
|
+
"""
|
|
70
|
+
Domain model namespace for position management related concepts.
|
|
71
|
+
|
|
72
|
+
???+ note "Position Management Concepts"
|
|
73
|
+
|
|
74
|
+
```mermaid
|
|
75
|
+
---
|
|
76
|
+
config:
|
|
77
|
+
themeVariables:
|
|
78
|
+
fontSize: "11px"
|
|
79
|
+
---
|
|
80
|
+
graph LR
|
|
81
|
+
A0[PositionManagement]
|
|
82
|
+
A[PositionManagement.OrderType]
|
|
83
|
+
B[PositionManagement.OrderState]
|
|
84
|
+
C[PositionManagement.Side]
|
|
85
|
+
D[PositionManagement.TimeInForce]
|
|
86
|
+
E[PositionManagement.CancelReason]
|
|
87
|
+
A0 --> A
|
|
88
|
+
A0 --> B
|
|
89
|
+
A0 --> C
|
|
90
|
+
A0 --> D
|
|
91
|
+
A0 --> E
|
|
92
|
+
```
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
class OrderType(enum.Enum):
|
|
96
|
+
"""
|
|
97
|
+
Order execution types.
|
|
98
|
+
|
|
99
|
+
quote:
|
|
100
|
+
- `MARKET`: Execute immediately at best available price
|
|
101
|
+
- `LIMIT`: Execute only at specified price or better
|
|
102
|
+
- `STOP`: Becomes market order when trigger price is reached
|
|
103
|
+
- `STOP_LIMIT`: Becomes limit order when trigger price is reached
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
MARKET = enum.auto()
|
|
107
|
+
LIMIT = enum.auto()
|
|
108
|
+
STOP = enum.auto()
|
|
109
|
+
STOP_LIMIT = enum.auto()
|
|
110
|
+
|
|
111
|
+
class OrderState(enum.Enum):
|
|
112
|
+
"""
|
|
113
|
+
Order lifecycle states.
|
|
114
|
+
|
|
115
|
+
quote:
|
|
116
|
+
- `NEW`: Created but not submitted
|
|
117
|
+
- `SUBMITTED`: Sent to broker/exchange
|
|
118
|
+
- `ACTIVE`: Live in market
|
|
119
|
+
- `PARTIALLY_FILLED`: Partially executed
|
|
120
|
+
- `FILLED`: Completely executed
|
|
121
|
+
- `CANCELLED`: Cancelled before first fill
|
|
122
|
+
- `CANCELLED_AT_PARTIAL_FILL`: Cancelled after partial fill
|
|
123
|
+
- `REJECTED`: Rejected by broker/exchange
|
|
124
|
+
- `EXPIRED`: Expired due to time-in-force constraints
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
NEW = enum.auto()
|
|
128
|
+
SUBMITTED = enum.auto()
|
|
129
|
+
ACTIVE = enum.auto()
|
|
130
|
+
PARTIALLY_FILLED = enum.auto()
|
|
131
|
+
FILLED = enum.auto()
|
|
132
|
+
CANCELLED = enum.auto()
|
|
133
|
+
CANCELLED_AT_PARTIAL_FILL = enum.auto()
|
|
134
|
+
REJECTED = enum.auto()
|
|
135
|
+
EXPIRED = enum.auto()
|
|
136
|
+
|
|
137
|
+
class Side(enum.Enum):
|
|
138
|
+
"""
|
|
139
|
+
Order direction - buy or sell.
|
|
140
|
+
|
|
141
|
+
quote:
|
|
142
|
+
- `BUY`: Buy the financial instrument
|
|
143
|
+
- `SELL`: Sell the financial instrument
|
|
144
|
+
"""
|
|
145
|
+
|
|
146
|
+
BUY = enum.auto()
|
|
147
|
+
SELL = enum.auto()
|
|
148
|
+
|
|
149
|
+
class TimeInForce(enum.Enum):
|
|
150
|
+
"""
|
|
151
|
+
Order time-in-force specifications.
|
|
152
|
+
|
|
153
|
+
quote:
|
|
154
|
+
- `DAY`: Valid until end of trading day
|
|
155
|
+
- `FOK`: Fill entire order immediately or cancel (Fill-or-Kill)
|
|
156
|
+
- `GTC`: Active until explicitly cancelled (Good-Till-Cancelled)
|
|
157
|
+
- `GTD`: Active until specified date (Good-Till-Date)
|
|
158
|
+
- `IOC`: Execute available quantity immediately, cancel rest
|
|
159
|
+
(Immediate-or-Cancel)
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
DAY = enum.auto()
|
|
163
|
+
FOK = enum.auto()
|
|
164
|
+
GTC = enum.auto()
|
|
165
|
+
GTD = enum.auto()
|
|
166
|
+
IOC = enum.auto()
|
|
167
|
+
|
|
168
|
+
class CancelReason(enum.Enum):
|
|
169
|
+
"""
|
|
170
|
+
Reasons for order cancellation.
|
|
171
|
+
|
|
172
|
+
quote:
|
|
173
|
+
- `CLIENT_REQUEST`: Order cancelled by client/trader request
|
|
174
|
+
- `EXPIRED_TIME_IN_FORCE`: Order expired due to time-in-force constraints
|
|
175
|
+
- `BROKER_REJECTED_AT_SUBMISSION`: Broker rejected order during submission
|
|
176
|
+
- `BROKER_FORCED_CANCEL`: Broker cancelled order due to risk or other constraints
|
|
177
|
+
- `UNKNOWN`: Cancellation reason not specified or unknown
|
|
178
|
+
"""
|
|
179
|
+
|
|
180
|
+
CLIENT_REQUEST = enum.auto()
|
|
181
|
+
EXPIRED_TIME_IN_FORCE = enum.auto()
|
|
182
|
+
BROKER_REJECTED_AT_SUBMISSION = enum.auto()
|
|
183
|
+
BROKER_FORCED_CANCEL = enum.auto()
|
|
184
|
+
UNKNOWN = enum.auto()
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class SystemManagement:
|
|
188
|
+
"""
|
|
189
|
+
Domain model namespace for system management related concepts.
|
|
190
|
+
|
|
191
|
+
???+ note "System Management Concepts"
|
|
192
|
+
|
|
193
|
+
```mermaid
|
|
194
|
+
---
|
|
195
|
+
config:
|
|
196
|
+
themeVariables:
|
|
197
|
+
fontSize: "11px"
|
|
198
|
+
---
|
|
199
|
+
graph LR
|
|
200
|
+
A0[SystemManagement]
|
|
201
|
+
A[SystemManagement.StopReason]
|
|
202
|
+
A0 --> A
|
|
203
|
+
```
|
|
204
|
+
"""
|
|
205
|
+
|
|
206
|
+
class StopReason(enum.Enum):
|
|
207
|
+
"""
|
|
208
|
+
Reasons for system or component shutdown.
|
|
209
|
+
|
|
210
|
+
quote:
|
|
211
|
+
- `SYSTEM_SHUTDOWN`: Coordinated shutdown of entire system
|
|
212
|
+
- `COMPONENT_DISCONNECT`: Single component disconnect
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
SYSTEM_SHUTDOWN = enum.auto()
|
|
216
|
+
COMPONENT_DISCONNECT = enum.auto()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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,7 @@
|
|
|
1
|
+
onesecondtrader/__init__.py,sha256=xB2oXIiffWA19eaQbdEn3GZyymhyLHaxPLO-DhP4CLc,430
|
|
2
|
+
onesecondtrader/domain_models.py,sha256=3UigXXEBlZehQupwM_LnLh4rlsOil9e_iPMosjWKFcw,6229
|
|
3
|
+
onesecondtrader/log_config.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
4
|
+
onesecondtrader-0.5.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
+
onesecondtrader-0.5.0.dist-info/METADATA,sha256=FRJXLOfZEs1Pr3PFNqfV41cBDNk1oT49RiO9cFYDwRw,1220
|
|
6
|
+
onesecondtrader-0.5.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
7
|
+
onesecondtrader-0.5.0.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
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,,
|
|
File without changes
|
|
File without changes
|