onesecondtrader 0.5.3__tar.gz → 0.6.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: onesecondtrader
3
- Version: 0.5.3
3
+ Version: 0.6.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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "onesecondtrader"
3
- version = "0.5.3"
3
+ version = "0.6.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"}
@@ -25,12 +25,9 @@ pyyaml = "^6.0.2"
25
25
  pytest = "^8.4.1"
26
26
  ruff = "^0.12.7"
27
27
  mypy = "^1.17.1"
28
- bandit = "^1.8.6"
29
- safety = "^3.6.0"
30
- radon = "^6.0.1"
28
+
31
29
  types-pyyaml = "^6.0.12.20250516"
32
- coverage = "^7.10.1"
33
- pytest-cov = "^6.2.1"
30
+
34
31
  mkdocs-autorefs = "^1.4.2"
35
32
  mkdocs = "^1.6.1"
36
33
  python-semantic-release = "^10.3.0"
@@ -55,32 +52,7 @@ requires = ["poetry-core>=2.0.0,<3.0.0"]
55
52
  build-backend = "poetry.core.masonry.api"
56
53
 
57
54
  [tool.mypy]
58
- mypy_path = "src"
59
- packages = ["onesecondtrader"]
60
55
  explicit_package_bases = true
61
56
 
62
57
  [tool.pytest.ini_options]
63
58
  testpaths = ["tests"]
64
-
65
- [tool.coverage.run]
66
- source = ["src"]
67
- omit = [
68
- "*/tests/*",
69
- "*/__pycache__/*",
70
- ]
71
-
72
- [tool.coverage.report]
73
- exclude_lines = [
74
- "pragma: no cover",
75
- "def __repr__",
76
- "if self.debug:",
77
- "if settings.DEBUG",
78
- "raise AssertionError",
79
- "raise NotImplementedError",
80
- "if 0:",
81
- "if __name__ == .__main__.:",
82
- "class .*\\bProtocol\\):",
83
- "class Event:",
84
- "class .*Event.*:",
85
- "@(abc\\.)?abstractmethod",
86
- ]
@@ -7,15 +7,8 @@ Research, simulate, and deploy algorithmic trading strategies — all in one pla
7
7
  # Core infrastructure
8
8
  from .monitoring import logger
9
9
 
10
- # Domain models
11
- from .domain.models import DomainModel, MarketData, PositionManagement, SystemManagement
12
10
 
13
11
  __all__ = [
14
12
  # Core infrastructure
15
13
  "logger",
16
- # Domain models
17
- "DomainModel",
18
- "MarketData",
19
- "PositionManagement",
20
- "SystemManagement",
21
14
  ]
