Skip to content

Commit

Permalink
Merge pull request #284 release 0.1.4_2-beta
Browse files Browse the repository at this point in the history
[Version] New daily release 0.1.4_2-beta
  • Loading branch information
Herklos authored Jul 2, 2018
2 parents 01c19cb + 948ce04 commit 57d0707
Show file tree
Hide file tree
Showing 21 changed files with 291 additions and 88 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OctoBot [0.1.4-beta](https://github.com/Drakkar-Software/OctoBot/tree/dev/docs/CHANGELOG.md)
# OctoBot [0.1.4_2-beta](https://github.com/Drakkar-Software/OctoBot/tree/dev/docs/CHANGELOG.md)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c83a127c42ba4a389ca86a92fba7c53c)](https://www.codacy.com/app/paul.bouquet/OctoBot?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot&utm_campaign=Badge_Grade) [![Build Status](https://api.travis-ci.org/Drakkar-Software/OctoBot.svg?branch=dev)](https://travis-ci.org/Drakkar-Software/OctoBot) [![Code Factor](https://www.codefactor.io/repository/github/Drakkar-Software/OctoBot/badge)](https://www.codefactor.io/repository/github/Drakkar-Software/OctoBot/overview/dev) [![Build Status](https://semaphoreci.com/api/v1/herklos/octobot/branches/dev/shields_badge.svg)](https://semaphoreci.com/herklos/octobot) [![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot/badge.svg?branch=dev)](https://coveralls.io/github/Drakkar-Software/OctoBot?branch=dev) [![Codefresh build status]( https://g.codefresh.io/api/badges/build?repoOwner=Drakkar-Software&repoName=OctoBot&branch=dev&pipelineName=OctoBot&accountName=herklos_marketplace&type=cf-1)](https://g.codefresh.io/repositories/Drakkar-Software/OctoBot/builds?filter=trigger:build;branch:dev;service:5b06a377435197b088b1757a~OctoBot) [![Build status](https://ci.appveyor.com/api/projects/status/jr9o8sghywnued9x?svg=true)](https://ci.appveyor.com/project/Herklos/octobot)
<p align="center">
<img src="../assets/octopus.svg" alt="Octobot Logo" height="400" width="400">
Expand Down
13 changes: 11 additions & 2 deletions config/cst.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum

SHORT_VERSION = "0.1.4"
MINOR_VERSION = "1"
MINOR_VERSION = "2"
VERSION_DEV_PHASE = "beta"
VERSION = "{0}-{1}".format(SHORT_VERSION, VERSION_DEV_PHASE)
LONG_VERSION = "{0}_{1}-{2}".format(SHORT_VERSION, MINOR_VERSION, VERSION_DEV_PHASE)
Expand Down Expand Up @@ -75,7 +75,7 @@
# DEBUG options
CONFIG_DEBUG_OPTION_PERF = "performance_analyser"
CONFIG_DEBUG_OPTION_PERF_REFRESH_TIME_MIN = 5
CONFIG_DEBUG_OPTION = "DEBUG"
CONFIG_DEBUG_OPTION = "DEV_MODE"

# SERVICES
CONFIG_CATEGORY_SERVICES = "services"
Expand Down Expand Up @@ -179,11 +179,13 @@
TENTACLE_MODULE_TYPE = "type"
TENTACLE_MODULE_SUBTYPE = "subtype"
TENTACLE_MODULE_VERSION = "version"
TENTACLE_MODULE_DEV = "developing"
TENTACLE_MODULE_CONFIG_FILES = "config_files"
TENTACLE_CREATOR_PATH = "tentacle_creator"
TENTACLE_TEMPLATE_DESCRIPTION = "description"
TENTACLE_TEMPLATE_PATH = "templates"
TENTACLE_TEMPLATE_PRE_EXT = "_tentacle"
TENTACLE_CONFIG_TEMPLATE_PRE_EXT = "_config"
TENTACLE_TEMPLATE_EXT = ".template"

TENTACLE_SONS = {"Social": TENTACLES_EVALUATOR_SOCIAL_PATH,
Expand All @@ -208,6 +210,13 @@
CONFIG_DEFAULT_EVALUATOR_FILE = "config/default_evaluator_config.json"


# Tentacle Config
STRATEGIES_REQUIRED_TIME_FRAME = "required_time_frames"
STRATEGIES_REQUIRED_EVALUATORS = "required_evaluators"
TRADING_MODE_REQUIRED_STRATEGIES = "required_strategies"
TRADING_MODE_SPECIFIC_SYMBOLS = "specific_symbols"


class TentacleManagerActions(Enum):
INSTALL = 1
UNINSTALL = 2
Expand Down
15 changes: 15 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
*It is strongly advised to perform an update of your tentacles after updating OctoBot.*

Changelog for 0.1.4_2-beta
====================
*Released date : July 3 2018*

# Concerned issues :
#281 [Tentacles] handle in development tentacles
#283 [Tentacle Strategies & Trading Mode] add constants to config files

# New features :
- In development tentacles
- Strategies and Trading Mode config creation with tentacle creator

# Bug fix :
-

Changelog for 0.1.4_1-beta
====================
*Released date : July 1 2018*
Expand Down
5 changes: 2 additions & 3 deletions evaluator/RealTime/realtime_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ def __init__(self):
self.load_config()

@classmethod
def get_config_file_name(cls):
return "{0}/{1}/{2}/{3}".format(CONFIG_EVALUATOR, CONFIG_EVALUATOR_REALTIME, EVALUATOR_CONFIG_FOLDER,
cls.get_name() + CONFIG_FILE_EXT)
def get_config_file_name(cls, config_evaluator_type=CONFIG_EVALUATOR_REALTIME):
return super().get_config_file_name(config_evaluator_type)

def stop(self):
self.keep_running = False
Expand Down
5 changes: 2 additions & 3 deletions evaluator/Social/social_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ def __init__(self):
self.load_config()

@classmethod
def get_config_file_name(cls):
return "{0}/{1}/{2}/{3}/{4}".format(TENTACLES_PATH, TENTACLES_EVALUATOR_PATH, CONFIG_EVALUATOR_SOCIAL
, EVALUATOR_CONFIG_FOLDER, cls.get_name() + CONFIG_FILE_EXT)
def get_config_file_name(cls, config_evaluator_type=CONFIG_EVALUATOR_SOCIAL):
return super().get_config_file_name(config_evaluator_type)

def stop(self):
self.keep_running = False
Expand Down
23 changes: 19 additions & 4 deletions evaluator/Strategies/strategies_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from abc import *

from config.cst import CONFIG_EVALUATOR_STRATEGIES, STRATEGIES_REQUIRED_TIME_FRAME, CONFIG_FILE_EXT, \
STRATEGIES_REQUIRED_EVALUATORS
from evaluator.abstract_evaluator import AbstractEvaluator
from tools.evaluator_divergence_analyser import EvaluatorDivergenceAnalyser
from tools.time_frame_manager import TimeFrameManager


class StrategiesEvaluator(AbstractEvaluator):
Expand Down Expand Up @@ -29,14 +32,26 @@ def eval_impl(self) -> None:
raise NotImplementedError("Eval_impl not implemented")

@classmethod
@abstractmethod
def get_config_file_name(cls, config_evaluator_type=CONFIG_EVALUATOR_STRATEGIES):
return super().get_config_file_name(config_evaluator_type)

@classmethod
def get_required_time_frames(cls):
raise NotImplementedError("Get_required_time_frames not implemented")
config = cls.get_evaluator_config()
if STRATEGIES_REQUIRED_TIME_FRAME in config:
return TimeFrameManager.parse_time_frames(config[STRATEGIES_REQUIRED_TIME_FRAME])
else:
raise Exception("'{0}' is missing in {1}".format(STRATEGIES_REQUIRED_TIME_FRAME,
cls.get_config_file_name()))

@classmethod
@abstractmethod
def get_required_evaluators(cls):
raise NotImplementedError("Get_required_evaluators not implemented")
config = cls.get_evaluator_config()
if STRATEGIES_REQUIRED_EVALUATORS in config:
return config[STRATEGIES_REQUIRED_EVALUATORS]
else:
raise Exception("'{0}' is missing in {1}".format(STRATEGIES_REQUIRED_EVALUATORS,
cls.get_config_file_name()))


class MixedStrategiesEvaluator(StrategiesEvaluator):
Expand Down
6 changes: 5 additions & 1 deletion evaluator/TA/TA_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import time
from abc import *

from config.cst import MAX_TA_EVAL_TIME_SECONDS
from config.cst import MAX_TA_EVAL_TIME_SECONDS, CONFIG_EVALUATOR_TA
from evaluator.abstract_evaluator import AbstractEvaluator


Expand All @@ -24,6 +24,10 @@ def get_is_evaluable(self):
def eval_impl(self) -> None:
raise NotImplementedError("Eval_impl not implemented")

@classmethod
def get_config_file_name(cls, config_evaluator_type=CONFIG_EVALUATOR_TA):
return super().get_config_file_name(config_evaluator_type)

def eval(self) -> None:
self.is_updating = True
start_time = time.time()
Expand Down
21 changes: 18 additions & 3 deletions evaluator/abstract_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import time
import copy
import time

from config.config import load_config

from config.cst import *
from evaluator.Dispatchers.abstract_dispatcher import *
from tools.config_manager import ConfigManager


class AbstractEvaluator:
Expand Down Expand Up @@ -37,6 +40,18 @@ def get_all_subclasses(cls):
subclasses_list += subclass.get_all_subclasses()
return subclasses_list

@classmethod
def get_config_file_name(cls, config_evaluator_type=None):
return "{0}/{1}/{2}/{3}/{4}".format(TENTACLES_PATH, TENTACLES_EVALUATOR_PATH, config_evaluator_type
, EVALUATOR_CONFIG_FOLDER, cls.get_name() + CONFIG_FILE_EXT)

@classmethod
def get_evaluator_config(cls):
try:
return load_config(cls.get_config_file_name())
except Exception as e:
raise e

# Used to provide a new logger for this particular indicator
def set_logger(self, logger):
self.logger = logger
Expand Down Expand Up @@ -86,14 +101,14 @@ def eval(self) -> None:
self.ensure_eval_note_is_not_expired()
self.eval_impl()
except Exception as e:
if CONFIG_DEBUG_OPTION in self.config and self.config[CONFIG_DEBUG_OPTION]:
if ConfigManager.is_in_dev_mode(self.config):
raise e
else:
self.logger.error("Exception in eval_impl(): " + str(e))
finally:
if self.eval_note == "nan":
self.eval_note = START_PENDING_EVAL_NOTE
self.logger.warning(str(self.symbol)+" evaluator returned 'nan' as eval_note, ignoring this value.")
self.logger.warning(str(self.symbol) + " evaluator returned 'nan' as eval_note, ignoring this value.")
self.is_updating = False

# eval new data
Expand Down
14 changes: 8 additions & 6 deletions evaluator/symbol_evaluator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import inspect
import logging

from config.cst import EvaluatorMatrixTypes, CONFIG_TRADER_MODE, CONFIG_TRADER, START_PENDING_EVAL_NOTE
Expand All @@ -7,6 +6,7 @@
from evaluator.TA import TAEvaluator
from evaluator.evaluator_creator import EvaluatorCreator
from evaluator.evaluator_matrix import EvaluatorMatrix
from tools.class_inspector import get_class_from_string
from trading.trader import modes
from trading.trader.modes import AbstractTradingMode

Expand Down Expand Up @@ -41,11 +41,13 @@ def set_trader_simulators(self, simulator):

def get_trading_mode_class(self):
if CONFIG_TRADER in self.config and CONFIG_TRADER_MODE in self.config[CONFIG_TRADER]:
if any(m[0] == self.config[CONFIG_TRADER][CONFIG_TRADER_MODE] and
hasattr(m[1], '__bases__') and
AbstractTradingMode in m[1].__bases__
for m in inspect.getmembers(modes)):
return getattr(modes, self.config[CONFIG_TRADER][CONFIG_TRADER_MODE])
trading_mode_class = get_class_from_string(
self.config[CONFIG_TRADER][CONFIG_TRADER_MODE],
AbstractTradingMode,
modes)

if trading_mode_class is not None:
return trading_mode_class

raise Exception("Please specify a valid trading mode in your config file (trader -> mode)")

Expand Down
17 changes: 17 additions & 0 deletions tools/class_inspector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import inspect


def get_class_from_string(class_string, parent, module):
if any(m[0] == class_string and
hasattr(m[1], '__bases__') and
parent in m[1].__bases__
for m in inspect.getmembers(module)):
return getattr(module, class_string)
return None


def get_deep_class_from_string(class_string, module):
for m in inspect.getmembers(module):
if m[0] == class_string:
return getattr(module, class_string)
return None
16 changes: 13 additions & 3 deletions tools/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
import threading

from git import Repo
from git import Repo, InvalidGitRepositoryError

from backtesting.collector.data_collector import DataCollector
from config.cst import ORIGIN_URL, GIT_ORIGIN
Expand All @@ -17,7 +17,12 @@ class Commands:
def update(logger, catch=False):
logger.info("Updating...")
try:
repo = Repo(os.getcwd())
try:
repo = Repo(os.getcwd())
except InvalidGitRepositoryError:
logger.error("Impossible to update if OctoBot. "
"This error can appear when OctoBot's folder is not a git repository.")
return
# git = repo.git

# check origin
Expand Down Expand Up @@ -47,7 +52,12 @@ def update(logger, catch=False):

@staticmethod
def check_bot_update(logger, log=True):
repo = Repo(os.getcwd())
try:
repo = Repo(os.getcwd())
except InvalidGitRepositoryError:
logger.warning("Impossible to check if OctoBot is up to date. "
"This error can appear when OctoBot's folder is not a git repository.")
return True

try:
diff = list(repo.iter_commits('{0}..{1}/{0}'.format(repo.active_branch.name, GIT_ORIGIN)))
Expand Down
7 changes: 7 additions & 0 deletions tools/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil

from config.config import load_config
from config.cst import CONFIG_DEBUG_OPTION


class ConfigManager:
Expand Down Expand Up @@ -42,3 +43,9 @@ def check_config(config_file):
load_config(config_file=config_file, error=True)
except Exception as e:
raise e

@staticmethod
def is_in_dev_mode(config):
if CONFIG_DEBUG_OPTION in config and config[CONFIG_DEBUG_OPTION]:
return True
return False
3 changes: 3 additions & 0 deletions tools/tentacle_creator/templates/Mode_config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\{
"required_strategies": ["FullMixedStrategiesEvaluator"]
}
4 changes: 4 additions & 0 deletions tools/tentacle_creator/templates/Strategies_config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
\{
"required_time_frames" : ["30m", "1h", "2h", "4h", "1d"],
"required_evaluators" : ["*"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ $tentacle_description: {
"subtype": "{{ subtype }}",
"version": "{{ version }}",
"requirements": {{ requirements }},
"config_files": [],
"tests": []
"config_files": {{ config }},
"tests": [],
"developing": true
}
Loading

0 comments on commit 57d0707

Please sign in to comment.