onesecondtrader 0.26.0__py3-none-any.whl → 0.27.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/brokers/__init__.py +5 -0
- onesecondtrader/brokers/base.py +39 -0
- onesecondtrader/messaging/subscriber.py +3 -1
- {onesecondtrader-0.26.0.dist-info → onesecondtrader-0.27.0.dist-info}/METADATA +1 -1
- {onesecondtrader-0.26.0.dist-info → onesecondtrader-0.27.0.dist-info}/RECORD +7 -5
- {onesecondtrader-0.26.0.dist-info → onesecondtrader-0.27.0.dist-info}/WHEEL +0 -0
- {onesecondtrader-0.26.0.dist-info → onesecondtrader-0.27.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import abc
|
|
2
|
+
|
|
3
|
+
from onesecondtrader import events, messaging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class BrokerBase(messaging.Subscriber):
|
|
7
|
+
def __init__(self, event_bus: messaging.EventBus) -> None:
|
|
8
|
+
super().__init__(event_bus)
|
|
9
|
+
self._subscribe(
|
|
10
|
+
events.requests.OrderSubmission,
|
|
11
|
+
events.requests.OrderCancellation,
|
|
12
|
+
events.requests.OrderModification,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def _on_event(self, event: events.bases.EventBase) -> None:
|
|
16
|
+
match event:
|
|
17
|
+
case events.requests.OrderSubmission() as submit_order:
|
|
18
|
+
self._on_submit_order(submit_order)
|
|
19
|
+
case events.requests.OrderCancellation() as cancel_order:
|
|
20
|
+
self._on_cancel_order(cancel_order)
|
|
21
|
+
case events.requests.OrderModification() as modify_order:
|
|
22
|
+
self._on_modify_order(modify_order)
|
|
23
|
+
case _:
|
|
24
|
+
return
|
|
25
|
+
|
|
26
|
+
@abc.abstractmethod
|
|
27
|
+
def _on_submit_order(self, event: events.requests.OrderSubmission) -> None:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@abc.abstractmethod
|
|
31
|
+
def _on_cancel_order(self, event: events.requests.OrderCancellation) -> None:
|
|
32
|
+
pass
|
|
33
|
+
|
|
34
|
+
@abc.abstractmethod
|
|
35
|
+
def _on_modify_order(self, event: events.requests.OrderModification) -> None:
|
|
36
|
+
pass
|
|
37
|
+
|
|
38
|
+
def _respond(self, response_event: events.bases.BrokerResponseEvent) -> None:
|
|
39
|
+
self._publish(response_event)
|
|
@@ -36,10 +36,12 @@ class Subscriber(abc.ABC):
|
|
|
36
36
|
self._thread.join()
|
|
37
37
|
|
|
38
38
|
def _subscribe(self, *event_types: type[events.bases.EventBase]) -> None:
|
|
39
|
-
# Call as last line of subclass __init__ to avoid receiving events before fully initialized
|
|
40
39
|
for event_type in event_types:
|
|
41
40
|
self._event_bus.subscribe(self, event_type)
|
|
42
41
|
|
|
42
|
+
def _publish(self, event: events.bases.EventBase) -> None:
|
|
43
|
+
self._event_bus.publish(event)
|
|
44
|
+
|
|
43
45
|
def _event_loop(self) -> None:
|
|
44
46
|
while True:
|
|
45
47
|
event = self._queue.get()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.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,4 +1,6 @@
|
|
|
1
1
|
onesecondtrader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
onesecondtrader/brokers/__init__.py,sha256=n-idxbvvlPrAnbxdA7l6S3ecRVqgroTZ0XBkse8GamQ,62
|
|
3
|
+
onesecondtrader/brokers/base.py,sha256=b6Xq2gBUdy3RTpnUfpUiNSXwbuq_bRIjXJ-s89Xu7nE,1345
|
|
2
4
|
onesecondtrader/events/__init__.py,sha256=IOlFRdiOXz93SpvkpKL8wr1954d_8olKSB1n9mlTL3Y,898
|
|
3
5
|
onesecondtrader/events/bases.py,sha256=g-ykq2jgcitIAueRurUlqAq0jINQwuhSWi_khAniPHw,662
|
|
4
6
|
onesecondtrader/events/market.py,sha256=IfHuIGfp_IUiw-dFay4c4RYmkoNzshxbhuWTglBqfN0,509
|
|
@@ -6,11 +8,11 @@ onesecondtrader/events/requests.py,sha256=2KXwSckiar9-fy8wkN3vcSIeOkeBfeo_XhUhrN
|
|
|
6
8
|
onesecondtrader/events/responses.py,sha256=w_BH1nkkPyxQjh30EXEVFcUGDoMprFc2PuAaqpVrQ8A,1436
|
|
7
9
|
onesecondtrader/messaging/__init__.py,sha256=vMRDabHBgse_vZRTRFtnU8M8v2sY_o4pHjGzgu3hp3E,115
|
|
8
10
|
onesecondtrader/messaging/eventbus.py,sha256=rTBDmtXKnUAVdOBeLyIn2pJmBLz9AszHGIcuOcVhEQI,1501
|
|
9
|
-
onesecondtrader/messaging/subscriber.py,sha256=
|
|
11
|
+
onesecondtrader/messaging/subscriber.py,sha256=ImpFmu5IstLXLoKVMaebmLp5MXN6225vHLdTL1ZOPvw,2106
|
|
10
12
|
onesecondtrader/models/__init__.py,sha256=cH5xyniz78MQjM9_-fFdP1ZW6FFLTmayMwQauFO23bU,135
|
|
11
13
|
onesecondtrader/models/data.py,sha256=TqUvTtjpmzTJT8ZdTYnlVoyI7Qck2IsseCazWZxJgD0,173
|
|
12
14
|
onesecondtrader/models/orders.py,sha256=y6Ar-6fMqaOd_hRnRGvfWUF0Z13H_2hfTOW3ROOk0A8,254
|
|
13
|
-
onesecondtrader-0.
|
|
14
|
-
onesecondtrader-0.
|
|
15
|
-
onesecondtrader-0.
|
|
16
|
-
onesecondtrader-0.
|
|
15
|
+
onesecondtrader-0.27.0.dist-info/METADATA,sha256=aHM_QsfmD8cIv5lqkvVFIveYEx5SxHsS1NjqaumOuXI,9682
|
|
16
|
+
onesecondtrader-0.27.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
17
|
+
onesecondtrader-0.27.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
18
|
+
onesecondtrader-0.27.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|