@@ -1,13 +0,0 @@
1
- from .models import DomainModel
2
-
3
- # Convenience aliases for domain models
4
- MarketData = DomainModel.MarketData
5
- PositionManagement = DomainModel.PositionManagement
6
- SystemManagement = DomainModel.SystemManagement
7
-
8
- __all__ = [
9
- "DomainModel",
10
- "MarketData",
11
- "PositionManagement",
12
- "SystemManagement",
13
- ]
@@ -1,526 +0,0 @@
1
- """
2
- Container module for non-component-specific domain models.
3
-
4
- This module provides the non-component-specific domain models used across the
5
- trading infrastructure.
6
- """
7
-
8
- import collections
9
- import enum
10
-
11
-
12
- class DomainModel:
13
- """
14
- Container class for non-component-specific domain models.
15
- Domain models are organised into namespaces to provide clear semantic groupings
16
- (e.g.: `PositionManagement.OrderType.MARKET`).
17
- Note that the namespace prefix `DomainModel` can be omitted when accessing
18
- the domain models, i.e.: `DomainModel.MarketData.OHLCV` can be aliased as
19
- `MarketData.OHLCV`.
20
-
21
- ???+ note "Domain Model Hierarchy"
22
-
23
- ```mermaid
24
- ---
25
- config:
26
- themeVariables:
27
- fontSize: "11px"
28
- ---
29
- graph LR
30
-
31
- A0[DomainModels]
32
-
33
- A01[MarketData]
34
- A02[PositionManagement]
35
- A03[SystemManagement]
36
-
37
- A0 --> A01
38
- A0 --> A02
39
- A0 --> A03
40
-
41
- A1["**MarketData.OHLCV**"]
42
- A2["**MarketData.RecordType**"]
43
- A01 --> A1
44
- A01 --> A2
45
-
46
- B1["**PositionManagement.OrderType**"]
47
- B2["**PositionManagement.OrderState**"]
48
- B3["**PositionManagement.Side**"]
49
- B4["**PositionManagement.TimeInForce**"]
50
- B5["**PositionManagement.CancelReason**"]
51
- A02 --> B1
52
- A02 --> B2
53
- A02 --> B3
54
- A02 --> B4
55
- A02 --> B5
56
-
57
- C1["**SystemManagement.StopReason**"]
58
- A03 --> C1
59
-
60
- subgraph MarketData ["Market Data Domain Models"]
61
- A1
62
- A2
63
- end
64
-
65
- subgraph PositionManagement ["Position Management Domain Models"]
66
- B1
67
- B2
68
- B3
69
- B4
70
- B5
71
- end
72
-
73
- subgraph SystemManagement ["System Management Domain Models"]
74
- C1
75
- end
76
-
77
- subgraph DomainModelNamespaces ["Domain Model Namespaces"]
78
- A0
79
- A01
80
- A02
81
- A03
82
- end
83
- ```
84
- """
85
-
86
- # ----------------------------------------------------------------------------------
87
- # SYSTEM MANAGEMENT DOMAIN MODEL NAMESPACE
88
- # ----------------------------------------------------------------------------------
89
-
90
- class SystemManagement:
91
- """
92
- Domain model namespace for system management related concepts.
93
-
94
- ???+ note "Domain Model Hierarchy"
95
-
96
- ```mermaid
97
- ---
98
- config:
99
- themeVariables:
100
- fontSize: "11px"
101
- ---
102
- graph LR
103
-
104
- A0[DomainModels]
105
-
106
- A01[MarketData]
107
- A02[PositionManagement]
108
- A03[SystemManagement]
109
-
110
- A0 --> A01
111
- A0 --> A02
112
- A0 --> A03
113
-
114
- A1["**MarketData.OHLCV**"]
115
- A2["**MarketData.RecordType**"]
116
- A01 --> A1
117
- A01 --> A2
118
-
119
- B1["**PositionManagement.OrderType**"]
120
- B2["**PositionManagement.OrderState**"]
121
- B3["**PositionManagement.Side**"]
122
- B4["**PositionManagement.TimeInForce**"]
123
- B5["**PositionManagement.CancelReason**"]
124
- A02 --> B1
125
- A02 --> B2
126
- A02 --> B3
127
- A02 --> B4
128
- A02 --> B5
129
-
130
- C1["**SystemManagement.StopReason**"]
131
- A03 --> C1
132
-
133
- subgraph MarketData ["Market Data Domain Models"]
134
- A1
135
- A2
136
- end
137
-
138
- subgraph PositionManagement ["Position Management Domain Models"]
139
- B1
140
- B2
141
- B3
142
- B4
143
- B5
144
- end
145
-
146
- subgraph SystemManagement ["System Management Domain Models"]
147
- C1
148
- end
149
-
150
- subgraph DomainModelNamespaces ["Domain Model Namespaces"]
151
- A0
152
- A01
153
- A02
154
- A03
155
- end
156
-
157
- style SystemManagement fill:#6F42C1,fill-opacity:0.3
158
- ```
159
- """
160
-
161
- class StopReason(enum.Enum):
162
- """
163
- Reasons for system or component shutdown.
164
-
165
- **Attributes:**
166
-
167
- | Enum | Value | Description |
168
- |------|-------|-------------|
169
- | `SYSTEM_SHUTDOWN` | `enum.auto()` | Coordinated shutdown of entire system |
170
- | `COMPONENT_DISCONNECT` | `enum.auto()` | Single component disconnect |
171
- """
172
-
173
- SYSTEM_SHUTDOWN = enum.auto()
174
- COMPONENT_DISCONNECT = enum.auto()
175
-
176
- # ----------------------------------------------------------------------------------
177
- # POSITION MANAGEMENT DOMAIN MODEL NAMESPACE
178
- # ----------------------------------------------------------------------------------
179
-
180
- class PositionManagement:
181
- """
182
- ???+ note "Domain Model Hierarchy"
183
-
184
- ```mermaid
185
- ---
186
- config:
187
- themeVariables:
188
- fontSize: "11px"
189
- ---
190
- graph LR
191
-
192
- A0[DomainModels]
193
-
194
- A01[MarketData]
195
- A02[PositionManagement]
196
- A03[SystemManagement]
197
-
198
- A0 --> A01
199
- A0 --> A02
200
- A0 --> A03
201
-
202
- A1["**MarketData.OHLCV**"]
203
- A2["**MarketData.RecordType**"]
204
- A01 --> A1
205
- A01 --> A2
206
-
207
- B1["**PositionManagement.OrderType**"]
208
- B2["**PositionManagement.OrderState**"]
209
- B3["**PositionManagement.Side**"]
210
- B4["**PositionManagement.TimeInForce**"]
211
- B5["**PositionManagement.CancelReason**"]
212
- A02 --> B1
213
- A02 --> B2
214
- A02 --> B3
215
- A02 --> B4
216
- A02 --> B5
217
-
218
- C1["**SystemManagement.StopReason**"]
219
- A03 --> C1
220
-
221
- subgraph MarketData ["Market Data Domain Models"]
222
- A1
223
- A2
224
- end
225
-
226
- subgraph PositionManagement ["Position Management Domain Models"]
227
- B1
228
- B2
229
- B3
230
- B4
231
- B5
232
- end
233
-
234
- subgraph SystemManagement ["System Management Domain Models"]
235
- C1
236
- end
237
-
238
- subgraph DomainModelNamespaces ["Domain Model Namespaces"]
239
- A0
240
- A01
241
- A02
242
- A03
243
- end
244
-
245
- style PositionManagement fill:#6F42C1,fill-opacity:0.3
246
- ```
247
- """
248
-
249
- # ------------------------------------------------------------------------------
250
- # ORDER TYPE
251
-
252
- class OrderType(enum.Enum):
253
- """
254
- Order execution types.
255
-
256
- **Attributes:**
257
-
258
- | Enum | Value | Description |
259
- |------|-------|-------------|
260
- | `MARKET` | `enum.auto()` | Execute immediately at best available price |
261
- | `LIMIT` | `enum.auto()` | Execute only at specified price or better |
262
- | `STOP` | `enum.auto()` | Becomes market order when trigger price is reached |
263
- | `STOP_LIMIT` | `enum.auto()` | Becomes limit order when trigger price is reached |
264
- """
265
-
266
- MARKET = enum.auto()
267
- LIMIT = enum.auto()
268
- STOP = enum.auto()
269
- STOP_LIMIT = enum.auto()
270
-
271
- # ------------------------------------------------------------------------------
272
- # ORDER STATE
273
-
274
- class OrderState(enum.Enum):
275
- """
276
- Order lifecycle states.
277
-
278
- **Attributes:**
279
-
280
- | Enum | Value | Description |
281
- |------|-------|-------------|
282
- | `NEW` | `enum.auto()` | Created but not submitted |
283
- | `SUBMITTED` | `enum.auto()` | Sent to broker/exchange |
284
- | `ACTIVE` | `enum.auto()` | Live in market |
285
- | `PARTIALLY_FILLED` | `enum.auto()` | Partially executed |
286
- | `FILLED` | `enum.auto()` | Completely executed |
287
- | `CANCELLED` | `enum.auto()` | Cancelled before first fill |
288
- | `CANCELLED_AT_PARTIAL_FILL` | `enum.auto()` | Cancelled after partial fill |
289
- | `REJECTED` | `enum.auto()` | Rejected by broker/exchange |
290
- | `EXPIRED` | `enum.auto()` | Expired due to time-in-force constraints |
291
-
292
- """
293
-
294
- NEW = enum.auto()
295
- SUBMITTED = enum.auto()
296
- ACTIVE = enum.auto()
297
- PARTIALLY_FILLED = enum.auto()
298
- FILLED = enum.auto()
299
- CANCELLED = enum.auto()
300
- CANCELLED_AT_PARTIAL_FILL = enum.auto()
301
- REJECTED = enum.auto()
302
- EXPIRED = enum.auto()
303
-
304
- # ------------------------------------------------------------------------------
305
- # SIDE
306
- class Side(enum.Enum):
307
- """
308
- Order direction - buy or sell.
309
-
310
- **Attributes:**
311
-
312
- | Enum | Value | Description |
313
- |------|-------|-------------|
314
- | `BUY` | `enum.auto()` | Buy the financial instrument |
315
- | `SELL` | `enum.auto()` | Sell the financial instrument |
316
-
317
- """
318
-
319
- BUY = enum.auto()
320
- SELL = enum.auto()
321
-
322
- # ------------------------------------------------------------------------------
323
- # TIME IN FORCE
324
- class TimeInForce(enum.Enum):
325
- """
326
- Order time-in-force specifications.
327
-
328
- **Attributes:**
329
-
330
- | Enum | Value | Description |
331
- |------|-------|-------------|
332
- | `DAY` | `enum.auto()` | Valid until end of trading day |
333
- | `FOK` | `enum.auto()` | Fill entire order immediately or cancel (Fill-or-Kill) |
334
- | `GTC` | `enum.auto()` | Active until explicitly cancelled (Good-Till-Cancelled) |
335
- | `GTD` | `enum.auto()` | Active until specified date (Good-Till-Date) |
336
- | `IOC` | `enum.auto()` | Execute available quantity immediately, cancel rest (Immediate-or-Cancel) |
337
- """
338
-
339
- DAY = enum.auto()
340
- FOK = enum.auto()
341
- GTC = enum.auto()
342
- GTD = enum.auto()
343
- IOC = enum.auto()
344
-
345
- # ------------------------------------------------------------------------------
346
- # CANCEL REASON
347
- class CancelReason(enum.Enum):
348
- """
349
- Reasons for order cancellation.
350
-
351
- **Attributes:**
352
-
353
- | Enum | Value | Description |
354
- |------|-------|-------------|
355
- | `CLIENT_REQUEST` | `enum.auto()` | Order cancelled by client/trader request |
356
- | `EXPIRED_TIME_IN_FORCE` | `enum.auto()` | Order expired due to time-in-force constraints |
357
- | `BROKER_REJECTED_AT_SUBMISSION` | `enum.auto()` | Broker rejected order during submission |
358
- | `BROKER_FORCED_CANCEL` | `enum.auto()` | Broker cancelled order due to risk or other constraints |
359
- | `UNKNOWN` | `enum.auto()` | Cancellation reason not specified or unknown |
360
- """
361
-
362
- CLIENT_REQUEST = enum.auto()
363
- EXPIRED_TIME_IN_FORCE = enum.auto()
364
- BROKER_REJECTED_AT_SUBMISSION = enum.auto()
365
- BROKER_FORCED_CANCEL = enum.auto()
366
- UNKNOWN = enum.auto()
367
-
368
- # ----------------------------------------------------------------------------------
369
- # MARKET DATA DOMAIN MODEL NAMESPACE
370
- # ----------------------------------------------------------------------------------
371
-
372
- class MarketData:
373
- """
374
- Domain model namespace for market data related concepts.
375
- (Can be aliased as `MarketData` for convenience.)
376
-
377
- ???+ note "Domain Model Hierarchy"
378
-
379
- ```mermaid
380
- ---
381
- config:
382
- themeVariables:
383
- fontSize: "11px"
384
- ---
385
- graph LR
386
-
387
- A0[DomainModels]
388
-
389
- A01[MarketData]
390
- A02[PositionManagement]
391
- A03[SystemManagement]
392
-
393
- A0 --> A01
394
- A0 --> A02
395
- A0 --> A03
396
-
397
- A1["**MarketData.OHLCV**"]
398
- A2["**MarketData.RecordType**"]
399
- A01 --> A1
400
- A01 --> A2
401
-
402
- B1["**PositionManagement.OrderType**"]
403
- B2["**PositionManagement.OrderState**"]
404
- B3["**PositionManagement.Side**"]
405
- B4["**PositionManagement.TimeInForce**"]
406
- B5["**PositionManagement.CancelReason**"]
407
- A02 --> B1
408
- A02 --> B2
409
- A02 --> B3
410
- A02 --> B4
411
- A02 --> B5
412
-
413
- C1["**SystemManagement.StopReason**"]
414
- A03 --> C1
415
-
416
- subgraph MarketData ["Market Data Domain Models"]
417
- A1
418
- A2
419
- end
420
-
421
- subgraph PositionManagement ["Position Management Domain Models"]
422
- B1
423
- B2
424
- B3
425
- B4
426
- B5
427
- end
428
-
429
- subgraph SystemManagement ["System Management Domain Models"]
430
- C1
431
- end
432
-
433
- subgraph DomainModelNamespaces ["Domain Model Namespaces"]
434
- A0
435
- A01
436
- A02
437
- A03
438
- end
439
-
440
- style MarketData fill:#6F42C1,fill-opacity:0.3
441
- ```
442
- """
443
-
444
- # ------------------------------------------------------------------------------
445
- # OHLCV
446
-
447
- OHLCV = collections.namedtuple(
448
- "OHLCV", ["open", "high", "low", "close", "volume"]
449
- )
450
- """
451
- Simple data class for Open-High-Low-Close-Volume (OHLCV) bar data.
452
-
453
- Attributes:
454
- open (float): Open price
455
- high (float): High price
456
- low (float): Low price
457
- close (float): Close price
458
- volume (int | float): Volume
459
-
460
- Examples:
461
- >>> from onesecondtrader.domain.models import MarketData
462
- >>> bar = MarketData.OHLCV(12.34, 13.74, 11.26, 12.32, 56789)
463
- >>> bar.open
464
- 12.34
465
- >>> bar.high
466
- 13.74
467
- """
468
-
469
- # ------------------------------------------------------------------------------
470
- # RECORD TYPE
471
-
472
- class RecordType(enum.Enum):
473
- """
474
- Market data record type identifiers that preserve compatibility with
475
- Databento's rtype integer identifiers.
476
-
477
- **Attributes:**
478
-
479
- | Enum | Value | Description |
480
- |------|-------|-------------|
481
- | `OHLCV_1S` | `32` | 1-second bars |
482
- | `OHLCV_1M` | `33` | 1-minute bars |
483
- | `OHLCV_1H` | `34` | 1-hour bars |
484
- | `OHLCV_1D` | `35` | Daily bars |
485
-
486
-
487
- Examples:
488
- >>> from onesecondtrader.domain.models import MarketData
489
- >>> MarketData.RecordType.OHLCV_1S
490
- <MarketData.RecordType.OHLCV_1S: 32>
491
- >>> MarketData.RecordType.OHLCV_1S.value
492
- 32
493
- >>> MarketData.RecordType.to_string(32)
494
- '1-second bars'
495
- >>> MarketData.RecordType.to_string(99)
496
- 'unknown (99)'
497
- """
498
-
499
- OHLCV_1S = 32
500
- OHLCV_1M = 33
501
- OHLCV_1H = 34
502
- OHLCV_1D = 35
503
-
504
- @classmethod
505
- def to_string(cls, record_type: int) -> str:
506
- match record_type:
507
- case cls.OHLCV_1S.value:
508
- return "1-second bars"
509
- case cls.OHLCV_1M.value:
510
- return "1-minute bars"
511
- case cls.OHLCV_1H.value:
512
- return "1-hour bars"
513
- case cls.OHLCV_1D.value:
514
- return "daily bars"
515
- case _:
516
- return f"unknown ({record_type})"
517
-
518
-
519
- # --------------------------------------------------------------------------------------
520
- # ALIASES
521
- # --------------------------------------------------------------------------------------
522
-
523
-
524
- MarketData = DomainModel.MarketData
525
- PositionManagement = DomainModel.PositionManagement
526
- SystemManagement = DomainModel.SystemManagement
File without changes