1
0
mirror of https://github.com/Rikj000/MoniGoMani.git synced 2022-03-06 00:08:05 +03:00

🔀 Fixed Merge Conflicts with Feature/GitHub-Action-Workflows

This commit is contained in:
Rik Helsen
2021-07-17 00:31:20 +02:00
15 changed files with 288 additions and 55 deletions

View File

@@ -1,38 +0,0 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
name: "pylint"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '17 11 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: GitHub Action for pylint
uses: cclauss/GitHub-Action-for-pylint@0.7.0

45
.github/workflows/python-analysis.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
name: "pylint"
on:
push:
branches: [ master, feature/gh-action-ci ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '17 11 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 mgm-hurry --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 mgm-hurry --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest

31
.gitignore vendored
View File

@@ -1,30 +1,41 @@
# Ignore the Private Config to prevent accidental pushing
user_data/mgm-config-private.json
# Ignore the HyperOpt Result Files that are used by Default
user_data/mgm-config-hyperopt.json
user_data/strategies/MoniGoManiHyperStrategy.json
# Ignore Release Template
ReleaseTemplate.md
# Ignore Python Caches
user_data/hyperopts/__pycache__/
user_data/mgm_tools/mgm_hurry/__pycache__/
user_data/strategies/__pycache__/
# Ignore Legacy Python Caches
Legacy MoniGoMani/user_data/hyperopts/__pycache__/
Legacy MoniGoMani/user_data/strategies/__pycache__/
__pycache__/
*.pyc
# Ignore Other General User Data
user_data/*_results/
user_data/*.lock
user_data/data/
user_data/logs/
user_data/plot/
# Ignore JetBrains Folder
.idea/
# Ignore VSCodium Folder & Workspace
workspace.code-workspace
.vscode/
# Ignore VSCodium / Visual Studio Code related
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Ignore Logo Folder
Logo/
# Ignore fthypt and legacy pickle Files
*.fthypt
*.pickle
*.pickle
# Ignore pytest cache files
.pytest_cache/

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"python.linting.enabled": true
}

2
requirements-dev.txt Normal file
View File

@@ -0,0 +1,2 @@
pytest==6.2.4
flake8==3.9.2

View File

@@ -0,0 +1,86 @@
import sys
sys.path.append('.')
sys.path.append('..')
from user_data.mgm_tools.mgm_hurry.FreqtradeCli import FreqtradeCli
def test_initialisation_without_logger():
fc = __get_instance('.', use_logger=False)
assert isinstance(fc, FreqtradeCli)
def test_initialisation_with_logger():
fc = __get_instance('.', use_logger=True)
assert isinstance(fc, FreqtradeCli)
def test_set_basedir():
fc = __get_instance('.', use_logger=True)
assert fc.basedir == '.'
def test_set_install_type_to_source():
fc = __get_instance('.', use_logger=True)
fc.install_type = 'source'
assert fc.install_type == 'source'
def test_set_incorrect_install_type_should_return_none():
fc = __get_instance('.', use_logger=True)
fc.install_type = 'foobar'
assert fc.install_type is None
def test_set_freqtrade_binary():
fc = __get_instance('.', use_logger=True)
fc.freqtrade_binary = 'unknown'
assert fc.freqtrade_binary == 'unknown'
def test_installation_exists_should_return_bool():
fc = __get_instance('.', use_logger=True)
# without installation type
assert type(fc.installation_exists()) is bool
def test_installation_exists_faulty_install_type():
fc = __get_instance('.', use_logger=True)
fc.install_type = 'foobar'
assert fc.installation_exists() is False
def test_installation_exists_faulty_freqtrade_binary():
fc = __get_instance('.', use_logger=True)
fc.install_type = 'source'
fc.freqtrade_binary = 'unknown'
assert fc.installation_exists() is False
def test_installation_exists_install_type_docker():
fc = __get_instance('.', use_logger=True)
fc.install_type = 'docker'
fc.freqtrade_binary = 'unknown'
assert fc.installation_exists() is True
"""
Private helper methods
"""
def __get_instance(dir, use_logger=True):
"""
Todo:
- Mock logger object
- Probably mock freqtrade installation
"""
logger = None
if use_logger is True:
from user_data.mgm_tools.mgm_hurry.LeetLogger import get_logger
logger = get_logger()
fc = FreqtradeCli(dir, logger)
return fc

View File

@@ -0,0 +1,35 @@
import pytest
"""
This unit test file will help while splitting mgm-hurry
into more modular code.
1. Create unit test for specific functionality
- Verify unit test succeeds
2. Split and modularize code. The interface should remain unchanged.
3. Run unit test
- Verify unit test still succeeds
Also be aware to unit test on code and cli level if differences could occur.
Interface mgm-hurry:
MGMHurry.
up
install_freqtrade
install_mgm
setup
cleanup
download_candle_data
hyperopt
hyperopt_show_results
hyperopt_show_epoch
hyperopt_apply_epoch
backtest
start_trader
"""
@pytest.mark.skip(reason='Test not implemented.')
def test_basic_usage():
assert NotImplemented

View File

@@ -0,0 +1,12 @@
from logging import Logger
from user_data.mgm_tools.mgm_hurry.LeetLogger import get_logger
import sys
sys.path.append('.')
sys.path.append('..')
def test_initialisation_logger():
logger = get_logger()
assert type(logger) is Logger

View File

@@ -0,0 +1,54 @@
from logging import Logger
import pytest
import sys
sys.path.append('.')
sys.path.append('..')
from user_data.mgm_tools.mgm_hurry.MoniGoManiCli import MoniGoManiCli
def test_initialisation():
cli = __get_instance()
assert type(cli) is MoniGoManiCli
def test_installation_exists_without_installation():
cli = __get_instance()
result = cli.installation_exists()
assert result is False
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
def test_installation_exists_with_config_without_strategy():
assert NotImplemented
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
def test_installation_exists_without_config_with_strategy():
assert NotImplemented
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
def test_installation_exists_with_valid_installation():
assert NotImplemented
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
def test_create_config_files_faulty_target_dir():
assert NotImplemented
@pytest.mark.skip(reason='Test not implemented. Mocking needed.')
def test_create_config_files_faulty_example_file():
assert NotImplemented
"""
Private helper methods
"""
def __get_instance(basedir='.', logger=None):
cli = MoniGoManiCli(basedir, logger)
return cli

8
tox.ini Normal file
View File

@@ -0,0 +1,8 @@
[flake8]
ignore = E226,E302,E41
max-line-length = 127
exclude = tests/*
max-complexity = 10
[pytest]
testpaths = tests

0
user_data/__init__.py Normal file
View File

View File

View File

@@ -5,7 +5,6 @@ import os
# --- ↑ Do not remove these libs ↑ -------------------------------------------------------------------------------------
class FreqtradeCli:
"""
FreqtradeCli is responsible for all Freqtrade (installation) related tasks.
@@ -19,10 +18,14 @@ class FreqtradeCli:
"""
self.basedir = basedir
self.install_type = None
self.logger = logger
self.freqtrade_binary = None
if os.path.exists(f'{self.basedir}/.env/bin/freqtrade') is False:
if logger is None:
return None
self.logger = logger
if os.path.exists(f"{self.basedir}/.env/bin/freqtrade") is False:
logger.warning('🤷♂️ No Freqtrade installation found.')
return None
@@ -51,8 +54,11 @@ class FreqtradeCli:
return self.__install_type
@install_type.setter
def install_type(self, install_type):
self.__install_type = install_type
def install_type(self, p_install_type):
if p_install_type in ['source', 'docker']:
self.__install_type = p_install_type
else:
self.__install_type = None
@property
def freqtrade_binary(self):
@@ -63,6 +69,15 @@ class FreqtradeCli:
self.__freqtrade_binary = freqtrade_binary
def installation_exists(self) -> bool:
"""
Returns true if all is setup correctly
source:
And after all the freqtrade binary is found
in the .env subdirectory.
docker:
Does not check for physic existence of Docker.
But returns True.
"""
if self.__install_type is None:
return False
@@ -73,7 +88,7 @@ class FreqtradeCli:
if self.__install_type == 'docker':
return True
if self.__install_type == 'source' and os.path.exists(f'{self.basedir}/.env/bin/freqtrade'):
if (self.__install_type == 'source') and os.path.exists(f'{self.basedir}/.env/bin/freqtrade'):
return True
return False

View File

@@ -25,7 +25,7 @@ class MoniGoManiCli:
self.logger.warning('🤷♂️ No "mgm-config.json" file found.')
return False
if os.path.exists(f"{self.basedir}/user_data/strategies/MoniGoManiHyperStrategy.py") is False:
if os.path.exists(f'{self.basedir}/user_data/strategies/MoniGoManiHyperStrategy.py') is False:
self.logger.warning('🤷♂️ No "MoniGoManiHyperStrategy.py" file found.')
return False