Skip to content

Commit 31523ee

Browse files
authored
Merge pull request #115 from Azulinho/next_release
load_klines_for_coin() as a service and new best_run.py tool
2 parents 6cf13d8 + 1bc97fe commit 31523ee

13 files changed

+698
-603
lines changed

.github/workflows/next_release.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ jobs:
2424
username: ${{ github.actor }}
2525
password: ${{ secrets.GITHUB_TOKEN }}
2626

27+
- name: pull latest next_release tag
28+
run: |
29+
set -e
30+
docker pull ghcr.io/azulinho/cryptobot:next_release || true
31+
2732
- name: Push to GitHub Packages
2833
uses: docker/build-push-action@v2
2934
with:
3035
tags: ghcr.io/azulinho/cryptobot:next_release
3136
push: true
32-
no-cache: true
37+
no-cache: false
3338

.github/workflows/pr.yaml

Lines changed: 0 additions & 124 deletions
This file was deleted.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Run PR docker-compose based tests
2+
on: pull_request
3+
4+
jobs:
5+
pr_tests:
6+
name: Run PR tests
7+
runs-on: ubuntu-latest
8+
env:
9+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
10+
IMAGE: ghcr.io/azulinho/cryptobot
11+
TAG: pr
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v2
15+
16+
- name: local docker-compose build
17+
run: |
18+
set -e
19+
pip install docker-compose
20+
docker-compose build --no-cache
21+
22+
- name: Login to GitHub Container Registry
23+
uses: docker/login-action@v1
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: run backtesting strategies BuyMoonSellRecoveryStrategy.yaml
30+
run: |
31+
set -e
32+
echo BuyMoonSellRecoveryStrategy.yaml
33+
docker compose run \
34+
--name cryptobot.automated-backtesting.$(whoami) --rm \
35+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
36+
cryptobot \
37+
-c tests/BuyMoonSellRecoveryStrategy.yaml \
38+
-m backtesting -s tests/fake.yaml |tail | tee result.txt
39+
grep ' wins:385 losses:97 stales:107 holds:1' result.txt
40+
41+
- name: run backtesting strategies BuyOnGrowthTrendAfterDropStrategy.yaml
42+
run: |
43+
set -e
44+
echo BuyOnGrowthTrendAfterDropStrategy.yaml
45+
docker compose run \
46+
--name cryptobot.automated-backtesting.$(whoami) --rm \
47+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
48+
cryptobot \
49+
-c tests/BuyOnGrowthTrendAfterDropStrategy.yaml \
50+
-m backtesting -s tests/fake.yaml | tail | tee result.txt
51+
grep 'wins:19 losses:1 stales:77 holds:2' result.txt
52+
53+
54+
- name: run backtesting strategies BuyDropSellRecoveryStrategy.yaml
55+
run: |
56+
set -e
57+
echo BuyDropSellRecoveryStrategy.yaml
58+
docker compose run \
59+
--name cryptobot.automated-backtesting.$(whoami) --rm \
60+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
61+
cryptobot \
62+
-c tests/BuyDropSellRecoveryStrategy.yaml \
63+
-m backtesting -s tests/fake.yaml | tail | tee result.txt
64+
grep 'wins:4 losses:9 stales:1 holds:0' result.txt
65+
66+
- name: run backtesting strategies BuyDropSellRecoveryStrategyWhenBTCisUp.yaml
67+
run: |
68+
set -e
69+
echo BuyDropSellRecoveryStrategyWhenBTCisUp.yaml
70+
docker compose run \
71+
--name cryptobot.automated-backtesting.$(whoami) --rm \
72+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
73+
cryptobot \
74+
-c tests/BuyDropSellRecoveryStrategyWhenBTCisUp.yaml \
75+
-m backtesting -s tests/fake.yaml | tail |tee result.txt
76+
grep 'wins:207 losses:1 stales:648 holds:0' result.txt
77+
78+
- name: run backtesting strategies BuyDropSellRecoveryStrategyWhenBTCisDown.yaml
79+
run: |
80+
set -e
81+
echo BuyDropSellRecoveryStrategyWhenBTCisDown.yaml
82+
docker compose run \
83+
--name cryptobot.automated-backtesting.$(whoami) --rm \
84+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
85+
cryptobot \
86+
-c tests/BuyDropSellRecoveryStrategyWhenBTCisDown.yaml \
87+
-m backtesting -s tests/fake.yaml | tail | tee result.txt
88+
grep 'wins:9 losses:0 stales:97 holds:0' result.txt
89+
90+
- name: run backtesting strategies BuyOnRecoveryAfterDropDuringGrowthTrendStrategy.yaml
91+
run: |
92+
set -e
93+
echo BuyOnRecoveryAfterDropDuringGrowthTrendStrategy.yaml
94+
docker compose run \
95+
--name cryptobot.automated-backtesting.$(whoami) --rm \
96+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
97+
cryptobot \
98+
-c tests/BuyOnRecoveryAfterDropDuringGrowthTrendStrategy.yaml \
99+
-m backtesting -s tests/fake.yaml | tail | tee result.txt
100+
grep 'wins:116 losses:0 stales:358 holds:0' result.txt
101+
102+
- name: run backtesting strategies BuyOnRecoveryAfterDropFromAverageStrategy.yaml
103+
run: |
104+
set -e
105+
echo BuyOnRecoveryAfterDropFromAverageStrategy.yaml
106+
docker compose run \
107+
--name cryptobot.automated-backtesting.$(whoami) --rm \
108+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/app.py" \
109+
cryptobot \
110+
-c tests/BuyOnRecoveryAfterDropFromAverageStrategy.yaml \
111+
-m backtesting -s tests/fake.yaml | tail | tee result.txt
112+
grep 'wins:187 losses:4 stales:598 holds:0' result.txt
113+
114+
115+
- name: run automated-backtesting
116+
run: |
117+
set -ex
118+
echo automated-tests
119+
LOGFILE=tests/price.log.gz
120+
CONFIG=tests/automated-backtesting.yaml
121+
MIN=1
122+
FILTER=""
123+
docker compose run \
124+
--name cryptobot.automated-backtesting.$(whoami) --rm \
125+
--entrypoint="/cryptobot/.venv/bin/python /cryptobot/utils/automated-backtesting.py" \
126+
cryptobot \
127+
-l ${LOGFILE} -c ${CONFIG} -m ${MIN} \
128+
-f "${FILTER}" -s "profit"| tail

