Skip to content

Commit

Permalink
use exchange id in exchange channels
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume De Saint Martin committed Jan 14, 2020
1 parent cb5893a commit 2b7dfc8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def create_evaluators_channel():
await get_chan(MATRIX_CHANNEL).new_consumer(matrix_callback)

await initialize_evaluators(config)
await create_all_type_evaluators(config, "test", ["BTC/USDT"], [TimeFrames.ONE_HOUR])
await create_all_type_evaluators(config, "test", "0", ["BTC/USDT"], [TimeFrames.ONE_HOUR])

await get_chan(MATRIX_CHANNEL).get_internal_producer().send(evaluator_name="test",
evaluator_type="test",
Expand Down
14 changes: 8 additions & 6 deletions octobot_evaluators/api/evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
}


async def create_evaluators(evaluator_parent_class, config, exchange_name,
async def create_evaluators(evaluator_parent_class, config, exchange_name, exchange_id,
cryptocurrencies=None, symbols=None, time_frames=None, relevant_evaluators=CONFIG_WILDCARD) -> list:
return [
await create_evaluator(evaluator_class, config, exchange_name,
await create_evaluator(evaluator_class, config, exchange_name, exchange_id,
cryptocurrency=cryptocurrency,
symbol=symbol,
time_frame=time_frame,
Expand Down Expand Up @@ -73,7 +73,7 @@ def get_evaluator_classes_from_type(evaluator_type, config, activated_only=True)
return create_advanced_types_list(EvaluatorClassTypes[evaluator_type], config)


async def create_evaluator(evaluator_class, config, exchange_name,
async def create_evaluator(evaluator_class, config, exchange_name, exchange_id,
cryptocurrency=None,
symbol=None,
time_frame=None,
Expand All @@ -84,6 +84,7 @@ async def create_evaluator(evaluator_class, config, exchange_name,
if is_relevant_evaluator(eval_class_instance, relevant_evaluators):
eval_class_instance.logger = get_logger(evaluator_class.get_name())
eval_class_instance.exchange_name = exchange_name if exchange_name else None
eval_class_instance.exchange_id = exchange_id if exchange_id else None
eval_class_instance.cryptocurrency = cryptocurrency if cryptocurrency else None
eval_class_instance.symbol = symbol if symbol else None
eval_class_instance.time_frame = time_frame if time_frame else None
Expand Down Expand Up @@ -131,11 +132,12 @@ def _init_time_frames(config) -> list:
return time_frames


async def create_all_type_evaluators(config, exchange_name,
async def create_all_type_evaluators(config, exchange_name, exchange_id,
cryptocurrencies=None,
symbols=None,
time_frames=None,
relevant_evaluators=CONFIG_WILDCARD) -> list:
return [await create_evaluators(evaluator_type, config, exchange_name, symbols=symbols, time_frames=time_frames,
cryptocurrencies=cryptocurrencies, relevant_evaluators=relevant_evaluators)
return [await create_evaluators(evaluator_type, config, exchange_name, exchange_id, symbols=symbols,
time_frames=time_frames, cryptocurrencies=cryptocurrencies,
relevant_evaluators=relevant_evaluators)
for evaluator_type in EvaluatorClassTypes.values()]
2 changes: 1 addition & 1 deletion octobot_evaluators/evaluator/TA_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def start(self) -> None:
"""
try:
from octobot_trading.channels.exchange_channel import get_chan as get_trading_chan
await get_trading_chan(OctoBotTradingChannelsName.OHLCV_CHANNEL.value, self.exchange_name).new_consumer(
await get_trading_chan(OctoBotTradingChannelsName.OHLCV_CHANNEL.value, self.exchange_id).new_consumer(
self.ohlcv_callback) # TODO filter
except ImportError:
self.logger.error("Can't connect to OHLCV trading channel")
Expand Down
3 changes: 3 additions & 0 deletions octobot_evaluators/evaluator/abstract_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self):
# Evaluation related exchange name
self.exchange_name = None

# Evaluation related exchange id
self.exchange_id = None

# Time_frame is the chart time frame (Should be None if wildcard)
self.time_frame = None

Expand Down

0 comments on commit 2b7dfc8

Please sign in to comment.