Skip to content

Commit

Permalink
Project Housekeeping (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
btschwertfeger authored Jan 21, 2024
1 parent 24b3e60 commit 66f1bda
Show file tree
Hide file tree
Showing 42 changed files with 129 additions and 117 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_build_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r docs/requirements.txt
python -m pip install -r doc/requirements.txt
- name: Build the documentation
run: cd docs && make html
run: cd doc && make html
2 changes: 2 additions & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ on:
push:
branches:
- "**"
schedule:
- cron: "24 7 */7 * *"

concurrency:
group: CICD-${{ github.ref }}
Expand Down
57 changes: 0 additions & 57 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ share/python-wheels/
*.whl
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
Expand All @@ -66,19 +56,6 @@ pytest.xml
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

Expand All @@ -88,30 +65,6 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
Expand All @@ -121,13 +74,6 @@ ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

Expand All @@ -137,9 +83,6 @@ venv.bak/
dmypy.json
mypy.xml

# Pyre type checker
.pyre/

# misc
del*.py
del/
Expand Down
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.7
rev: v0.1.13
hooks:
- id: ruff
args:
Expand All @@ -21,7 +21,7 @@ repos:
- --show-source
- --statistics
- repo: https://github.com/pycqa/pylint
rev: v3.0.1
rev: v3.0.2
hooks:
- id: pylint
name: pylint
Expand All @@ -31,16 +31,16 @@ repos:
- --rcfile=pyproject.toml
- -d=R0801 # ignore duplicate code
- -j=4
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.1
hooks:
- id: mypy
name: mypy
additional_dependencies: ["types-requests"]
pass_filenames: false
args:
- --config-file=pyproject.toml
- kraken
# - repo: https://github.com/pre-commit/mirrors-mypy # FIXME
# rev: v1.8.0
# hooks:
# - id: mypy
# name: mypy
# additional_dependencies: ["types-requests"]
# pass_filenames: false
# args:
# - --config-file=pyproject.toml
# - kraken
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build:

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
configuration: doc/conf.py

# If using Sphinx, optionally build your docs in additional formats such as PDF
# formats:
Expand All @@ -22,4 +22,4 @@ sphinx:
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: docs/requirements.txt
- requirements: doc/requirements.txt
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Changelog

## [Unreleased](https://github.com/btschwertfeger/python-kraken-sdk/tree/HEAD)

[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v2.1.1...HEAD)

**Fixed bugs:**

- Futures re-subscribe to authenticated feed doesn't work [\#179](https://github.com/btschwertfeger/python-kraken-sdk/issues/179)

## [v2.1.1](https://github.com/btschwertfeger/python-kraken-sdk/tree/v2.1.1) (2023-12-18)

[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v2.1.0...v2.1.1)

**Fixed bugs:**

- Futures re-subscribe to authenticated feed doesn't work [\#179](https://github.com/btschwertfeger/python-kraken-sdk/issues/179)
- Fix "Futures re-subscribe to authenticated feed doesn't work" [\#180](https://github.com/btschwertfeger/python-kraken-sdk/pull/180) ([btschwertfeger](https://github.com/btschwertfeger))

**Closed issues:**

- Add support for trailing-stop and trailing-stop-limit order types for Spot REST [\#181](https://github.com/btschwertfeger/python-kraken-sdk/issues/181)

## [v2.1.0](https://github.com/btschwertfeger/python-kraken-sdk/tree/v2.1.0) (2023-12-07)

[Full Changelog](https://github.com/btschwertfeger/python-kraken-sdk/compare/v2.0.0...v2.1.0)
Expand Down
7 changes: 7 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#

include README.md LICENSE pyproject.toml

graft kraken

prune doc
prune examples
prune tests
31 changes: 19 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2023 Benjamin Thomas Schwertfeger
# GitHub: https://github.com/btschwertfeger
#

PYTHON := venv/bin/python
PYTEST := $(PYTHON) -m pytest
Expand All @@ -27,7 +28,7 @@ rebuild: clean build
##
.PHONY: doc
doc:
cd docs && make html
cd doc && make html

## ======= I N S T A L L A T I O N =======
## install Install the package
Expand All @@ -47,7 +48,7 @@ dev:
##
.PHONY: test
test:
@rm *.log || true
@rm .cache/tests/*.log || true
$(PYTEST) $(PYTEST_OPTS) $(TEST_DIR)

.PHONY: tests
Expand All @@ -57,14 +58,14 @@ tests: test
##
.PHONY: wip
wip:
@rm *.log || true
@rm .cache/tests/*.log || true
$(PYTEST) -m "wip" -vv $(TEST_DIR)

## coverage Run all tests and generate the coverage report
##
.PHONY: coverage
coverage:
@rm *.log || true
@rm .cache/tests/*.log || true
$(PYTEST) $(PYTEST_COV_OPTS) $(TEST_DIR)

## doctest Run the documentation related tests
Expand Down Expand Up @@ -110,17 +111,23 @@ changelog:
##
.PHONY: clean
clean:
rm -rf build/ dist/ \
python_kraken_sdk.egg-info \
docs/_build \
rm -rf .cache \
.vscode \
.cache
dist/ \
doc/_build \
python_kraken_sdk.egg-info \
build/

rm -f .coverage coverage.xml pytest.xml mypy.xml \
rm -f .coverage \
*.csv \
*.log \
*.zip \
coverage.xml \
kraken/_version.py \
*.log *.csv *.zip \
tests/*.zip tests/.csv \
python_kraken_sdk-*.whl
mypy.xml \
pytest.xml \
python_kraken_sdk-*.whl \
tests/*.zip

find tests -name "__pycache__" | xargs rm -rf
find kraken -name "__pycache__" | xargs rm -rf
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,16 @@ if __name__ == "__main__":

# 🆕 Contributions

… are welcome! - Please have a look at [CONTRIBUTION.md](./CONTRIBUTING.md).
… are welcome - but:

- First check if there is an existing issue or PR that addresses your
problem/solution. If not - create one first - before creating a PR.
- Typo fixes, project configuration, CI, documentation or style/formatting PRs
will be rejected. Please create an issue for that.
- PRs must provide a reasonable, easy to understand and maintain solution for an
existing problem. You may want to propose a solution when creating the issue
to discuss the approach before creating a PR.
- Please have a look at [CONTRIBUTION.md](./CONTRIBUTING.md).

---

Expand All @@ -490,12 +499,11 @@ if __name__ == "__main__":

- The version scheme is `<Major>.<Minor>.<Service Level>` where:

- **Major** will affect everything and there will be breaking changes in any
case. This could be for example a change to Python 3.11+ only.
- **Major** will affect everything and there will be breaking changes.
- **Minor** introduces features and enhancements which may bring breaking
changes in some cases. These breaking changes could be renaming or addition
of parameters, change in order of parameters or even renaming a function.
- **Service Level** includes bug fixes, documentation or CI related changes.
- **Service Level** includes bug fixes, documentation and CI related changes.

- Coding standards are not always followed to make arguments and function names
as similar as possible to those of the Kraken API documentations.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions kraken/futures/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,9 @@ def get_open_positions(
:linenos:
:caption: Futures Trade: Get the user's open positions
>>> from kraken.futures import Trade
>>> trade = Trade(key="api-key", secret="secret-key")
>>> trade.get_open_positions()
>>> from kraken.futures import User
>>> user = User(key="api-key", secret="secret-key")
>>> user.get_open_positions()
{
'result': 'success',
'openPositions': [
Expand Down Expand Up @@ -834,9 +834,9 @@ def get_open_orders(
:linenos:
:caption: Futures Trade: Get open orders
>>> from kraken.futures import Trade
>>> trade = Trade(key="api-key", secret="secret-key")
>>> trade.get_open_orders()
>>> from kraken.futures import User
>>> user = User(key="api-key", secret="secret-key")
>>> user.get_open_orders()
{
'result': 'success',
'openOrders': [{
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ python_version = "3.11"

# junit_xml = "mypy.xml"
files = ["kraken/**/*.py"]
exclude = ["tests/*/*.py"]
exclude = ["tests/**/*.py"]

cache_dir = ".cache/mypy"
sqlite_cache = true
Expand Down Expand Up @@ -221,10 +221,10 @@ select = [
"FBT", # boolean trap
"PTH", # flake8-use-pathlib
"FURB", # refurb
# "ERA", # eradicate # commented-out code
# "ERA", # eradicate # commented-out code
# "FIX", # flake8-fixme
# "TD", # flake8-todos
# "TRY", # tryceratops # specify exception messages in class; not important
# "TRY", # tryceratops # specify exception messages in class; not important
]
fixable = [
"I",
Expand Down
13 changes: 11 additions & 2 deletions tests/futures/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

from kraken.futures import KrakenFuturesWSClient

CACHE_DIR: Path = Path(__file__).resolve().parent.parent.parent / ".cache" / "tests"
CACHE_DIR.mkdir(parents=True, exist_ok=True)


def is_success(value: Any) -> bool:
"""
Expand Down Expand Up @@ -66,10 +69,16 @@ async def on_message(

log: str = ""
try:
with Path("futures_ws.log").open("r", encoding="utf-8") as logfile:
with Path(CACHE_DIR / "futures_ws.log").open(
mode="r",
encoding="utf-8",
) as logfile:
log = logfile.read()
except FileNotFoundError:
pass

with Path("futures_ws.log").open("w", encoding="utf-8") as logfile:
with Path(CACHE_DIR / "futures_ws.log").open(
mode="w",
encoding="utf-8",
) as logfile:
logfile.write(f"{log}\n{message}")
Loading

0 comments on commit 66f1bda

Please sign in to comment.