.github/workflows/pr_lint.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Run PR lint tests
2+
on: pull_request
3+
4+
jobs:
5+
pr_tests:
6+
name: Run PR tests
7+
runs-on: ubuntu-latest
8+
env:
9+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
10+
steps:
11+
- name: Check out the repo
12+
uses: actions/checkout@v2
13+
14+
- name: install build-essentials
15+
run: sudo apt-get -y install build-essential
16+
17+
- name: install ta-lib
18+
run: |
19+
cd /tmp \
20+
&& wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz \
21+
&& tar xf ta-lib-0.4.0-src.tar.gz \
22+
&& cd ta-lib \
23+
&& ./configure --prefix=/usr \
24+
&& make \
25+
&& sudo make install
26+
27+
- name: pyenv install
28+
uses: "gabrielfalcao/pyenv-action@v5"
29+
with:
30+
command: pyenv install
31+
32+
- name: pip install
33+
run: |
34+
set -e
35+
pip install --upgrade pip
36+
pip install wheel
37+
pip install -r requirements.txt
38+
pip install -r requirements-dev.txt
39+
40+
- name: pytest
41+
run: |
42+
pytest tests/
43+
44+
- name: mypy
45+
run: |
46+
mypy app.py
47+
mypy strategies/*.py
48+
mypy lib/*.py
49+
50+
- name: pylint
51+
run: |
52+
pylint app.py
53+
pylint lib/*.py
54+
pylint strategies/*.py

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ ADD utils/automated-backtesting.sh utils/automated-backtesting.sh
6868
ADD utils/prove-backtesting.py utils/prove-backtesting.py
6969
ADD utils/prove-backtesting.sh utils/prove-backtesting.sh
7070
ADD utils/pull_klines.py utils/pull_klines.py
71+
72+
ADD load_klines_for_coin.py .
7173
EXPOSE 5555
7274
ENTRYPOINT ["/cryptobot/.venv/bin/python", "-u", "app.py"]

0 commit comments

Comments
 (0)