onesecondtrader 0.5.1__py3-none-any.whl → 0.5.3__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 +3 -2
- onesecondtrader/domain/__init__.py +13 -0
- onesecondtrader/{domain.py → domain/models.py} +5 -174
- {onesecondtrader-0.5.1.dist-info → onesecondtrader-0.5.3.dist-info}/METADATA +1 -1
- onesecondtrader-0.5.3.dist-info/RECORD +8 -0
- onesecondtrader-0.5.1.dist-info/RECORD +0 -7
- /onesecondtrader/{log_config.py → monitoring.py} +0 -0
- {onesecondtrader-0.5.1.dist-info → onesecondtrader-0.5.3.dist-info}/LICENSE +0 -0
- {onesecondtrader-0.5.1.dist-info → onesecondtrader-0.5.3.dist-info}/WHEEL +0 -0
onesecondtrader/__init__.py
CHANGED
|
@@ -5,15 +5,16 @@ Research, simulate, and deploy algorithmic trading strategies — all in one pla
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
# Core infrastructure
|
|
8
|
-
from .
|
|
8
|
+
from .monitoring import logger
|
|
9
9
|
|
|
10
10
|
# Domain models
|
|
11
|
-
from .domain import MarketData, PositionManagement, SystemManagement
|
|
11
|
+
from .domain.models import DomainModel, MarketData, PositionManagement, SystemManagement
|
|
12
12
|
|
|
13
13
|
__all__ = [
|
|
14
14
|
# Core infrastructure
|
|
15
15
|
"logger",
|
|
16
16
|
# Domain models
|
|
17
|
+
"DomainModel",
|
|
17
18
|
"MarketData",
|
|
18
19
|
"PositionManagement",
|
|
19
20
|
"SystemManagement",
|
|
@@ -0,0 +1,13 @@
|
|
|
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,26 +1,12 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Container module for non-component-specific domain models.
|
|
3
3
|
|
|
4
|
-
This module provides
|
|
5
|
-
|
|
6
|
-
- the **non-component-specific domain models** used across the
|
|
7
|
-
trading infrastructure and
|
|
8
|
-
- the **event messages** used for decoupled communication
|
|
9
|
-
between the trading infrastructure's components.
|
|
4
|
+
This module provides the non-component-specific domain models used across the
|
|
5
|
+
trading infrastructure.
|
|
10
6
|
"""
|
|
11
7
|
|
|
12
8
|
import collections
|
|
13
|
-
import dataclasses
|
|
14
9
|
import enum
|
|
15
|
-
import pandas as pd
|
|
16
|
-
import uuid
|
|
17
|
-
|
|
18
|
-
from .log_config import logger
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
########################################################################################
|
|
22
|
-
# DOMAIN MODELS
|
|
23
|
-
########################################################################################
|
|
24
10
|
|
|
25
11
|
|
|
26
12
|
class DomainModel:
|
|
@@ -472,7 +458,7 @@ class DomainModel:
|
|
|
472
458
|
volume (int | float): Volume
|
|
473
459
|
|
|
474
460
|
Examples:
|
|
475
|
-
>>> from onesecondtrader.domain import MarketData
|
|
461
|
+
>>> from onesecondtrader.domain.models import MarketData
|
|
476
462
|
>>> bar = MarketData.OHLCV(12.34, 13.74, 11.26, 12.32, 56789)
|
|
477
463
|
>>> bar.open
|
|
478
464
|
12.34
|
|
@@ -499,7 +485,7 @@ class DomainModel:
|
|
|
499
485
|
|
|
500
486
|
|
|
501
487
|
Examples:
|
|
502
|
-
>>> from onesecondtrader.domain import MarketData
|
|
488
|
+
>>> from onesecondtrader.domain.models import MarketData
|
|
503
489
|
>>> MarketData.RecordType.OHLCV_1S
|
|
504
490
|
<MarketData.RecordType.OHLCV_1S: 32>
|
|
505
491
|
>>> MarketData.RecordType.OHLCV_1S.value
|
|
@@ -538,158 +524,3 @@ class DomainModel:
|
|
|
538
524
|
MarketData = DomainModel.MarketData
|
|
539
525
|
PositionManagement = DomainModel.PositionManagement
|
|
540
526
|
SystemManagement = DomainModel.SystemManagement
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
########################################################################################
|
|
544
|
-
# DOMAIN EVENTS
|
|
545
|
-
########################################################################################
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
class Event:
|
|
549
|
-
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
550
|
-
class _AbstractEvent:
|
|
551
|
-
"""
|
|
552
|
-
Root base class for all event types in the trading system.
|
|
553
|
-
|
|
554
|
-
This class prevents instantiation of any class that has subclasses.
|
|
555
|
-
Only leaf classes (classes with no children) can be instantiated. This ensures
|
|
556
|
-
that only concrete event classes can be created, while base/parent classes
|
|
557
|
-
remain non-instantiable.
|
|
558
|
-
|
|
559
|
-
The check is performed dynamically at instantiation time, so it automatically
|
|
560
|
-
adapts to changes in the inheritance hierarchy without manual maintenance.
|
|
561
|
-
|
|
562
|
-
Attributes:
|
|
563
|
-
ts_event (pd.Timestamp): Timestamp of the event. Must be timezone-aware.
|
|
564
|
-
event_id (uuid.UUID): Unique identifier for the event. Automatically
|
|
565
|
-
generated.
|
|
566
|
-
sequence_number (int | None): Global sequence number assigned by the event
|
|
567
|
-
bus at publish time.
|
|
568
|
-
"""
|
|
569
|
-
|
|
570
|
-
ts_event: pd.Timestamp
|
|
571
|
-
event_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
|
|
572
|
-
sequence_number: int | None = dataclasses.field(default=None, init=False)
|
|
573
|
-
|
|
574
|
-
@staticmethod
|
|
575
|
-
def _has_subclasses(cls):
|
|
576
|
-
"""
|
|
577
|
-
Check if a class has any subclasses (direct or indirect).
|
|
578
|
-
|
|
579
|
-
Args:
|
|
580
|
-
cls: The class to check for subclasses.
|
|
581
|
-
|
|
582
|
-
Returns:
|
|
583
|
-
bool: True if the class has any subclasses, False otherwise.
|
|
584
|
-
"""
|
|
585
|
-
|
|
586
|
-
def get_all_subclasses(cls):
|
|
587
|
-
all_subclasses = set()
|
|
588
|
-
for subclass in cls.__subclasses__():
|
|
589
|
-
all_subclasses.add(subclass)
|
|
590
|
-
all_subclasses.update(get_all_subclasses(subclass))
|
|
591
|
-
return all_subclasses
|
|
592
|
-
|
|
593
|
-
return len(get_all_subclasses(cls)) > 0
|
|
594
|
-
|
|
595
|
-
def __new__(cls, *args, **kwargs):
|
|
596
|
-
"""
|
|
597
|
-
Prevent instantiation of classes that have subclasses.
|
|
598
|
-
|
|
599
|
-
Only allows instantiation of leaf classes (classes with no children).
|
|
600
|
-
|
|
601
|
-
Raises:
|
|
602
|
-
TypeError: If attempting to instantiate a class that has subclasses.
|
|
603
|
-
"""
|
|
604
|
-
if Event._AbstractEvent._has_subclasses(cls):
|
|
605
|
-
subclass_names = [subcls.__name__ for subcls in cls.__subclasses__()]
|
|
606
|
-
logger.error(
|
|
607
|
-
f"Cannot instantiate class '{cls.__name__}' because it has subclasses: "
|
|
608
|
-
f"{subclass_names}. Only leaf classes (classes with no children) can be instantiated."
|
|
609
|
-
)
|
|
610
|
-
return super().__new__(cls)
|
|
611
|
-
|
|
612
|
-
def __post_init__(self) -> None:
|
|
613
|
-
if self.ts_event.tz is None:
|
|
614
|
-
raise ValueError(
|
|
615
|
-
f"Event timestamp should be timezone-aware, "
|
|
616
|
-
f"got timezone-naive: {self.ts_event}"
|
|
617
|
-
)
|
|
618
|
-
|
|
619
|
-
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
620
|
-
class _AbstractMarketUpdateEvent(_AbstractEvent):
|
|
621
|
-
"""
|
|
622
|
-
Base class for events related to market data updates.
|
|
623
|
-
|
|
624
|
-
Attributes:
|
|
625
|
-
ts_event (pd.Timestamp): Timestamp of the event. Must be timezone-aware.
|
|
626
|
-
event_id (uuid.UUID): Unique identifier for the event. (auto-generated)
|
|
627
|
-
sequence_number (int | None): Global sequence number assigned by the event
|
|
628
|
-
bus at publish time.
|
|
629
|
-
symbol (str): The financial instrument symbol.
|
|
630
|
-
"""
|
|
631
|
-
|
|
632
|
-
symbol: str
|
|
633
|
-
|
|
634
|
-
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
635
|
-
class _AbstractBrokerRequest(_AbstractEvent):
|
|
636
|
-
"""
|
|
637
|
-
Base class for broker request events.
|
|
638
|
-
|
|
639
|
-
Attributes:
|
|
640
|
-
ts_event (pd.Timestamp): Timestamp of the request. (defaults to current
|
|
641
|
-
UTC time)
|
|
642
|
-
event_id (uuid.UUID): Unique identifier for the event. (auto-generated)
|
|
643
|
-
sequence_number (int | None): Global sequence number assigned by the event
|
|
644
|
-
bus at publish time.
|
|
645
|
-
symbol (str): The financial instrument symbol.
|
|
646
|
-
"""
|
|
647
|
-
|
|
648
|
-
symbol: str
|
|
649
|
-
ts_event: pd.Timestamp = dataclasses.field(
|
|
650
|
-
default_factory=lambda: pd.Timestamp.now(tz="UTC")
|
|
651
|
-
)
|
|
652
|
-
|
|
653
|
-
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
654
|
-
class _AbstractBrokerResponse(_AbstractEvent):
|
|
655
|
-
"""
|
|
656
|
-
Base class for broker response events.
|
|
657
|
-
|
|
658
|
-
Attributes:
|
|
659
|
-
ts_event (pd.Timestamp): Timestamp of the event. Must be timezone-aware.
|
|
660
|
-
event_id (uuid.UUID): Unique identifier for the event. (auto-generated)
|
|
661
|
-
sequence_number (int | None): Global sequence number assigned by the event
|
|
662
|
-
bus at publish time.
|
|
663
|
-
symbol (str): The financial instrument symbol.
|
|
664
|
-
"""
|
|
665
|
-
|
|
666
|
-
symbol: str
|
|
667
|
-
|
|
668
|
-
@dataclasses.dataclass(kw_only=True, frozen=True)
|
|
669
|
-
class _AbstractSystemEvent(_AbstractEvent):
|
|
670
|
-
"""
|
|
671
|
-
Base class for system-level events.
|
|
672
|
-
|
|
673
|
-
Attributes:
|
|
674
|
-
ts_event (pd.Timestamp): Timestamp of the event. Must be timezone-aware.
|
|
675
|
-
event_id (uuid.UUID): Unique identifier for the event. (auto-generated)
|
|
676
|
-
sequence_number (int | None): Global sequence number assigned by the event
|
|
677
|
-
bus at publish time.
|
|
678
|
-
"""
|
|
679
|
-
|
|
680
|
-
pass
|
|
681
|
-
|
|
682
|
-
class MarketUpdate:
|
|
683
|
-
pass
|
|
684
|
-
|
|
685
|
-
class BrokerRequest:
|
|
686
|
-
pass
|
|
687
|
-
|
|
688
|
-
class Order:
|
|
689
|
-
pass
|
|
690
|
-
|
|
691
|
-
class BrokerResponse:
|
|
692
|
-
pass
|
|
693
|
-
|
|
694
|
-
class System:
|
|
695
|
-
pass
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.3
|
|
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,8 @@
|
|
|
1
|
+
onesecondtrader/__init__.py,sha256=58MDAIjNTzzg0fqH3b6Tgf2Cifzq9w5MdWUWVnzQa9I,462
|
|
2
|
+
onesecondtrader/domain/__init__.py,sha256=1KLObrd6j_QuA7_yws0ajZYyVEb1QC3toakvmcd_nsE,311
|
|
3
|
+
onesecondtrader/domain/models.py,sha256=qU3S27TgQJ1uIbM1TPF6poDFOFbrImHw8EADDMw_zi0,16523
|
|
4
|
+
onesecondtrader/monitoring.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
5
|
+
onesecondtrader-0.5.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
6
|
+
onesecondtrader-0.5.3.dist-info/METADATA,sha256=Hkyti4cDKugO46y9x_4h3gTAyCpsP91pzYYPKX0Xmhs,1220
|
|
7
|
+
onesecondtrader-0.5.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
8
|
+
onesecondtrader-0.5.3.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
onesecondtrader/__init__.py,sha256=RIGF18ux5aem5xZJ07XwXSi9GU3Rthqrv9IEJeUKj78,423
|
|
2
|
-
onesecondtrader/domain.py,sha256=9DWsWKhwzTVWrXhtI12rH6jmbi_xaLo_Uc5LcIhG1G4,22523
|
|
3
|
-
onesecondtrader/log_config.py,sha256=TGm53SD_TA4Xa57Go91BGHV3SEIA6MflwSO63r9Jt6g,366
|
|
4
|
-
onesecondtrader-0.5.1.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
5
|
-
onesecondtrader-0.5.1.dist-info/METADATA,sha256=ebQudnGj1NjergnSFfrQ1hKj3UrVFL-GyQUtpY-4A2s,1220
|
|
6
|
-
onesecondtrader-0.5.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
7
|
-
onesecondtrader-0.5.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|