onesecondtrader 0.29.0__py3-none-any.whl → 0.31.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/indicators/__init__.py +8 -0
- onesecondtrader/indicators/averages.py +56 -0
- onesecondtrader/indicators/bar.py +47 -0
- onesecondtrader/models/__init__.py +2 -1
- onesecondtrader/models/data.py +8 -0
- {onesecondtrader-0.29.0.dist-info → onesecondtrader-0.31.0.dist-info}/METADATA +1 -1
- {onesecondtrader-0.29.0.dist-info → onesecondtrader-0.31.0.dist-info}/RECORD +10 -8
- {onesecondtrader-0.29.0.dist-info → onesecondtrader-0.31.0.dist-info}/WHEEL +0 -0
- {onesecondtrader-0.29.0.dist-info → onesecondtrader-0.31.0.dist-info}/licenses/LICENSE +0 -0
onesecondtrader/__init__.py
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import collections
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
from onesecondtrader import events, models
|
|
8
|
+
from .base import Indicator
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SimpleMovingAverage(Indicator):
|
|
12
|
+
def __init__(
|
|
13
|
+
self,
|
|
14
|
+
period: int = 200,
|
|
15
|
+
max_history: int = 100,
|
|
16
|
+
input_source: models.InputSource = models.InputSource.CLOSE,
|
|
17
|
+
plot_at: int = 0,
|
|
18
|
+
) -> None:
|
|
19
|
+
super().__init__(max_history=max_history, plot_at=plot_at)
|
|
20
|
+
self.period: int = max(1, int(period))
|
|
21
|
+
self.input_source: models.InputSource = input_source
|
|
22
|
+
self._window: dict[str, collections.deque[float]] = {}
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def name(self) -> str:
|
|
26
|
+
return f"SMA_{self.period}_{self.input_source.name}"
|
|
27
|
+
|
|
28
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
29
|
+
symbol = incoming_bar.symbol
|
|
30
|
+
if symbol not in self._window:
|
|
31
|
+
self._window[symbol] = collections.deque(maxlen=self.period)
|
|
32
|
+
window = self._window[symbol]
|
|
33
|
+
value = self._extract_input(incoming_bar)
|
|
34
|
+
window.append(value)
|
|
35
|
+
if len(window) < self.period:
|
|
36
|
+
return np.nan
|
|
37
|
+
return sum(window) / self.period
|
|
38
|
+
|
|
39
|
+
def _extract_input(self, incoming_bar: events.BarReceived) -> float:
|
|
40
|
+
match self.input_source:
|
|
41
|
+
case models.InputSource.OPEN:
|
|
42
|
+
return incoming_bar.open
|
|
43
|
+
case models.InputSource.HIGH:
|
|
44
|
+
return incoming_bar.high
|
|
45
|
+
case models.InputSource.LOW:
|
|
46
|
+
return incoming_bar.low
|
|
47
|
+
case models.InputSource.CLOSE:
|
|
48
|
+
return incoming_bar.close
|
|
49
|
+
case models.InputSource.VOLUME:
|
|
50
|
+
return (
|
|
51
|
+
float(incoming_bar.volume)
|
|
52
|
+
if incoming_bar.volume is not None
|
|
53
|
+
else np.nan
|
|
54
|
+
)
|
|
55
|
+
case _:
|
|
56
|
+
return incoming_bar.close
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from onesecondtrader import events
|
|
2
|
+
from .base import Indicator
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class Open(Indicator):
|
|
6
|
+
@property
|
|
7
|
+
def name(self) -> str:
|
|
8
|
+
return "OPEN"
|
|
9
|
+
|
|
10
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
11
|
+
return incoming_bar.open
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class High(Indicator):
|
|
15
|
+
@property
|
|
16
|
+
def name(self) -> str:
|
|
17
|
+
return "HIGH"
|
|
18
|
+
|
|
19
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
20
|
+
return incoming_bar.high
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Low(Indicator):
|
|
24
|
+
@property
|
|
25
|
+
def name(self) -> str:
|
|
26
|
+
return "LOW"
|
|
27
|
+
|
|
28
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
29
|
+
return incoming_bar.low
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class Close(Indicator):
|
|
33
|
+
@property
|
|
34
|
+
def name(self) -> str:
|
|
35
|
+
return "CLOSE"
|
|
36
|
+
|
|
37
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
38
|
+
return incoming_bar.close
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Volume(Indicator):
|
|
42
|
+
@property
|
|
43
|
+
def name(self) -> str:
|
|
44
|
+
return "VOLUME"
|
|
45
|
+
|
|
46
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
47
|
+
return float(incoming_bar.volume) if incoming_bar.volume is not None else 0.0
|
onesecondtrader/models/data.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.31.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,4 @@
|
|
|
1
|
-
onesecondtrader/__init__.py,sha256=
|
|
1
|
+
onesecondtrader/__init__.py,sha256=edb0kipMTx0p-utX0tc4J8IbhFrZprX200oxhX8LzH4,241
|
|
2
2
|
onesecondtrader/brokers/__init__.py,sha256=YofzD0qlrfo_BzL6gwiHb9by7Webp36TQ_1O5EV0uzY,124
|
|
3
3
|
onesecondtrader/brokers/base.py,sha256=b6Xq2gBUdy3RTpnUfpUiNSXwbuq_bRIjXJ-s89Xu7nE,1345
|
|
4
4
|
onesecondtrader/brokers/simulated.py,sha256=pJvZ7b76xAs-NBbOX_v78IJgVrdnuTLCadqj8kYQ5sg,12694
|
|
@@ -7,15 +7,17 @@ onesecondtrader/events/bases.py,sha256=g-ykq2jgcitIAueRurUlqAq0jINQwuhSWi_khAniP
|
|
|
7
7
|
onesecondtrader/events/market.py,sha256=IfHuIGfp_IUiw-dFay4c4RYmkoNzshxbhuWTglBqfN0,509
|
|
8
8
|
onesecondtrader/events/requests.py,sha256=2KXwSckiar9-fy8wkN3vcSIeOkeBfeo_XhUhrNKEd2Q,831
|
|
9
9
|
onesecondtrader/events/responses.py,sha256=w_BH1nkkPyxQjh30EXEVFcUGDoMprFc2PuAaqpVrQ8A,1436
|
|
10
|
-
onesecondtrader/indicators/__init__.py,sha256=
|
|
10
|
+
onesecondtrader/indicators/__init__.py,sha256=hRg3FCP1FT7LYOLzztybWn48gTR5QvewzzdELPYbdoY,239
|
|
11
|
+
onesecondtrader/indicators/averages.py,sha256=DpRRdY5G5ze3jwNOV19PPjV6slA0IEeOOla67yChi2Y,1900
|
|
12
|
+
onesecondtrader/indicators/bar.py,sha256=0H07mKNiUx5cE1fQvx1oPVY0R_MXcmAAgsLek175vTk,1115
|
|
11
13
|
onesecondtrader/indicators/base.py,sha256=WGqjp9mmkR2PZ5ZC8zL9ddeTfUrB0hX3bjnq1W4HKuI,1658
|
|
12
14
|
onesecondtrader/messaging/__init__.py,sha256=vMRDabHBgse_vZRTRFtnU8M8v2sY_o4pHjGzgu3hp3E,115
|
|
13
15
|
onesecondtrader/messaging/eventbus.py,sha256=Y8VbDZlEz8Q6KcCkfXRKsVIixsctBMRW1a5ANw297Ls,1576
|
|
14
16
|
onesecondtrader/messaging/subscriber.py,sha256=ImpFmu5IstLXLoKVMaebmLp5MXN6225vHLdTL1ZOPvw,2106
|
|
15
|
-
onesecondtrader/models/__init__.py,sha256=
|
|
16
|
-
onesecondtrader/models/data.py,sha256=
|
|
17
|
+
onesecondtrader/models/__init__.py,sha256=0J91ixFxYRaZ9t-dm_LVh7xh1ukb3G7H1GgelZg68as,167
|
|
18
|
+
onesecondtrader/models/data.py,sha256=fBmddVl6EXYC5u2UnvQ59DXAXeZeIb48KP1ZdeTL52A,322
|
|
17
19
|
onesecondtrader/models/orders.py,sha256=y6Ar-6fMqaOd_hRnRGvfWUF0Z13H_2hfTOW3ROOk0A8,254
|
|
18
|
-
onesecondtrader-0.
|
|
19
|
-
onesecondtrader-0.
|
|
20
|
-
onesecondtrader-0.
|
|
21
|
-
onesecondtrader-0.
|
|
20
|
+
onesecondtrader-0.31.0.dist-info/METADATA,sha256=OnASDmSzTXcJ2jmviGqe8qkF3xp8g3B4fAmicO3rDF0,9682
|
|
21
|
+
onesecondtrader-0.31.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
22
|
+
onesecondtrader-0.31.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
23
|
+
onesecondtrader-0.31.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|