infinity-grid 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. infinity_grid-1.0.0/.gitignore +56 -0
  2. infinity_grid-1.0.0/.pre-commit-config.yaml +96 -0
  3. infinity_grid-1.0.0/.readthedocs.yaml +27 -0
  4. infinity_grid-1.0.0/CITATION +14 -0
  5. infinity_grid-1.0.0/Dockerfile +56 -0
  6. infinity_grid-1.0.0/LICENSE +61 -0
  7. infinity_grid-1.0.0/MANIFEST.in +21 -0
  8. infinity_grid-1.0.0/Makefile +136 -0
  9. infinity_grid-1.0.0/PKG-INFO +460 -0
  10. infinity_grid-1.0.0/README.md +415 -0
  11. infinity_grid-1.0.0/docker-compose.yaml +98 -0
  12. infinity_grid-1.0.0/pyproject.toml +292 -0
  13. infinity_grid-1.0.0/setup.cfg +4 -0
  14. infinity_grid-1.0.0/src/infinity_grid/__init__.py +6 -0
  15. infinity_grid-1.0.0/src/infinity_grid/_version.py +34 -0
  16. infinity_grid-1.0.0/src/infinity_grid/adapters/__init__ .py +6 -0
  17. infinity_grid-1.0.0/src/infinity_grid/adapters/exchanges/__init__ .py +6 -0
  18. infinity_grid-1.0.0/src/infinity_grid/adapters/exchanges/kraken.py +532 -0
  19. infinity_grid-1.0.0/src/infinity_grid/adapters/notification.py +48 -0
  20. infinity_grid-1.0.0/src/infinity_grid/core/__init__.py +6 -0
  21. infinity_grid-1.0.0/src/infinity_grid/core/cli.py +379 -0
  22. infinity_grid-1.0.0/src/infinity_grid/core/engine.py +176 -0
  23. infinity_grid-1.0.0/src/infinity_grid/core/event_bus.py +38 -0
  24. infinity_grid-1.0.0/src/infinity_grid/core/state_machine.py +120 -0
  25. infinity_grid-1.0.0/src/infinity_grid/exceptions.py +40 -0
  26. infinity_grid-1.0.0/src/infinity_grid/infrastructure/__init__.py +6 -0
  27. infinity_grid-1.0.0/src/infinity_grid/infrastructure/database.py +404 -0
  28. infinity_grid-1.0.0/src/infinity_grid/interfaces/__init__.py +18 -0
  29. infinity_grid-1.0.0/src/infinity_grid/interfaces/exchange.py +390 -0
  30. infinity_grid-1.0.0/src/infinity_grid/interfaces/notification.py +16 -0
  31. infinity_grid-1.0.0/src/infinity_grid/models/__init__.py +6 -0
  32. infinity_grid-1.0.0/src/infinity_grid/models/configuration.py +148 -0
  33. infinity_grid-1.0.0/src/infinity_grid/models/exchange.py +196 -0
  34. infinity_grid-1.0.0/src/infinity_grid/services/__init__.py +12 -0
  35. infinity_grid-1.0.0/src/infinity_grid/services/database.py +123 -0
  36. infinity_grid-1.0.0/src/infinity_grid/services/notification_service.py +69 -0
  37. infinity_grid-1.0.0/src/infinity_grid/strategies/__init__.py +18 -0
  38. infinity_grid-1.0.0/src/infinity_grid/strategies/c_dca.py +46 -0
  39. infinity_grid-1.0.0/src/infinity_grid/strategies/grid_base.py +1328 -0
  40. infinity_grid-1.0.0/src/infinity_grid/strategies/grid_hodl.py +161 -0
  41. infinity_grid-1.0.0/src/infinity_grid/strategies/grid_sell.py +188 -0
  42. infinity_grid-1.0.0/src/infinity_grid/strategies/swing.py +205 -0
  43. infinity_grid-1.0.0/src/infinity_grid.egg-info/PKG-INFO +460 -0
  44. infinity_grid-1.0.0/src/infinity_grid.egg-info/SOURCES.txt +46 -0
  45. infinity_grid-1.0.0/src/infinity_grid.egg-info/dependency_links.txt +1 -0
  46. infinity_grid-1.0.0/src/infinity_grid.egg-info/entry_points.txt +2 -0
  47. infinity_grid-1.0.0/src/infinity_grid.egg-info/requires.txt +21 -0
  48. infinity_grid-1.0.0/src/infinity_grid.egg-info/top_level.txt +1 -0
