diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa7b7c6a..7214f7d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,19 +3,43 @@ name: CI on: push jobs: - mypy: + + basic_install: name: 'pip install' runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v2 with: - ref: chart_hacking + ref: master + - name: Setup python uses: actions/setup-python@v2 with: - python-version: '3.8' + python-version: '3.9' + - name: Install dependencies run: pip install -e . --upgrade-strategy eager -r requirements.txt - - name: Run piker + + - name: Run piker cli run: piker + + testing: + name: 'test suite' + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup python + uses: actions/setup-python@v2 + with: + python-version: '3.9' + + - name: Install dependencies + run: pip install -U . -r requirements-test.txt -r requirements.txt --upgrade-strategy eager + + - name: Test suite + run: pytest tests -rs diff --git a/MANIFEST.in b/MANIFEST.in index 9561fb10..7f3499c6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1,2 @@ include README.rst +include data/brokers.toml diff --git a/data/brokers.toml b/data/brokers.toml new file mode 100644 index 00000000..54b3df16 --- /dev/null +++ b/data/brokers.toml @@ -0,0 +1,9 @@ +[binance] + +[kraken] + + +# [ib] + + +# [questrade] diff --git a/piker/brokers/config.py b/piker/brokers/config.py index 6718e794..a8ba7ff2 100644 --- a/piker/brokers/config.py +++ b/piker/brokers/config.py @@ -18,9 +18,12 @@ Broker configuration mgmt. """ import os -import configparser +from os.path import dirname +import shutil + import toml import click + from ..log import get_logger log = get_logger('broker-config') @@ -40,12 +43,28 @@ def get_broker_conf_path(): return os.path.join(_config_dir, _file_name) +def repodir(): + """Return the abspath to the repo directory. + """ + dirpath = os.path.abspath( + # we're 3 levels down in **this** module file + dirname(dirname(dirname(os.path.realpath(__file__)))) + ) + return dirpath + + def load( path: str = None ) -> (dict, str): """Load broker config. """ path = path or get_broker_conf_path() + if not os.path.isfile(path): + shutil.copyfile( + os.path.join(repodir(), 'data/brokers.toml'), + path, + ) + config = toml.load(path) log.debug(f"Read config file {path}") return config, path diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index c7d8917e..17c0ceb2 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -47,7 +47,7 @@ from ib_insync.wrapper import Wrapper from ib_insync.client import Client as ib_Client from ..log import get_logger, get_console_log -from ..data import maybe_spawn_brokerd +from .._daemon import maybe_spawn_brokerd from ..data._source import from_df from ..data._sharedmem import ShmArray from ._util import SymbolNotFound diff --git a/piker/data/__init__.py b/piker/data/__init__.py index 1a287ee2..e98195b4 100644 --- a/piker/data/__init__.py +++ b/piker/data/__init__.py @@ -38,7 +38,6 @@ from .feed import ( __all__ = [ 'open_feed', - 'maybe_spawn_brokerd', 'ShmArray', 'iterticks', 'maybe_open_shm_array', diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 00000000..e079f8a6 --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1 @@ +pytest diff --git a/setup.py b/setup.py index 76246e56..457032dc 100755 --- a/setup.py +++ b/setup.py @@ -77,7 +77,7 @@ setup( #'kivy', see requirement.txt; using a custom branch atm ], tests_require=['pytest'], - python_requires=">=3.7", # literally for ``datetime.datetime.fromisoformat``... + python_requires=">=3.9", # literally for ``datetime.datetime.fromisoformat``... keywords=["async", "trading", "finance", "quant", "charting"], classifiers=[ 'Development Status :: 3 - Alpha', @@ -85,7 +85,7 @@ setup( 'Operating System :: POSIX :: Linux', "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.9", 'Intended Audience :: Financial and Insurance Industry', 'Intended Audience :: Science/Research', 'Intended Audience :: Developers', diff --git a/tests/conftest.py b/tests/conftest.py index f461ffc6..d6ebbbf2 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -44,7 +44,6 @@ def confdir(request, test_config): if confdir is not None: config._override_config_dir(confdir) - # return config.load()[0] return confdir diff --git a/tests/test_cli.py b/tests/test_cli.py index 26065245..8c9df93a 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -10,6 +10,12 @@ import os.path import piker.watchlists as wl +pytestmark = pytest.mark.skipif( + True, + reason="cli tests rely on quote api and questrade symbols" +) + + def run(cmd, *args): """Run cmd and check for zero return code. """ diff --git a/tests/test_questrade.py b/tests/test_questrade.py index 67417f1d..f8bd3f7a 100644 --- a/tests/test_questrade.py +++ b/tests/test_questrade.py @@ -10,11 +10,18 @@ import pytest import tractor from tractor.testing import tractor_test +import piker from piker.brokers import get_brokermod from piker.brokers.data import DataFeed -log = tractor.get_logger('tests') +log = piker.log.get_logger('tests') + + +pytestmark = pytest.mark.skipif( + True, + reason="questrade tests can only be run locally with an API key", +) # stock quote