Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions quantwave-py/python/quantwave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
``StreamingError``, and ``InternalError`` (native FFI). See ``quantwave._errors``.
"""

from __future__ import annotations # PEP 604 (str | None) annotations on Python 3.9

from typing import List, Dict, Any
import warnings

Expand Down
8 changes: 6 additions & 2 deletions quantwave-py/python/quantwave/talib.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import inspect
from typing import Any, Callable, Dict, List, Optional

import numpy as np

from quantwave._talib_map_generated import TALIB_SLUG_TO_NAME as _TALIB_MAP

# numpy is imported lazily (inside the wrappers) so that `import quantwave` — and the
# rest of quantwave.talib's discovery API (list_functions) — work without numpy
# installed. Calling a talib function does require numpy (classic array in/out).

# Canonical TA-Lib price-input order. Multi-input functions receive their arrays in
# this order (subset), matching classic talib (e.g. ATR(high, low, close)).
_OHLCV = ["open", "high", "low", "close", "volume"]
Expand Down Expand Up @@ -148,6 +150,8 @@ def _make_wrapper(talib_name: str, method_name: str) -> Callable[..., Any]:
spec = _Signature(method_name)

def wrapper(*arrays, **kwargs):
import numpy as np # lazy: classic talib API is numpy-based

if len(arrays) != len(spec.input_roles):
raise TypeError(
f"{talib_name} expects {len(spec.input_roles)} input array(s) "
Expand Down
Loading