@@ -0,0 +1,56 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ *.egg
11
+ *.egg-info
12
+ build/
13
+ dist/
14
+
15
+ # Version file
16
+ infinity_grid/_version.py
17
+
18
+ # Environments
19
+ .env
20
+ .venv
21
+
22
+ # Jupyter Notebook
23
+ .ipynb_checkpoints
24
+
25
+ # Logs
26
+ *.log
27
+
28
+ # Miscellaneous
29
+ .DS_Store
30
+ .vscode/
31
+ del/
32
+ del.*
33
+ *tar.gz
34
+ uv.lock
35
+
36
+ .cache/
37
+
38
+ # Unit test / coverage reports
39
+ .coverage
40
+ .coverage.*
41
+ coverage.xml
42
+ *.cover
43
+ *.py,cover
44
+ .pytest_cache/
45
+ pytest.xml
46
+
47
+ # Sphinx documentation
48
+ doc/_build/
49
+
50
+ # CSV and pickle files
51
+ *.csv
52
+
53
+ # Other artifacts
54
+ *.sqlite*
55
+ *sqlite*
56
+ *.sqlite-journal
@@ -0,0 +1,96 @@
1
+ # -*- mode: yaml; coding: utf-8 -*-
2
+ #
3
+ # Copyright (C) 2023 Benjamin Thomas Schwertfeger
4
+ # All rights reserved.
5
+ # https://github.com/btschwertfeger
6
+ #
7
+
8
+ repos:
9
+ - repo: https://github.com/astral-sh/ruff-pre-commit
10
+ rev: v0.9.2
11
+ hooks:
12
+ - id: ruff
13
+ args:
14
+ - --preview
15
+ - --fix
16
+ - --exit-non-zero-on-fix
17
+ - repo: https://github.com/pre-commit/mirrors-mypy
18
+ rev: v1.14.1
19
+ hooks:
20
+ - id: mypy
21
+ name: mypy
22
+ additional_dependencies:
23
+ - types-requests
24
+ - types-SQLAlchemy
25
+ pass_filenames: false
26
+ args:
27
+ - --config-file=pyproject.toml
28
+ - --install-types
29
+ - --non-interactive
30
+ - src
31
+ - repo: https://github.com/gitleaks/gitleaks
32
+ rev: v8.23.1
33
+ hooks:
34
+ - id: gitleaks
35
+ - repo: https://github.com/codespell-project/codespell
36
+ rev: v2.3.0
37
+ hooks:
38
+ - id: codespell
39
+ additional_dependencies: [tomli]
40
+ - repo: https://github.com/pre-commit/pre-commit-hooks
41
+ rev: v5.0.0
42
+ hooks:
43
+ - id: check-yaml
44
+ - id: check-ast
45
+ - id: check-json
46
+ - id: check-toml
47
+ - id: check-docstring-first
48
+ - id: check-case-conflict
49
+ - id: check-merge-conflict
50
+ - id: check-added-large-files
51
+ args: [--maxkb=500]
52
+ - id: check-executables-have-shebangs
53
+ - id: trailing-whitespace
54
+ - id: fix-byte-order-marker
55
+ - id: mixed-line-ending
56
+ - id: requirements-txt-fixer
57
+ - id: end-of-file-fixer
58
+ - id: detect-private-key
59
+ - repo: https://github.com/pre-commit/pygrep-hooks
60
+ rev: v1.10.0
61
+ hooks:
62
+ - id: python-use-type-annotations
63
+ - id: python-check-blanket-noqa
64
+ - id: python-check-blanket-type-ignore
65
+ - id: python-check-mock-methods
66
+ - id: python-no-eval
67
+ - id: python-no-log-warn
68
+ - id: rst-backticks
69
+ - id: rst-directive-colons
70
+ - id: rst-inline-touching-normal
71
+ - id: text-unicode-replacement-char
72
+ - repo: https://github.com/psf/black
73
+ rev: 24.10.0
74
+ hooks:
75
+ - id: black
76
+ - repo: https://github.com/rbubley/mirrors-prettier
77
+ rev: v3.4.2
78
+ hooks:
79
+ - id: prettier
80
+ - repo: https://github.com/PyCQA/isort # TODO: remove as soon as ruff is stable
81
+ rev: 5.13.2
82
+ hooks:
83
+ - id: isort
84
+ args:
85
+ - --profile=black
86
+ - repo: https://github.com/hadolint/hadolint
87
+ rev: v2.12.0
88
+ hooks:
89
+ - id: hadolint-docker
90
+ files: \.(dockerfile|Dockerfile)$|^Dockerfile
91
+ - repo: https://github.com/docker-compose-linter/pre-commit-dclint
92
+ rev: v3.1.0
93
+ hooks:
94
+ - id: dclint-docker
95
+ files: (docker-)?compose\.ya?ml$
96
+ # args: [--fix]
@@ -0,0 +1,27 @@
1
+ # .readthedocs.yaml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Set the version of Python and other tools you might need
9
+ build:
10
+ os: ubuntu-22.04
11
+ tools:
12
+ python: "3.11"
13
+ apt_packages:
14
+ - pandoc
15
+
16
+ # Build documentation in the doc/ directory with Sphinx
17
+ sphinx:
18
+ configuration: doc/conf.py
19
+
20
+ # If using Sphinx, optionally build your docs in additional formats such as PDF
21
+ # formats:
22
+ # - pdf
23
+
24
+ # Optionally declare the Python requirements required to build your docs
25
+ python:
26
+ install:
27
+ - requirements: doc/requirements.txt
@@ -0,0 +1,14 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ authors:
4
+ - family-names: "Schwertfeger"
5
+ given-names: "Benjamin Thomas"
6
+ orcid: "https://orcid.org/0000-0001-7664-8434"
7
+ title: "infinity-grid"
8
+ url: "https://github.com/btschwertfeger/infinity-grid"
9
+ keywords:
10
+ - Python
11
+ - Cryptocurrency
12
+ - Trading
13
+ - Automation
14
+ - Grid Trading
@@ -0,0 +1,56 @@
1
+ FROM python:3.13-slim-bookworm AS builder
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+
5
+ WORKDIR /apps
6
+ COPY . /apps
7
+
8
+ # hadolint ignore=DL3013,DL3008
9
+ RUN --mount=type=cache,target=/var/lib/apt/,sharing=locked \
10
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
11
+ --mount=type=tmpfs,target=/var/log/apt/ \
12
+ apt-get update \
13
+ && apt-get install --no-install-recommends -y git \
14
+ && python -m pip install --no-cache-dir --compile --upgrade pip build \
15
+ && python -m build .
16
+
17
+ # ------------------------------------------------------------------------------
18
+
19
+ FROM python:3.13-slim-bookworm
20
+
21
+ ENV DEBIAN_FRONTEND=noninteractive
22
+
23
+ # hadolint ignore=DL3008,DL3013,SC2102
24
+ RUN --mount=type=bind,target=/context,from=builder,source=/apps \
25
+ --mount=type=cache,target=/var/lib/apt/,sharing=locked \
26
+ --mount=type=cache,target=/var/cache/apt,sharing=locked \
27
+ --mount=type=tmpfs,target=/var/log/apt/ \
28
+ rm -f /etc/apt/apt.conf.d/docker-clean \
29
+ && echo "LC_ALL=en_US.UTF-8" >> /etc/environment \
30
+ && echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \
31
+ && echo "LANG=en_US.UTF-8" >> /etc/locale.conf \
32
+ && apt-get update \
33
+ && apt-get -y upgrade \
34
+ && apt-get -y --no-install-recommends install \
35
+ gcc \
36
+ libpq-dev \
37
+ locales \
38
+ procps \
39
+ && locale-gen en_US.UTF-8 \
40
+ && rm -rf /var/lib/apt/lists/* \
41
+ && python -m pip install --compile --no-cache-dir $(find /context/dist -name "*.whl")[kraken] \
42
+ && groupadd -r infinity-grid \
43
+ && useradd -r -g infinity-grid -d /home/infinity-grid -s /bin/bash -c "Infinity Grid User" infinity-grid \
44
+ && mkdir -p /home/infinity-grid \
45
+ && chown -R infinity-grid:infinity-grid /home/infinity-grid
46
+
47
+ USER infinity-grid
48
+ WORKDIR /home/infinity-grid
49
+
50
+ ENTRYPOINT ["infinity-grid", "run"]
51
+
52
+ LABEL title="Infinity Grid"
53
+ LABEL maintainer="Benjamin Thomas Schwertfeger contact@b-schwertfeger.de"
54
+ LABEL description="The Infinity Grid Trading Algorithm."
55
+ LABEL documentation="https://infinity-grid.readthedocs.io/en/stable"
56
+ LABEL image.url="https://github.com/btschwerfeger/infinity-grid"
@@ -0,0 +1,61 @@
1
+ Custom License Agreement
2
+ Version 2.0, January 2025
3
+
4
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
5
+
6
+ 1. Permission for Personal Use
7
+
8
+ You are allowed to use, modify, and distribute this software for personal and
9
+ non-commercial purposes. This includes the right to modify the code and share
10
+ it with others, provided the terms outlined in this license are met.
11
+
12
+ 2. No Commercial Use
13
+
14
+ Companies and other organizations are prohibited from using, modifying, or
15
+ distributing this software for commercial purposes without explicit written
16
+ consent from the author. Commercial use includes any activity that directly
17
+ or indirectly generates revenue or is intended for commercial advantage.
18
+
19
+ 3. Attribution Requirement
20
+
21
+ If you use, modify, or distribute this software in any public capacity, you
22
+ must provide clear and visible attribution to the original author and owner.
23
+ This attribution should include the author's name and a link to the original
24
+ project repository.
25
+
26
+ 4. Request for Commercial Use
27
+
28
+ For any commercial use, you must contact the author to negotiate a separate
29
+ agreement. Commercial use is only permitted after entering into a custom
30
+ contract with terms agreed upon by both parties.
31
+
32
+ 5. Disclaimer of Liability
33
+
34
+ This software is provided "as is", without any warranties of any kind, either
35
+ express or implied, including but not limited to the warranties of
36
+ merchantability, fitness for a particular purpose, or non-infringement. In no
37
+ event shall the author be liable for any claim, damages, or other liability,
38
+ whether in an action of contract, tort, or otherwise, arising from, out of,
39
+ or in connection with the software or the use or other dealings in the
40
+ software.
41
+
42
+ 6. Governing Law
43
+
44
+ This license shall be governed by and construed in accordance with the laws
45
+ of Germany.
46
+
47
+ 7. Contributor Rights
48
+
49
+ By contributing to this project, contributors agree that they waive any
50
+ rights to attribution or ownership of their contributions. All contributions
51
+ become the sole property of the original author and owner. Contributors have
52
+ no rights to require their names to be included in any references or credits
53
+ related to this software.
54
+
55
+ END OF TERMS AND CONDITIONS
56
+
57
+ Copyright 2025 Benjamin Thomas Schwertfeger
58
+
59
+ contact@b-schwertfeger.de
60
+
61
+ https://github.com/btschwertfeger
@@ -0,0 +1,21 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (C) 2025 Benjamin Thomas Schwertfeger
3
+ # GitHub: https://github.com/btschwertfeger
4
+ #
5
+
6
+ include README.md LICENSE pyproject.toml
7
+
8
+ graft src
9
+ prune .cache
10
+ prune .github
11
+ prune doc
12
+ prune tools
13
+ prune tests
14
+ prune .venv
15
+
16
+ prune .gitignore
17
+ prune .pre-commit-config.yaml
18
+ prune .readthedocs.yaml
19
+ prune Makefile
20
+ prune Dockerfile
21
+ prune docker-compose.yaml
@@ -0,0 +1,136 @@
1
+ #!make
2
+ # -*- mode: make; coding: utf-8 -*-
3
+ #
4
+ # Copyright (C) 2023 Benjamin Thomas Schwertfeger
5
+ # All rights reserved.
6
+ # https://github.com/btschwertfeger
7
+ #
8
+
9
+ UV ?= uv
10
+ PYTHON := python
11
+ PYTEST := pytest
12
+ PYTEST_OPTS := -vv --junit-xml=pytest.xml
13
+ PYTEST_COV_OPTS := $(PYTEST_OPTS) --cov=infinity_grid --cov-report=xml:coverage.xml --cov-report=term-missing
14
+ TEST_DIR := tests
15
+
16
+ ## ======= H E L P =============================================================
17
+ ## help Show this help message
18
+ .PHONY: help
19
+ help:
20
+ @grep "^##" Makefile | sed -e "s/##//"
21
+
22
+ ## ======= B U I L D I N G =====================================================
23
+ ## build Builds the package
24
+ ##
25
+ .PHONY: build
26
+ build: check-uv
27
+ $(UV) build .
28
+
29
+ .PHONY: rebuild
30
+ rebuild: clean build
31
+
32
+ ## doc Build the documentation
33
+ ##
34
+ .PHONY: doc
35
+ doc:
36
+ cd doc && make html
37
+
38
+ ## image Build the Docker image
39
+ ##
40
+ image:
41
+ docker build -t btschwertfeger/infinity-grid:dev .
42
+
43
+ ## ======= I N S T A L L A T I O N =============================================
44
+ ## install Install the package
45
+ ##
46
+ .PHONY: install
47
+ install: check-uv
48
+ $(UV) pip install .
49
+
50
+ ## dev Installs the extended package in edit mode
51
+ ##
52
+ .PHONY: dev
53
+ dev: check-uv
54
+ $(UV) pip install --compile -e ".[dev,test]" -r doc/requirements.txt
55
+
56
+ ## ======= T E S T I N G =======================================================
57
+ ## test Run the unit tests
58
+ ##
59
+ .PHONY: test
60
+ test:
61
+ $(PYTEST) $(PYTEST_OPTS) $(TEST_DIR)
62
+
63
+ .PHONY: tests
64
+ tests: test
65
+
66
+ ## retest Run only the tests that failed last time
67
+ ##
68
+ .PHONY: retest
69
+ retest:
70
+ $(PYTEST) $(PYTEST_OPTS) --lf $(TEST_DIR)
71
+
72
+ ## wip Run tests marked as 'wip'
73
+ ##
74
+ .PHONY: wip
75
+ wip:
76
+ @rm .cache/tests/*.log || true
77
+ $(PYTEST) -m "wip" -vv $(TEST_DIR)
78
+
79
+ ## coverage Run all tests and generate the coverage report
80
+ ##
81
+ .PHONY: coverage
82
+ coverage:
83
+ @rm .cache/tests/*.log || true
84
+ $(PYTEST) $(PYTEST_COV_OPTS) $(TEST_DIR)
85
+
86
+ ## doctest Run the documentation related tests
87
+ ##
88
+ .PHONY: doctest
89
+ doctest:
90
+ cd docs && make doctest
91
+
92
+ ## ======= M I S C E L L A N I O U S ===========================================
93
+ ## pre-commit Run the pre-commit targets
94
+ ##
95
+ .PHONY: pre-commit
96
+ pre-commit:
97
+ @pre-commit run -a
98
+
99
+ ## clean Clean the workspace
100
+ ##
101
+ .PHONY: clean
102
+ clean:
103
+ rm -rf \
104
+ .cache \
105
+ .vscode \
106
+ dist/ \
107
+ doc/_build \
108
+ src/infinity_grid.egg-info \
109
+ build/
110
+
111
+ rm -f \
112
+ .coverage \
113
+ *.csv \
114
+ *.log \
115
+ *.zip \
116
+ coverage.xml \
117
+ src/infinity_grid/_version.py \
118
+ mypy.xml \
119
+ pytest.xml \
120
+ infinity_grid-*.whl \
121
+ uv.lock
122
+
123
+ find src/infinity_grid -name "__pycache__" | xargs rm -rf
124
+ find tests -name "__pycache__" | xargs rm -rf
125
+ find tools -name ".ipynb_checkpoints" | xargs rm -rf
126
+ find tools -name "__pycache__" | xargs rm -rf
127
+ find tests -name "*.log" | xargs rm -rf
128
+
129
+ ## check-uv Check if uv is installed
130
+ ##
131
+ .PHONY: check-uv
132
+ check-uv:
133
+ @if ! command -v $(UV) >/dev/null; then \
134
+ echo "Error: uv is not installed. Please visit https://github.com/astral-sh/uv for installation instructions."; \
135
+ exit 1; \
136
+ fi