onesecondtrader 0.17.0__tar.gz → 0.18.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.4
2
2
  Name: onesecondtrader
3
- Version: 0.17.0
3
+ Version: 0.18.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.17.0"
3
+ version = "0.18.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"}
@@ -8,6 +8,7 @@ import enum
8
8
  import pandas as pd
9
9
  import queue
10
10
  import threading
11
+ import uuid
11
12
 
12
13
  from collections import defaultdict
13
14
 
@@ -23,6 +24,16 @@ class Models:
23
24
  OHLCV_1H = 34
24
25
  OHLCV_1D = 35
25
26
 
27
+ class OrderSide(enum.Enum):
28
+ BUY = enum.auto()
29
+ SELL = enum.auto()
30
+
31
+ class OrderType(enum.Enum):
32
+ MARKET = enum.auto()
33
+ LIMIT = enum.auto()
34
+ STOP = enum.auto()
35
+ STOP_LIMIT = enum.auto()
36
+
26
37
 
27
38
  class Events:
28
39
  """
@@ -35,10 +46,12 @@ class Events:
35
46
  default_factory=lambda: pd.Timestamp.now(tz="UTC")
36
47
  )
37
48
 
49
+ # SYSTEM EVENTS
38
50
  @dataclasses.dataclass(kw_only=True, frozen=True)
39
51
  class SystemShutdown(BaseEvent):
40
52
  pass
41
53
 
54
+ # MARKET EVENTS
42
55
  @dataclasses.dataclass(kw_only=True, frozen=True)
43
56
  class IncomingBar(BaseEvent):
44
57
  ts_event: pd.Timestamp
@@ -50,6 +63,29 @@ class Events:
50
63
  close: float
51
64
  volume: int | None = None
52
65
 
66
+ # BROKER REQUEST EVENTS
67
+ @dataclasses.dataclass(kw_only=True, frozen=True)
68
+ class Order(BaseEvent):
69
+ order_id: uuid.UUID = dataclasses.field(default_factory=lambda: uuid.uuid4())
70
+ symbol: str
71
+ order_type: Models.OrderType
72
+ side: Models.OrderSide
73
+ quantity: float
74
+ limit_price: float | None = None
75
+ stop_price: float | None = None
76
+
77
+ # BROKER RESPONSE EVENTS
78
+ @dataclasses.dataclass(kw_only=True, frozen=True)
79
+ class Fill(BaseEvent):
80
+ fill_id: uuid.UUID = dataclasses.field(default_factory=uuid.uuid4)
81
+ broker_fill_id: str | None = None
82
+ associated_order_id: uuid.UUID
83
+ side: Models.OrderSide
84
+ quantity_filled: float
85
+ fill_price: float
86
+ commission: float
87
+ exchange: str = "SIMULATED"
88
+
53
89
 
54
90
  class BaseConsumer(abc.ABC):
55
91
  """
@@ -103,3 +139,9 @@ class EventBus:
103
139
  consumers = list(self._subscriptions[type(event)])
104
140
  for consumer in consumers:
105
141
  consumer.receive(event)
142
+
143
+
144
+ event_bus = EventBus()
145
+ """
146
+ Global event bus instance.
147
+ """