Skip to content

Commit

Permalink
[Version] v1.5.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Herklos committed May 16, 2020
1 parent 2d76615 commit 959ac99
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.12] - 2020-05-16
### Added
- [OctoBotChannel] Add consumer

## [1.5.11] - 2020-05-14
### Fixed
- [AbstractEvaluator] Priority level
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OctoBot-Evaluators [1.5.11](https://github.com/Drakkar-Software/OctoBot-Evaluators/blob/master/CHANGELOG.md)
# OctoBot-Evaluators [1.5.12](https://github.com/Drakkar-Software/OctoBot-Evaluators/blob/master/CHANGELOG.md)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a0c08eab5d4c440aa6e3fc3061ad0520)](https://app.codacy.com/gh/Drakkar-Software/OctoBot-Evaluators?utm_source=github.com&utm_medium=referral&utm_content=Drakkar-Software/OctoBot-Evaluators&utm_campaign=Badge_Grade_Dashboard)
[![PyPI](https://img.shields.io/pypi/v/OctoBot-Evaluators.svg)](https://pypi.python.org/pypi/OctoBot-Evaluators/)
[![Coverage Status](https://coveralls.io/repos/github/Drakkar-Software/OctoBot-Evaluators/badge.svg)](https://coveralls.io/github/Drakkar-Software/OctoBot-Evaluators)
Expand Down
2 changes: 1 addition & 1 deletion octobot_evaluators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
# License along with this library.

PROJECT_NAME = "OctoBot-Evaluators"
VERSION = "1.5.11" # major.minor.revision
VERSION = "1.5.12" # major.minor.revision
15 changes: 15 additions & 0 deletions octobot_evaluators/consumers/__init__.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Drakkar-Software OctoBot-Evaluators
# Copyright (c) Drakkar-Software, All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
15 changes: 15 additions & 0 deletions octobot_evaluators/consumers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Drakkar-Software OctoBot-Evaluators
# Copyright (c) Drakkar-Software, All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
16 changes: 16 additions & 0 deletions octobot_evaluators/consumers/octobot_channel_consumer.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# cython: language_level=3
# Drakkar-Software OctoBot-Evaluators
# Copyright (c) Drakkar-Software, All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
83 changes: 83 additions & 0 deletions octobot_evaluators/consumers/octobot_channel_consumer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Drakkar-Software OctoBot-Evaluators
# Copyright (c) Drakkar-Software, All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library.
from enum import Enum

from octobot_channels.channels.channel_instances import get_chan_at_id
from octobot_commons.channels_name import OctoBotChannelsName
from octobot_commons.logging.logging_util import get_logger

from octobot_commons.enums import OctoBotChannelSubjects

from octobot_evaluators.api.evaluators import create_all_type_evaluators

OCTOBOT_CHANNEL_EVALUATOR_CONSUMER_LOGGER_TAG = "OctoBotChannelEvaluatorConsumer"


class OctoBotChannelEvaluatorActions(Enum):
"""
OctoBot Channel consumer supported actions
"""

EVALUATOR = "evaluator"


class OctoBotChannelEvaluatorDataKeys(Enum):
"""
OctoBot Channel consumer supported data keys
"""

EXCHANGE_CONFIGURATION = "exchange_configuration"
MATRIX_ID = "matrix_id"
TENTACLES_SETUP_CONFIG = "tentacles_setup_config"
CONFIG = "config"


async def octobot_channel_callback(bot_id, subject, action, data) -> None:
"""
OctoBot channel consumer callback
:param bot_id: the callback bot id
:param subject: the callback subject
:param action: the callback action
:param data: the callback data
"""
if subject == OctoBotChannelSubjects.CREATION.value:
await _handle_creation(bot_id, action, data)


async def _handle_creation(bot_id, action, data):
if action == OctoBotChannelEvaluatorActions.EVALUATOR.value:
try:
exchange_configuration = data[OctoBotChannelEvaluatorDataKeys.EXCHANGE_CONFIGURATION.value]
await create_all_type_evaluators(
config=data[OctoBotChannelEvaluatorDataKeys.CONFIG.value],
tentacles_setup_config=data[OctoBotChannelEvaluatorDataKeys.TENTACLES_SETUP_CONFIG.value],
matrix_id=data[OctoBotChannelEvaluatorDataKeys.MATRIX_ID.value],
exchange_name=exchange_configuration.exchange_name,
bot_id=bot_id,
symbols_by_crypto_currencies=exchange_configuration.symbols_by_crypto_currencies,
symbols=exchange_configuration.symbols,
time_frames=exchange_configuration.time_frames_without_real_time,
real_time_time_frames=exchange_configuration.real_time_time_frames
)
await get_chan_at_id(OctoBotChannelsName.OCTOBOT_CHANNEL.value, bot_id).get_internal_producer() \
.send(bot_id=bot_id,
subject=OctoBotChannelSubjects.NOTIFICATION.value,
action=action,
data={OctoBotChannelEvaluatorDataKeys.MATRIX_ID.value:
data[OctoBotChannelEvaluatorDataKeys.MATRIX_ID.value]})

except Exception as e:
get_logger(OCTOBOT_CHANNEL_EVALUATOR_CONSUMER_LOGGER_TAG).error(f"Error when creating new evaluator {e}")
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ cython==0.29.17
numpy==1.18.3

# Drakkar-Software requirements
OctoBot-Channels>=1.4.4, <1.5
OctoBot-Channels>=1.4.5, <1.5
OctoBot-Commons>=1.3.30, <1.4
OctoBot-Tentacles-Manager>=2.1.1, <2.2
OctoBot-Tentacles-Manager>=2.1.3, <2.2

# Cryptocurrency trading
tulipy==0.4.0
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def build_ext(*args, **kwargs):
packages_list: list = ["octobot_evaluators.channels.evaluators",
"octobot_evaluators.channels.evaluator_channel",
"octobot_evaluators.channels.matrix",
"octobot_evaluators.consumers.octobot_channel_consumer",
"octobot_evaluators.matrices.matrices",
"octobot_evaluators.data.matrix",
"octobot_evaluators.data_manager.matrix_manager",
Expand Down

0 comments on commit 959ac99

Please sign in to comment.