diff --git a/.travis.yml b/.travis.yml index b2501aa..4f4f334 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,8 @@ python: install: - pip install -e ".[dev]" script: - - py.test --cov . --cov-report xml:coverage.xml + - cd docs && make doctest + - pytest --cov . --cov-report xml:coverage.xml env: global: diff --git a/docs/source/_static/.gitkeep b/docs/source/_static/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/api.rst b/docs/source/api.rst new file mode 100644 index 0000000..5bf8d8c --- /dev/null +++ b/docs/source/api.rst @@ -0,0 +1,5 @@ +API reference +============= + +.. automodule:: cryptocom.exchange + :members: diff --git a/docs/source/conf.py b/docs/source/conf.py index 6207bdd..33135a4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,16 +13,18 @@ # documentation root, use os.path.abspath to make it absolute, like shown here. # +from cryptocom.exchange import VERSION + # -- Project information ----------------------------------------------------- project = 'cryptocom-exchange' -copyright = '2019, change' -author = 'change' +copyright = '2020, goincrypto.com' +author = 'Yaroslav Rudenok [MortySpace]' # The short X.Y version -version = '' +version = VERSION # The full version, including alpha/beta/rc tags -release = '0.1' +release = VERSION # -- General configuration --------------------------------------------------- @@ -79,7 +81,7 @@ pygments_style = None # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -133,7 +135,7 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'cryptocom-exchange.tex', 'unv\\_template Documentation', + (master_doc, 'cryptocom-exchange.tex', 'cryptocom-exchange\\_template Documentation', 'change', 'manual'), ] @@ -154,7 +156,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'cryptocom-exchange', 'cryptocom-exchange Documentation', + (master_doc, 'cryptocom-exchange', 'cryptocom-exchange Documentati', author, 'cryptocom-exchange', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/source/guide.rst b/docs/source/guide.rst new file mode 100644 index 0000000..2540431 --- /dev/null +++ b/docs/source/guide.rst @@ -0,0 +1,2 @@ +User's Guide +============ diff --git a/docs/source/index.rst b/docs/source/index.rst index bcbb503..03c39eb 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,15 +2,43 @@ You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. +.. toctree:: + :hidden: + :maxdepth: 3 + :caption: Contents: + + Home + install + guide + api + Welcome to cryptocom-exchange documentation! ============================================ +Get started with "Installation" and then get an overview with the User's guide with helpful examples. Also you can find tests with examples of trading and exchange data usage. +Full reference you can find in the API section. cryptocom-exchange depends on the aiohttp the documentation for this library can be found at: "link". -.. toctree:: - :maxdepth: 2 - :caption: Contents: +Quick-start +=========== + +- python3 -m venv venv (create virutalenv) +- source venv/bin/activate +- pip3 install cryptocom-exchange + +- create simple file hello_crypto.py with contents + +.. testcode:: + + import asyncio + import cryptocom.exchange as cro + + async def main(): + exchange = cro.Exchange() + candles = [ + candle async for candle in exchange.get_candles(cro.Symbol.CROUSDT) + ] + assert len(candles) > 30 -.. automodule:: cryptocom.exchange - :members: + asyncio.run(main()) Indices and tables ================== diff --git a/docs/source/install.rst b/docs/source/install.rst new file mode 100644 index 0000000..11e4437 --- /dev/null +++ b/docs/source/install.rst @@ -0,0 +1,2 @@ +Installation +============ diff --git a/pytest.ini b/pytest.ini index 7f3b810..c10b7f3 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,3 +1,3 @@ [pytest] -addopts = --doctest-modules +addopts = --doctest-plus --doctest-rst python_paths = tests diff --git a/setup.py b/setup.py index a3013bc..d1a7060 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,18 @@ +from pathlib import Path from setuptools import setup, find_packages + +def get_version(): + module_file = Path( + Path(__file__).parent, 'src', + *find_packages('src')[-1].split('.'), '__init__.py' + ) + return module_file.read_text().split("VERSION = '")[1].split("'")[0] + + setup( name='cryptocom-exchange', - version='0.1', + version=get_version(), description="""Provide description""", url='https://github.com/goincrypto/cryptocom-exchange', author='Yaroslav Rudenok [Morty Space]', @@ -35,9 +45,11 @@ setup( 'pytest-asyncio', 'pytest-cov', 'pytest-env', + 'pytest-doctestplus', 'pytest-pythonpath', 'autopep8', 'sphinx', + 'sphinx_rtd_theme', 'setuptools', 'wheel', 'twine' diff --git a/src/cryptocom/exchange/__init__.py b/src/cryptocom/exchange/__init__.py index d452dfa..1c61200 100644 --- a/src/cryptocom/exchange/__init__.py +++ b/src/cryptocom/exchange/__init__.py @@ -7,3 +7,5 @@ __all__ = [ 'Exchange', 'Account', 'Candle', 'ApiError', 'ApiProvider' ] + +VERSION = '0.1' diff --git a/src/cryptocom/exchange/base.py b/src/cryptocom/exchange/base.py index ec9300b..148f0be 100644 --- a/src/cryptocom/exchange/base.py +++ b/src/cryptocom/exchange/base.py @@ -35,7 +35,7 @@ class Exchange: async def get_ticker(self, symbol: Symbol): return (await self.get_tickers()).get(symbol.value) - async def get_candles(self, symbol: Symbol, period: Period): + async def get_candles(self, symbol: Symbol, period: Period = Period.D1): """Get k-line data over a specified period.""" data = await self.api.get( 'klines', {'symbol': symbol.value, 'period': period.value})