Skip to content

Commit

Permalink
optimized dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed Dec 16, 2024
1 parent f6965b2 commit 46e8737
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion bin/local_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

rm -rf ./runs

uv sync --all-extras
uv sync --all-extras --dev

# QA
uvx ruff check || exit 1
Expand Down
2 changes: 1 addition & 1 deletion bin/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

rm -rf ./runs

uv sync --all-extras
uv sync --all-extras --dev

# QA
uvx ruff check
Expand Down
2 changes: 1 addition & 1 deletion bin/verify.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[ ! -f "LICENSE" ]] && echo "run the script from the project root directory like this: ./bin/verify.sh" && exit 1

uv sync --all-extras
uv sync --all-extras --dev

# QA
echo "Running ruff"
Expand Down
10 changes: 7 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ dependencies = [
"numpy>=1.26.4",
"websocket-client~=1.8.0",
"requests>=2.32.0",
"fastavro>=1.9.7",
"pyarrow>=16.1.0",
"matplotlib>=3.10.0",
"yfinance~=0.2.50"
]
Expand All @@ -50,9 +48,15 @@ dependencies = [
torch = ["torch>=2.5.0", "tensorboard>=2.15.2", "stable-baselines3>=2.4.0", "sb3-contrib>=2.4.0"]
ibkr = ["nautilus-ibapi~=10.19.2"]
alpaca = ["alpaca-py"]
all = ["roboquant[torch,ibkr,alpaca]"]
avro = ["fastavro>=1.9.7"]
parquet = ["pyarrow>=16.1.0"]

[project.urls]
Homepage = "https://roboquant.org"
Repository = "https://github.com/neurallayer/roboquant.py.git"
Issues = "https://github.com/neurallayer/roboquant.py/issues"

[dependency-groups]
dev = [
"ta-lib>=0.5.1",
]
6 changes: 4 additions & 2 deletions roboquant/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class SignalType(Flag):
- ENTRY: enter/increase a position size
- EXIT: close/reduce a position size
- ENTRY_EXIT: can be used both to increase or decrease position sizes
- ENTRY_EXIT: can be used both to increase or reduce position sizes
"""

ENTRY = auto()
Expand All @@ -27,12 +27,14 @@ class Signal:
A rating is a float normally between -1.0 and 1.0, where -1.0 is a strong sell, and 1.0 is a strong buy.
But this range isn't enforced. It is up to the used trader to handle these values.
The type indicates if it is an ENTRY, EXIT or ENTRY_EXIT signal.
The type indicates if it is an `ENTRY`, `EXIT` or `ENTRY_EXIT` signal. The default is `ENTRY_EXIT`.
Examples:
```
Signal.buy("XYZ")
Signal.sell("XYZ", SignalType.EXIT)
Signal("XYZ", 0.5, SignalType.ENTRY)
```
"""

asset: Asset
Expand Down
9 changes: 7 additions & 2 deletions roboquant/strategies/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, rows: int, columns: int, dtype: Any = "float32", order="C") -
self.rows = rows

def append(self, data: array | NDArray | list | tuple) -> bool:
"""Append data to this buffer. Return True if the buffer is full, False otherwise"""
if self._idx >= len(self._data):
self._data[0: self.rows] = self._data[-self.rows:]
self._idx = self.rows
Expand Down Expand Up @@ -53,7 +54,9 @@ def reset(self):


class OHLCVBuffer(NumpyBuffer):
"""A OHLCV buffer (first-in-first-out) of a fixed capacity."""
"""A OHLCV buffer (first-in-first-out) of a fixed capacity.
It stores the data in a `NumpyBuffer`.
"""

def __init__(self, capacity: int, dtype="float64") -> None:
"""Create a new OHLCV buffer"""
Expand Down Expand Up @@ -81,6 +84,7 @@ def volume(self) -> NDArray:


class OHLCVBuffers(UserDict[Asset, OHLCVBuffer]):
"""A OHLCV buffer for multiple assets"""

def __init__(self, size: int):
super().__init__()
Expand All @@ -100,5 +104,6 @@ def add_event(self, event: Event) -> set[Asset]:
assets.add(asset)
return assets

def ready(self):
def ready(self) -> set[Asset]:
"""Return a set of assets for which the buffer is already full"""
return {asset for asset, ohlcv in self.items() if ohlcv.is_full()}
1 change: 1 addition & 0 deletions roboquant/strategies/emacrossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def create_signals(self, event: Event) -> list[Signal]:
return result

class _Calculator:
"""Calculates the EMA crossover"""

__slots__ = "momentum1", "momentum2", "price1", "price2", "step"

Expand Down
45 changes: 26 additions & 19 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 46e8737

Please sign in to comment.