onesecondtrader 0.28.0__tar.gz → 0.29.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.
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/PKG-INFO +1 -1
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/pyproject.toml +1 -1
- onesecondtrader-0.29.0/src/onesecondtrader/indicators/__init__.py +5 -0
- onesecondtrader-0.29.0/src/onesecondtrader/indicators/base.py +50 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/LICENSE +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/README.md +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/__init__.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/brokers/__init__.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/brokers/base.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/brokers/simulated.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/events/__init__.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/events/bases.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/events/market.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/events/requests.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/events/responses.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/messaging/__init__.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/messaging/eventbus.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/messaging/subscriber.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/models/__init__.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/models/data.py +0 -0
- {onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/models/orders.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: onesecondtrader
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.29.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.
|
|
3
|
+
version = "0.29.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"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import abc
|
|
4
|
+
import collections
|
|
5
|
+
import threading
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from onesecondtrader import events
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Indicator(abc.ABC):
|
|
13
|
+
def __init__(self, max_history: int = 100, plot_at: int = 99) -> None:
|
|
14
|
+
self._lock = threading.Lock()
|
|
15
|
+
self._max_history = max(1, int(max_history))
|
|
16
|
+
# Keyed by symbol only - each strategy subscribes to one timeframe, so the indicator only sees bars from that timeframe.
|
|
17
|
+
self._history: dict[str, collections.deque[float]] = {}
|
|
18
|
+
# 0 = main price chart, 1-98 = subcharts, 99 = no plot
|
|
19
|
+
self._plot_at = plot_at
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
@abc.abstractmethod
|
|
23
|
+
def name(self) -> str:
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
@abc.abstractmethod
|
|
27
|
+
def _compute_indicator(self, incoming_bar: events.BarReceived) -> float:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
def update(self, incoming_bar: events.BarReceived) -> None:
|
|
31
|
+
symbol = incoming_bar.symbol
|
|
32
|
+
value = self._compute_indicator(incoming_bar)
|
|
33
|
+
with self._lock:
|
|
34
|
+
if symbol not in self._history:
|
|
35
|
+
self._history[symbol] = collections.deque(maxlen=self._max_history)
|
|
36
|
+
self._history[symbol].append(value)
|
|
37
|
+
|
|
38
|
+
def latest(self, symbol: str) -> float:
|
|
39
|
+
with self._lock:
|
|
40
|
+
history = self._history.get(symbol, collections.deque())
|
|
41
|
+
return history[-1] if history else np.nan
|
|
42
|
+
|
|
43
|
+
def history(self, symbol: str) -> collections.deque[float]:
|
|
44
|
+
with self._lock:
|
|
45
|
+
h = self._history.get(symbol, collections.deque())
|
|
46
|
+
return collections.deque(h, maxlen=self._max_history)
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def plot_at(self) -> int:
|
|
50
|
+
return self._plot_at
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{onesecondtrader-0.28.0 → onesecondtrader-0.29.0}/src/onesecondtrader/messaging/subscriber.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|