From 6ffcfa71375438327508425f60caeff0b24ca3a7 Mon Sep 17 00:00:00 2001 From: Peter Dekkers Date: Sun, 25 Aug 2024 09:54:54 +0200 Subject: [PATCH] inlcude samples in pylint --- bin/local_install.sh | 2 +- bin/publish.sh | 2 +- bin/verify.sh | 2 +- pyproject.toml | 6 +----- tests/samples/__init__.py | 0 tests/samples/monetary.py | 2 +- tests/samples/parquet_recording.py | 11 ----------- tests/samples/talib_feature.py | 2 ++ tests/samples/talib_strategy.py | 3 +++ 9 files changed, 10 insertions(+), 20 deletions(-) create mode 100644 tests/samples/__init__.py diff --git a/bin/local_install.sh b/bin/local_install.sh index cc96e23..7f2dc65 100755 --- a/bin/local_install.sh +++ b/bin/local_install.sh @@ -7,7 +7,7 @@ rm -rf ./runs # QA flake8 roboquant tests || exit 1 -pylint roboquant tests samples || exit 1 +pylint roboquant tests || exit 1 python -m unittest discover -s tests/unit || exit 1 # Build diff --git a/bin/publish.sh b/bin/publish.sh index 4c02389..89feda4 100755 --- a/bin/publish.sh +++ b/bin/publish.sh @@ -7,7 +7,7 @@ rm -rf ./runs # QA flake8 || exit 1 -pylint roboquant tests samples || exit 1 +pylint roboquant tests || exit 1 python -m unittest discover -s tests/unit || exit 1 # Build diff --git a/bin/verify.sh b/bin/verify.sh index 708096a..078d393 100755 --- a/bin/verify.sh +++ b/bin/verify.sh @@ -5,7 +5,7 @@ source .venv/bin/activate # QA flake8 || exit 1 -pylint roboquant tests samples || exit 1 +pylint roboquant tests || exit 1 python -m unittest discover -s tests/unit || exit 1 echo "All tests passed" \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 925e486..7b9377b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,14 +10,10 @@ testpaths = [ [tool.pyright] reportOptionalOperand = "none" -# exclude = ["samples/*.py", "scratch/*.py"] - -[tool.pylint.MASTER] -ignore-paths = 'samples' [tool.pylint.'MESSAGES CONTROL'] max-line-length = 127 -disable = "too-few-public-methods,missing-module-docstring,missing-class-docstring,missing-function-docstring,unnecessary-ellipsis" +disable = "too-few-public-methods,missing-module-docstring,missing-class-docstring,missing-function-docstring,unnecessary-ellipsis,invalid-name" max-args = 15 max-locals = 20 max-attributes = 10 diff --git a/tests/samples/__init__.py b/tests/samples/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/samples/monetary.py b/tests/samples/monetary.py index 133e7e3..3d36beb 100644 --- a/tests/samples/monetary.py +++ b/tests/samples/monetary.py @@ -1,6 +1,6 @@ # %% -from roboquant.monetary import EUR, USD, JPY, ECBConversion, Amount from datetime import datetime +from roboquant.monetary import EUR, USD, JPY, ECBConversion, Amount # %% # Different ways to create Amounts and add them to a wallet diff --git a/tests/samples/parquet_recording.py b/tests/samples/parquet_recording.py index 288dd6d..71b2594 100644 --- a/tests/samples/parquet_recording.py +++ b/tests/samples/parquet_recording.py @@ -9,14 +9,3 @@ feed = ParquetFeed("/tmp/stocks.parquet") if not feed.exists(): feed.record(yahoo_feed) - -# %% -# split the feed timeframe in 4 equal parts -timeframes = feed.timeframe().split(4) - -# %% -# run a walkforward back-test on each timeframe -for timeframe in timeframes: - strategy = rq.strategies.EMACrossover(13, 26) - account = rq.run(feed, strategy, timeframe=timeframe) - print(f"{timeframe} equity={account.equity()}") diff --git a/tests/samples/talib_feature.py b/tests/samples/talib_feature.py index c5f726b..8a4f334 100644 --- a/tests/samples/talib_feature.py +++ b/tests/samples/talib_feature.py @@ -5,6 +5,8 @@ from roboquant.ml.features import TaFeature from roboquant.strategies.buffer import OHLCVBuffer +# pylint: disable=no-member + # %% class RSIFeature(TaFeature): diff --git a/tests/samples/talib_strategy.py b/tests/samples/talib_strategy.py index a78e903..313146e 100644 --- a/tests/samples/talib_strategy.py +++ b/tests/samples/talib_strategy.py @@ -4,12 +4,15 @@ from roboquant.signal import Signal from roboquant.strategies import OHLCVBuffer, TaStrategy +# pylint: disable=no-member + # %% class MyStrategy(TaStrategy): """Example using talib to create a combined RSI/BollingerBand strategy""" def process_asset(self, asset: rq.Asset, ohlcv: OHLCVBuffer): + close = ohlcv.close() rsi = ta.RSI(close, timeperiod=self.size - 1) # type: ignore