From c8232a9e8fd2f8f1817079827335a9ce0206c488 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 1 Dec 2023 19:13:28 +0200 Subject: [PATCH 01/17] feat: add a mapping from file hashes to strategy names Multiple strategies can be included in a single file, therefore, one hash may be mapped to more than one names. --- packages/valory/skills/decision_maker_abci/skill.yaml | 3 +++ packages/valory/skills/trader_abci/skill.yaml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index a5bf6658a..8e7df1f19 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -208,6 +208,9 @@ models: - stabilityai-stable-diffusion-512-v2-1 - stabilityai-stable-diffusion-768-v2-1 tool_punishment_multiplier: 1 + file_hash_to_strategies_json: + - - hash + - - strategy_name class_name: DecisionMakerParams mech_response: args: diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index bc7029e07..cb2fcfef1 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -190,6 +190,9 @@ models: agent_balance_threshold: 10000000000000000 refill_check_interval: 10 tool_punishment_multiplier: 1 + file_hash_to_strategies_json: + - - hash + - - strategy_name class_name: TraderParams network_subgraph: args: From 5b628236be4ba17a201f404fea63e5171606657d Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 1 Dec 2023 19:11:36 +0200 Subject: [PATCH 02/17] feat: add support for dynamically loading strategies --- .../decision_maker_abci/behaviours/base.py | 150 ++++++++++++++---- .../behaviours/decision_receive.py | 1 - .../skills/decision_maker_abci/handlers.py | 48 +++++- .../skills/decision_maker_abci/models.py | 60 +++++-- .../valory/skills/trader_abci/handlers.py | 6 +- 5 files changed, 213 insertions(+), 52 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index bc00716bb..ac3eecd73 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -22,11 +22,12 @@ import dataclasses from abc import ABC from datetime import datetime, timedelta -from typing import Any, Callable, Generator, List, Optional, cast +from typing import Any, Callable, Dict, Generator, List, Optional, cast from aea.configurations.data_types import PublicId +from aea.protocols.base import Message +from aea.protocols.dialogue.base import Dialogue -from packages.jhehemann.skills.kelly_strategy.models import get_bet_amount_kelly from packages.valory.contracts.erc20.contract import ERC20 from packages.valory.contracts.gnosis_safe.contract import ( GnosisSafeContract, @@ -35,6 +36,7 @@ from packages.valory.contracts.mech.contract import Mech from packages.valory.contracts.multisend.contract import MultiSendContract from packages.valory.protocols.contract_api import ContractApiMessage +from packages.valory.protocols.ipfs import IpfsMessage from packages.valory.skills.abstract_round_abci.base import BaseTxPayload from packages.valory.skills.abstract_round_abci.behaviour_utils import ( BaseBehaviour, @@ -43,7 +45,6 @@ from packages.valory.skills.decision_maker_abci.models import ( DecisionMakerParams, MultisendBatch, - STRATEGY_BET_AMOUNT_PER_CONF_THRESHOLD, SharedState, ) from packages.valory.skills.decision_maker_abci.policy import EGreedyPolicy @@ -63,6 +64,9 @@ SAFE_GAS = 0 CID_PREFIX = "f01701220" WXDAI = "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" +STRATEGY_RUN_METHOD = "run" +BET_AMOUNT_FIELD = "bet_amount" +SUPPORTED_STRATEGY_LOG_LEVELS = ("info", "warning", "error") def remove_fraction_wei(amount: int, fraction: float) -> int: @@ -85,6 +89,26 @@ def __init__(self, **kwargs: Any) -> None: self.multisend_data = b"" self._safe_tx_hash = "" self._policy: Optional[EGreedyPolicy] = None + self._inflight_strategy_req: Optional[str] = None + self._strategies_executables: Dict[str, str] = {} + + @property + def strategy_exec(self) -> str: + """Get the executable strategy file's content.""" + return self._strategies_executables[self.params.trading_strategy] + + def execute_strategy(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: + """Execute the strategy and return the results.""" + if STRATEGY_RUN_METHOD in globals(): + del globals()[STRATEGY_RUN_METHOD] + exec(self.strategy_exec, globals()) # pylint: disable=W0122 # nosec + method = globals().get(STRATEGY_RUN_METHOD, None) + if method is None: + self.context.logger.error( + f"No {STRATEGY_RUN_METHOD!r} method was found in {self.params.trading_strategy} strategy's executable." + ) + return {BET_AMOUNT_FIELD: 0} + return method(*args, **kwargs) @property def params(self) -> DecisionMakerParams: @@ -217,9 +241,69 @@ def check_balance(self) -> WaitableConditionType: self.context.logger.info(f"The safe has {native} xDAI and {collateral}.") return True + def send_message( + self, msg: Message, dialogue: Dialogue, callback: Callable + ) -> None: + """Send a message.""" + self.context.outbox.put_message(message=msg) + nonce = dialogue.dialogue_label.dialogue_reference[0] + self.shared_state.req_to_callback[nonce] = callback + self.shared_state.in_flight_req = True + + def _handle_get_strategy(self, message: IpfsMessage, _: Dialogue) -> None: + """Handle get strategy response""" + strategy_req = self._inflight_strategy_req + if strategy_req is None: + self.context.logger.error(f"No strategy request to handle for {message=}.") + return + + files = list(message.files.values()) + n_files = len(files) + if n_files != 1: + self.context.logger.error( + f"Executables for strategies should be in single files. " + f"Found {n_files} files for strategy {strategy_req} instead." + ) + + # store the executable and remove the hash from the mapping because we have downloaded it + strategy_exec = files[0] + self._strategies_executables[strategy_req] = strategy_exec + self.shared_state.strategy_to_filehash.pop(strategy_req) + self._inflight_strategy_req = None + + def download_next_strategy(self) -> None: + """Download the strategies one by one. + + The next strategy in the list is downloaded each time this method is called. + + We download all the strategies, + because in the future we will perform some complicated logic, + where we utilize more than one, e.g., in case the default fails + or is weaker than another depending on the situation. + + :return: None + """ + if self._inflight_strategy_req is not None: + # there already is a req in flight + return + if len(self.shared_state.strategy_to_filehash) == 0: + # no strategies pending to be fetched + return + for strategy, file_hash in self.shared_state.strategy_to_filehash.items(): + self.context.logger.info(f"Fetching {strategy} strategy...") + ipfs_msg, message = self._build_ipfs_get_file_req(file_hash) + self._inflight_strategy_req = strategy + self.send_message(ipfs_msg, message, self._handle_get_strategy) + return + + def download_strategies(self) -> Generator: + """Download all the strategies, if not yet downloaded.""" + while len(self.shared_state.strategy_to_filehash) > 0: + self.download_next_strategy() + yield from self.sleep(self.params.sleep_time) + def get_bet_amount( self, - strategy: str, win_probability: float, confidence: float, selected_type_tokens_in_pool: int, @@ -227,38 +311,36 @@ def get_bet_amount( bet_fee: int, ) -> Generator[None, None, int]: """Get the bet amount given a specified trading strategy.""" - + yield from self.download_strategies() yield from self.wait_for_condition_with_sleep(self.check_balance) - bankroll = self.token_balance + self.wallet_balance - - # Kelly Criterion does not trade for equally weighted pools. - if ( - strategy == STRATEGY_BET_AMOUNT_PER_CONF_THRESHOLD - or selected_type_tokens_in_pool == other_tokens_in_pool - ): - self.context.logger.info( - "Used trading strategy: Bet amount per confidence threshold" - ) - threshold = round(confidence, 1) - bet_amount = self.params.bet_amount_per_threshold[threshold] - return bet_amount - - self.context.logger.info("Used trading strategy: Kelly Criterion") - bet_amount, info, error = get_bet_amount_kelly( - self.params.bet_kelly_fraction, - bankroll, - win_probability, - confidence, - selected_type_tokens_in_pool, - other_tokens_in_pool, - bet_fee, + self.context.logger.info( + f"Used trading strategy: {self.params.trading_strategy}" + ) + # the following are always passed to a strategy script, which may choose to ignore any + kwargs: Dict[str, Any] = self.params.strategies_kwargs + kwargs.update( + { + "bankroll": self.token_balance + self.wallet_balance, + "win_probability": win_probability, + "confidence": confidence, + "selected_type_tokens_in_pool": selected_type_tokens_in_pool, + "other_tokens_in_pool": other_tokens_in_pool, + "bet_fee": bet_fee, + } ) - if len(info) > 0: - for info_ in info: - self.context.logger.info(info_) - if len(error) > 0: - for error_ in error: - self.context.logger.error(error_) + results = self.execute_strategy(**kwargs) + for level in SUPPORTED_STRATEGY_LOG_LEVELS: + logger = getattr(self.context.logger, level, None) + if logger is not None: + for log in results.get(level, []): + logger(log) + bet_amount = results.get(BET_AMOUNT_FIELD, None) + if bet_amount is None: + self.context.logger.error( + f"Required field {BET_AMOUNT_FIELD!r} was not returned by {self.params.trading_strategy} strategy." + "Setting bet amount to 0." + ) + return 0 return bet_amount def default_error( diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py index fda584961..686dd3cd2 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -315,7 +315,6 @@ def _is_profitable( ) bet_amount = yield from self.get_bet_amount( - self.params.trading_strategy, win_probability, confidence, selected_type_tokens_in_pool, diff --git a/packages/valory/skills/decision_maker_abci/handlers.py b/packages/valory/skills/decision_maker_abci/handlers.py index 060a2155b..0ac2ab56d 100644 --- a/packages/valory/skills/decision_maker_abci/handlers.py +++ b/packages/valory/skills/decision_maker_abci/handlers.py @@ -19,6 +19,11 @@ """This module contains the handler for the 'decision_maker_abci' skill.""" +from typing import cast + +from aea.skills.base import Handler + +from packages.valory.protocols.ipfs import IpfsMessage from packages.valory.skills.abstract_round_abci.handlers import ( ABCIRoundHandler as BaseABCIRoundHandler, ) @@ -28,9 +33,6 @@ from packages.valory.skills.abstract_round_abci.handlers import ( HttpHandler as BaseHttpHandler, ) -from packages.valory.skills.abstract_round_abci.handlers import ( - IpfsHandler as BaseIpfsHandler, -) from packages.valory.skills.abstract_round_abci.handlers import ( LedgerApiHandler as BaseLedgerApiHandler, ) @@ -40,6 +42,7 @@ from packages.valory.skills.abstract_round_abci.handlers import ( TendermintHandler as BaseTendermintHandler, ) +from packages.valory.skills.decision_maker_abci.models import SharedState ABCIHandler = BaseABCIRoundHandler @@ -48,4 +51,41 @@ LedgerApiHandler = BaseLedgerApiHandler ContractApiHandler = BaseContractApiHandler TendermintHandler = BaseTendermintHandler -IpfsHandler = BaseIpfsHandler + + +class IpfsHandler(Handler): + """IPFS message handler.""" + + SUPPORTED_PROTOCOL = IpfsMessage.protocol_id + + def setup(self) -> None: + """Setup""" + + def teardown(self) -> None: + """Teardown.""" + + @property + def shared_state(self) -> SharedState: + """Get the parameters.""" + return cast(SharedState, self.context.state) + + def handle(self, message: IpfsMessage) -> None: + """ + Implement the reaction to an IPFS message. + + :param message: the message + """ + self.context.logger.debug(f"Received message: {message}") + supported_performative = IpfsMessage.Performative.FILES + if message.performative != supported_performative: + self.context.logger.warning( + f"Only IPFS Message {supported_performative} performative is supported. Got {message.performative}." + ) + self.shared_state.in_flight_req = False + return + + dialogue = self.context.ipfs_dialogues.update(message) + nonce = dialogue.dialogue_label.dialogue_reference[0] + callback = self.shared_state.req_to_callback.pop(nonce) + callback(message, dialogue) + self.shared_state.in_flight_req = False diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 35df1bb2e..0ccd58bf9 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -25,7 +25,7 @@ from dataclasses import dataclass, field from pathlib import Path from string import Template -from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union +from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union, Callable, Iterable from aea.exceptions import enforce from aea.skills.base import SkillContext @@ -139,13 +139,29 @@ def __init__(self, *args: Any, skill_context: SkillContext, **kwargs: Any) -> No """Initialize the state.""" super().__init__(*args, skill_context=skill_context, **kwargs) self.redeeming_progress: RedeemingProgress = RedeemingProgress() + self.strategy_to_filehash: Dict[str, str] = {} + self.in_flight_req: bool = False + self.req_to_callback: Dict[str, Callable] = {} def setup(self) -> None: """Set up the model.""" super().setup() + params = self.context.params self.redeeming_progress.event_filtering_batch_size = ( - self.context.params.event_filtering_batch_size + params.event_filtering_batch_size ) + self.strategy_to_filehash = { + value: key + for key, values in params.file_hash_to_strategies.items() + for value in values + } + selected_strategy = params.trading_strategy + strategy_exec = self.strategy_to_filehash.keys() + if selected_strategy not in strategy_exec: + raise ValueError( + f"The selected trading strategy {selected_strategy} " + f"is not in the strategies' executables {strategy_exec}." + ) def extract_keys_from_template(delimiter: str, template: str) -> Set[str]: @@ -173,6 +189,29 @@ def check_prompt_template(bet_prompt_template: PromptTemplate) -> None: ) +def _raise_incorrect_config(key: str, values: Any) -> None: + """Raise a `ValueError` for incorrect configuration of a nested_list workaround.""" + raise ValueError( + f"The given configuration for {key!r} is incorrectly formatted: {values}!" + "The value is expected to be a list of lists that can be represented as a dictionary." + ) + + +def nested_list_todict_workaround( + kwargs: Dict, + key: str, +) -> Dict: + """Get a nested list from the kwargs and convert it to a dictionary.""" + values = list(kwargs.get(key, [])) + if len(values) == 0: + raise ValueError(f"No {key!r} specified in agent's configurations: {kwargs}!") + if any(not issubclass(type(nested_values), Iterable) for nested_values in values): + _raise_incorrect_config(key, values) + if any(len(nested_values) % 2 == 1 for nested_values in values): + _raise_incorrect_config(key, values) + return {value[0]: value[1] for value in values} + + class DecisionMakerParams(MarketManagerParams): """Decision maker's parameters.""" @@ -196,14 +235,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: raise ValueError( f"The trading strategy {self.trading_strategy} is not supported!" ) - # the factor of calculated kelly bet to use for placing bets - self.bet_kelly_fraction: float = self._ensure( - "bet_kelly_fraction", kwargs, float - ) - # this is a mapping from the confidence of a bet's choice to the amount we are willing to bet - self.bet_amount_per_threshold: Dict[float, int] = self._ensure( - "bet_amount_per_threshold", kwargs, Dict[float, int] - ) # the threshold amount in WEI starting from which we are willing to place a bet self.bet_threshold: int = self._ensure("bet_threshold", kwargs, int) # the duration, in seconds, of blacklisting a bet before retrying to make an estimate for it @@ -251,6 +282,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.tool_punishment_multiplier: int = self._ensure( "tool_punishment_multiplier", kwargs, int ) + self.file_hash_to_strategies: Dict[ + str, List[str] + ] = nested_list_todict_workaround( + kwargs, + "file_hash_to_strategies_json", + ) + self.strategies_kwargs: Dict[str, List[Any]] = nested_list_todict_workaround( + kwargs, "strategies_kwargs" + ) super().__init__(*args, **kwargs) @property diff --git a/packages/valory/skills/trader_abci/handlers.py b/packages/valory/skills/trader_abci/handlers.py index 1116e9113..c120c3e89 100644 --- a/packages/valory/skills/trader_abci/handlers.py +++ b/packages/valory/skills/trader_abci/handlers.py @@ -27,9 +27,6 @@ from packages.valory.skills.abstract_round_abci.handlers import ( HttpHandler as BaseHttpHandler, ) -from packages.valory.skills.abstract_round_abci.handlers import ( - IpfsHandler as BaseIpfsHandler, -) from packages.valory.skills.abstract_round_abci.handlers import ( LedgerApiHandler as BaseLedgerApiHandler, ) @@ -39,6 +36,9 @@ from packages.valory.skills.abstract_round_abci.handlers import ( TendermintHandler as BaseTendermintHandler, ) +from packages.valory.skills.decision_maker_abci.handlers import ( + IpfsHandler as BaseIpfsHandler, +) TraderHandler = ABCIRoundHandler From f3655a1b0838c836e1d9788591de4b97c252669c Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:16:13 +0200 Subject: [PATCH 03/17] chore: remove the kelly strategy skill --- .gitignore | 2 - packages/jhehemann/__init__.py | 20 --- .../jhehemann/skills/kelly_strategy/README.md | 5 - .../skills/kelly_strategy/__init__.py | 25 --- .../jhehemann/skills/kelly_strategy/models.py | 142 ------------------ .../skills/kelly_strategy/skill.yaml | 22 --- packages/packages.json | 3 +- packages/valory/agents/trader/aea-config.yaml | 1 - .../skills/decision_maker_abci/skill.yaml | 1 - .../decision_maker_abci/tests/__init__.py | 25 --- .../decision_maker_abci/tests/conftest.py | 34 ----- .../tests/test_behaviours.py | 44 ------ tox.ini | 4 +- 13 files changed, 3 insertions(+), 325 deletions(-) delete mode 100644 packages/jhehemann/__init__.py delete mode 100644 packages/jhehemann/skills/kelly_strategy/README.md delete mode 100644 packages/jhehemann/skills/kelly_strategy/__init__.py delete mode 100644 packages/jhehemann/skills/kelly_strategy/models.py delete mode 100644 packages/jhehemann/skills/kelly_strategy/skill.yaml delete mode 100644 packages/valory/skills/decision_maker_abci/tests/__init__.py delete mode 100644 packages/valory/skills/decision_maker_abci/tests/conftest.py delete mode 100644 packages/valory/skills/decision_maker_abci/tests/test_behaviours.py diff --git a/.gitignore b/.gitignore index 769259560..f2695e299 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,3 @@ trader/ !/packages/valory/agents/trader/ !/packages/valory/services/trader/ /trader_service/ - -kelly_strategy_explanation.md diff --git a/packages/jhehemann/__init__.py b/packages/jhehemann/__init__.py deleted file mode 100644 index 85f1b2b57..000000000 --- a/packages/jhehemann/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""jhehemann packages.""" diff --git a/packages/jhehemann/skills/kelly_strategy/README.md b/packages/jhehemann/skills/kelly_strategy/README.md deleted file mode 100644 index 17cabab69..000000000 --- a/packages/jhehemann/skills/kelly_strategy/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Kelly Strategy - -## Description - -This skill implements a number of helper methods that implement the kelly strategy. They serve as plugins for the decision_maker_abci of the trader agent. diff --git a/packages/jhehemann/skills/kelly_strategy/__init__.py b/packages/jhehemann/skills/kelly_strategy/__init__.py deleted file mode 100644 index 90a362d64..000000000 --- a/packages/jhehemann/skills/kelly_strategy/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the decision maker skill for the trader.""" - -from aea.configurations.base import PublicId - - -PUBLIC_ID = PublicId.from_str("jhehemann/kelly_strategy:0.1.0") diff --git a/packages/jhehemann/skills/kelly_strategy/models.py b/packages/jhehemann/skills/kelly_strategy/models.py deleted file mode 100644 index 0b462013c..000000000 --- a/packages/jhehemann/skills/kelly_strategy/models.py +++ /dev/null @@ -1,142 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the helper functions for the kelly strategy.""" - - -def wei_to_native(wei: int) -> float: - """Convert WEI to native token.""" - return wei / 10**18 - - -def get_max_bet_amount(a: int, x: int, y: int, f: float) -> tuple[int, str]: - """Get max bet amount based on available shares.""" - if x**2 * f**2 + 2 * x * y * f**2 + y**2 * f**2 == 0: - error = ( - "Could not recalculate. " - "Either bankroll is 0 or pool token amount is distributed such as " - "x**2*f**2 + 2*x*y*f**2 + y**2*f**2 == 0:\n" - f"Available tokens: {a}\n" - f"Pool token amounts: {x}, {y}\n" - f"Fee, fee fraction f: {1-f}, {f}" - ) - return 0, error - - pre_root = -2 * x**2 + a * x - 2 * x * y - sqrt = ( - 4 * x**4 - + 8 * x**3 * y - + a**2 * x**2 - + 4 * x**2 * y**2 - + 2 * a**2 * x * y - + a**2 * y**2 - ) - numerator = y * (pre_root + sqrt**0.5 + a * y) - denominator = f * (x**2 + 2 * x * y + y**2) - new_bet_amount = numerator / denominator - return int(new_bet_amount), "" - - -def calculate_kelly_bet_amount( # pylint: disable=too-many-arguments - x: int, y: int, p: float, c: float, b: int, f: float -) -> int: - """Calculate the Kelly bet amount.""" - if b == 0: - return 0 - numerator = ( - -4 * x**2 * y - + b * y**2 * p * c * f - + 2 * b * x * y * p * c * f - + b * x**2 * p * c * f - - 2 * b * y**2 * f - - 2 * b * x * y * f - + ( - ( - 4 * x**2 * y - - b * y**2 * p * c * f - - 2 * b * x * y * p * c * f - - b * x**2 * p * c * f - + 2 * b * y**2 * f - + 2 * b * x * y * f - ) - ** 2 - - ( - 4 - * (x**2 * f - y**2 * f) - * ( - -4 * b * x * y**2 * p * c - - 4 * b * x**2 * y * p * c - + 4 * b * x * y**2 - ) - ) - ) - ** (1 / 2) - ) - denominator = 2 * (x**2 * f - y**2 * f) - kelly_bet_amount = numerator / denominator - return int(kelly_bet_amount) - - -def get_bet_amount_kelly( # pylint: disable=too-many-arguments - bet_kelly_fraction: float, - bankroll: int, - win_probability: float, - confidence: float, - selected_type_tokens_in_pool: int, - other_tokens_in_pool: int, - bet_fee: int, -) -> tuple[int, list[str], list[str]]: - """Calculate the Kelly bet amount.""" - # keep `floor_balance` xDAI in the bankroll - floor_balance = 500000000000000000 - bankroll_adj = bankroll - floor_balance - bankroll_adj_xdai = wei_to_native(bankroll_adj) - info = [f"Adjusted bankroll: {bankroll_adj_xdai} xDAI."] - error = [] - if bankroll_adj <= 0: - error.append( - f"Bankroll ({bankroll_adj}) is less than the floor balance ({floor_balance})." - ) - error.append("Set bet amount to 0.") - error.append("Top up safe with DAI or wait for redeeming.") - return 0, info, error - - fee_fraction = 1 - wei_to_native(bet_fee) - info.append(f"Fee fraction: {fee_fraction}") - kelly_bet_amount = calculate_kelly_bet_amount( - selected_type_tokens_in_pool, - other_tokens_in_pool, - win_probability, - confidence, - bankroll_adj, - fee_fraction, - ) - if kelly_bet_amount < 0: - info.append( - f"Invalid value for kelly bet amount: {kelly_bet_amount}\nSet bet amount to 0." - ) - return 0, info, error - - info.append(f"Kelly bet amount: {wei_to_native(kelly_bet_amount)} xDAI") - info.append(f"Bet kelly fraction: {bet_kelly_fraction}") - adj_kelly_bet_amount = int(kelly_bet_amount * bet_kelly_fraction) - info.append( - f"Adjusted Kelly bet amount: {wei_to_native(adj_kelly_bet_amount)} xDAI" - ) - return adj_kelly_bet_amount, info, error diff --git a/packages/jhehemann/skills/kelly_strategy/skill.yaml b/packages/jhehemann/skills/kelly_strategy/skill.yaml deleted file mode 100644 index d519624d9..000000000 --- a/packages/jhehemann/skills/kelly_strategy/skill.yaml +++ /dev/null @@ -1,22 +0,0 @@ -name: kelly_strategy -author: jhehemann -version: 0.1.0 -type: skill -description: A degenerate skill providing helper functions for the kelly strategy - to the decision_maker_abci of the trader agent. -license: Apache-2.0 -aea_version: '>=1.0.0, <2.0.0' -fingerprint: - README.md: bafybeiev7ybkk3mcz3g7mmzp336uzbjlfu67nti5av47v6bmy2gzng2vwa - __init__.py: bafybeib6swgcthhlaammlwp6amezcwot27sigzvim73sjrnhy2fbutzc4y - models.py: bafybeid7if2cryqe2sc4hh7ofenw4pwhrptrn7qmbe5ra7ixsggpuhbgyy -fingerprint_ignore_patterns: [] -connections: [] -contracts: [] -protocols: [] -skills: [] -behaviours: {} -handlers: {} -models: {} -dependencies: {} -is_abstract: true diff --git a/packages/packages.json b/packages/packages.json index f41a4f52e..9822efcc6 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -14,8 +14,7 @@ "contract/valory/conditional_tokens/0.1.0": "bafybeifu5axib5ifzq6bomfscs7nnx5qknkzymlz6gfn7ohjsb2shghrei", "contract/valory/agent_registry/0.1.0": "bafybeibezt4xtzgf25eidmwev6moki74eufmb4hx7cpvd6odbyoxo42hxi", "contract/valory/service_staking_token/0.1.0": "bafybeig2pnb3f4y65hlhhva52fsrwb6k3dqkqttq43sxd5kb4drgob65oy", - "skill/valory/staking_abci/0.1.0": "bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe", - "skill/jhehemann/kelly_strategy/0.1.0": "bafybeiblziqq774voze5s3xu4bkw3v7e67nfkl76elo555nchnlgx7tgky" + "skill/valory/staking_abci/0.1.0": "bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeie7xyems76v5b4wc2lmaidcujizpxfzjnnwdeokmhje53g7ym25ii", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index d2ec46967..d90dd93aa 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -48,7 +48,6 @@ skills: - valory/decision_maker_abci:0.1.0:bafybeialhiifvrhehvh7gtmkirrodcywrpztxxcz6e4grrfwkxdsv7wody - valory/trader_abci:0.1.0:bafybeibov6x4ifi4775dmqq74ngvjxtsu56stkpaxfzkapk5nsdjqonfcq - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe -- jhehemann/kelly_strategy:0.1.0:bafybeiblziqq774voze5s3xu4bkw3v7e67nfkl76elo555nchnlgx7tgky default_ledger: ethereum required_ledgers: - ethereum diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 8e7df1f19..459f5d983 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -63,7 +63,6 @@ skills: - valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq -- jhehemann/kelly_strategy:0.1.0:bafybeiblziqq774voze5s3xu4bkw3v7e67nfkl76elo555nchnlgx7tgky behaviours: main: args: {} diff --git a/packages/valory/skills/decision_maker_abci/tests/__init__.py b/packages/valory/skills/decision_maker_abci/tests/__init__.py deleted file mode 100644 index da96e5260..000000000 --- a/packages/valory/skills/decision_maker_abci/tests/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the tests for valory/decision_maker_abci.""" - -from aea.configurations.base import PublicId - - -PUBLIC_ID = PublicId.from_str("valory/decision_maker_abci:0.1.0") diff --git a/packages/valory/skills/decision_maker_abci/tests/conftest.py b/packages/valory/skills/decision_maker_abci/tests/conftest.py deleted file mode 100644 index 432304d24..000000000 --- a/packages/valory/skills/decision_maker_abci/tests/conftest.py +++ /dev/null @@ -1,34 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""Conftest module for io tests.""" - -import os -from pathlib import Path - -from hypothesis import settings - - -# pylint: skip-file - - -CI = "CI" -PACKAGE_DIR = Path(__file__).parent.parent -settings.register_profile(CI, deadline=5000) -profile_name = ("default", "CI")[bool(os.getenv("CI"))] diff --git a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py deleted file mode 100644 index bea37a5d3..000000000 --- a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py +++ /dev/null @@ -1,44 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2021-2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""This module contains the tests for valory/decision_maker_abci's behaviours.""" - -from hypothesis import given, settings -from hypothesis import strategies as st - -from packages.jhehemann.skills.kelly_strategy.models import calculate_kelly_bet_amount -from packages.valory.skills.decision_maker_abci.tests.conftest import profile_name - - -settings.load_profile(profile_name) - - -@given( - x=st.integers(min_value=100, max_value=100000), - y=st.integers(min_value=100, max_value=100000), - p=st.floats(min_value=0.6, max_value=1.0), - c=st.floats(min_value=0.6, max_value=1.0), - b=st.floats(min_value=0.5, max_value=2.0), - f=st.floats(min_value=0.98, max_value=0.99), -) -def test_calculate_kelly_bet_amount( - x: int, y: int, p: float, c: float, b: int, f: float -) -> None: - """Test the calculate_kelly_bet_amount function.""" - assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= -10 diff --git a/tox.ini b/tox.ini index 3974f31c2..63b3d8b33 100644 --- a/tox.ini +++ b/tox.ini @@ -64,7 +64,7 @@ setenv = PYTHONPATH={env:PWD:%CD%} PACKAGES_PATHS = packages/valory SKILLS_PATHS = {env:PACKAGES_PATHS}/skills - SERVICE_SPECIFIC_PACKAGES = {env:SKILLS_PATHS}/staking_abci {env:SKILLS_PATHS}/market_manager_abci {env:SKILLS_PATHS}/decision_maker_abci {env:SKILLS_PATHS}/trader_abci {env:SKILLS_PATHS}/tx_settlement_multiplexer_abci packages/jhehemann/skills/kelly_strategy + SERVICE_SPECIFIC_PACKAGES = {env:SKILLS_PATHS}/staking_abci {env:SKILLS_PATHS}/market_manager_abci {env:SKILLS_PATHS}/decision_maker_abci {env:SKILLS_PATHS}/trader_abci {env:SKILLS_PATHS}/tx_settlement_multiplexer_abci [testenv:bandit] skipsdist = True @@ -198,7 +198,7 @@ commands = [testenv:check-handlers] skipsdist = True usedevelop = True -commands = autonomy analyse handlers -h abci -h http -h contract_api -h ledger_api -h signing -i abstract_abci -i contract_subscription -i kelly_strategy +commands = autonomy analyse handlers -h abci -h http -h contract_api -h ledger_api -h signing -i abstract_abci -i contract_subscription [testenv:check-doc-hashes] skipsdist = True From 6ab2b5fa45713451f3cbb732e02e6d2f6d15a0b4 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:17:25 +0200 Subject: [PATCH 04/17] feat: create the strategies' scripts --- strategies/bet_amount_per_threshold.py | 64 +++++++++++ strategies/kelly_criterion.py | 152 +++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 strategies/bet_amount_per_threshold.py create mode 100644 strategies/kelly_criterion.py diff --git a/strategies/bet_amount_per_threshold.py b/strategies/bet_amount_per_threshold.py new file mode 100644 index 000000000..03febe1ea --- /dev/null +++ b/strategies/bet_amount_per_threshold.py @@ -0,0 +1,64 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""This module contains a simple strategy that returns a bet amount based on a mapping.""" + +from typing import Union, List, Dict, Tuple, Any + +REQUIRED_FIELDS = ("confidence", "bet_amount_per_threshold") + + +def check_missing_fields(kwargs: Dict[str, Any]) -> List[str]: + """Check for missing fields and return them, if any.""" + missing = [] + for field in REQUIRED_FIELDS: + if kwargs.get(field, None) is None: + missing.append(field) + return missing + + +def remove_irrelevant_fields(kwargs: Dict[str, Any]) -> Dict[str, Any]: + """Remove the irrelevant fields from the given kwargs.""" + return {key: value for key, value in kwargs.items() if key in REQUIRED_FIELDS} + + +def amount_per_threshold( + confidence: float, bet_amount_per_threshold: Dict[float, int] +) -> Dict[str, Union[int, Tuple[str]]]: + """Get the bet amount per threshold strategy's result.""" + threshold = round(confidence, 1) + bet_amount = bet_amount_per_threshold.get(threshold, None) + + if bet_amount is None: + return { + "error": ( + f"No amount was found in {bet_amount_per_threshold=} for {confidence=}.", + ) + } + return {"bet_amount": bet_amount} + + +def run(*_args, **kwargs) -> Dict[str, Union[int, Tuple[str]]]: + """Run the strategy.""" + missing = check_missing_fields(kwargs) + if len(missing) > 0: + return {"error": (f"Required kwargs {missing} were not provided.",)} + + kwargs = remove_irrelevant_fields(kwargs) + return amount_per_threshold(**kwargs) diff --git a/strategies/kelly_criterion.py b/strategies/kelly_criterion.py new file mode 100644 index 000000000..388f459f2 --- /dev/null +++ b/strategies/kelly_criterion.py @@ -0,0 +1,152 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""This module contains the kelly criterion strategy.""" + +from typing import Dict, Any, List, Union + +REQUIRED_FIELDS = ( + # the fraction of the calculated kelly bet amount to use for placing the bet + "bet_kelly_fraction", + "bankroll", + "win_probability", + "confidence", + "selected_type_tokens_in_pool", + "other_tokens_in_pool", + "bet_fee", + "floor_balance", +) + + +def check_missing_fields(kwargs: Dict[str, Any]) -> List[str]: + """Check for missing fields and return them, if any.""" + missing = [] + for field in REQUIRED_FIELDS: + if kwargs.get(field, None) is None: + missing.append(field) + return missing + + +def remove_irrelevant_fields(kwargs: Dict[str, Any]) -> Dict[str, Any]: + """Remove the irrelevant fields from the given kwargs.""" + return {key: value for key, value in kwargs.items() if key in REQUIRED_FIELDS} + + +def calculate_kelly_bet_amount( + x: int, y: int, p: float, c: float, b: int, f: float +) -> int: + """Calculate the Kelly bet amount.""" + if b == 0: + return 0 + numerator = ( + -4 * x**2 * y + + b * y**2 * p * c * f + + 2 * b * x * y * p * c * f + + b * x**2 * p * c * f + - 2 * b * y**2 * f + - 2 * b * x * y * f + + ( + ( + 4 * x**2 * y + - b * y**2 * p * c * f + - 2 * b * x * y * p * c * f + - b * x**2 * p * c * f + + 2 * b * y**2 * f + + 2 * b * x * y * f + ) + ** 2 + - ( + 4 + * (x**2 * f - y**2 * f) + * ( + -4 * b * x * y**2 * p * c + - 4 * b * x**2 * y * p * c + + 4 * b * x * y**2 + ) + ) + ) + ** (1 / 2) + ) + denominator = 2 * (x**2 * f - y**2 * f) + kelly_bet_amount = numerator / denominator + return int(kelly_bet_amount) + + +def wei_to_native(wei: int) -> float: + """Convert WEI to native token.""" + return wei / 10**18 + + +def get_bet_amount_kelly( # pylint: disable=too-many-arguments + bet_kelly_fraction: float, + bankroll: int, + win_probability: float, + confidence: float, + selected_type_tokens_in_pool: int, + other_tokens_in_pool: int, + bet_fee: int, + floor_balance: int, +) -> Dict[str, Union[int, List[str]]]: + """Calculate the Kelly bet amount.""" + # keep `floor_balance` xDAI in the bankroll + bankroll_adj = bankroll - floor_balance + bankroll_adj_xdai = wei_to_native(bankroll_adj) + info = [f"Adjusted bankroll: {bankroll_adj_xdai} xDAI."] + error = [] + if bankroll_adj <= 0: + error.append( + f"Bankroll ({bankroll_adj}) is less than the floor balance ({floor_balance})." + ) + error.append("Set bet amount to 0.") + error.append("Top up safe with DAI or wait for redeeming.") + return {"bet_amount": 0, "info": info, "error": error} + + fee_fraction = 1 - wei_to_native(bet_fee) + info.append(f"Fee fraction: {fee_fraction}") + kelly_bet_amount = calculate_kelly_bet_amount( + selected_type_tokens_in_pool, + other_tokens_in_pool, + win_probability, + confidence, + bankroll_adj, + fee_fraction, + ) + if kelly_bet_amount < 0: + info.append( + f"Invalid value for kelly bet amount: {kelly_bet_amount}\nSet bet amount to 0." + ) + return {"bet_amount": 0, "info": info, "error": error} + + info.append(f"Kelly bet amount: {wei_to_native(kelly_bet_amount)} xDAI") + info.append(f"Bet kelly fraction: {bet_kelly_fraction}") + adj_kelly_bet_amount = int(kelly_bet_amount * bet_kelly_fraction) + info.append( + f"Adjusted Kelly bet amount: {wei_to_native(adj_kelly_bet_amount)} xDAI" + ) + return {"bet_amount": adj_kelly_bet_amount, "info": info, "error": error} + + +def run(*_args, **kwargs) -> Dict[str, Union[int, List[str]]]: + """Run the strategy.""" + missing = check_missing_fields(kwargs) + if len(missing) > 0: + return {"error": [f"Required kwargs {missing} were not provided."]} + + kwargs = remove_irrelevant_fields(kwargs) + return get_bet_amount_kelly(**kwargs) From f33baa202d19ccbc134f9ed461a4a9bc89fe7ed2 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:19:08 +0200 Subject: [PATCH 05/17] feat: add ipfs protocol for fetching the strategies --- packages/valory/skills/decision_maker_abci/skill.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 459f5d983..d64df5515 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -59,6 +59,7 @@ contracts: protocols: - valory/contract_api:1.0.0:bafybeialhbjvwiwcnqq3ysxcyemobcbie7xza66gaofcvla5njezkvhcka - valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru +- valory/ipfs:0.1.0:bafybeiedxeismnx3k5ty4mvvhlqideixlhqmi5mtcki4lxqfa7uqh7p33u skills: - valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i From 49186c1825c016a000fe383c7de8c226f0a09540 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:20:23 +0200 Subject: [PATCH 06/17] feat: create the `strategies_kwargs` configuration This is for passing parameters to the dynamically loaded strategies without needing to change the service's implementation. --- .../skills/decision_maker_abci/skill.yaml | 22 +++++++------------ packages/valory/skills/trader_abci/skill.yaml | 22 +++++++------------ 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index d64df5515..2ab1ccd85 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -167,20 +167,7 @@ models: use_termination: false mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' sample_bets_closing_days: 10 - trading_strategy: bet_amount_per_conf_threshold - bet_kelly_fraction: 1.0 - bet_amount_per_threshold: - 0.0: 0 - 0.1: 0 - 0.2: 0 - 0.3: 0 - 0.4: 0 - 0.5: 0 - 0.6: 0 - 0.7: 0 - 0.8: 0 - 0.9: 0 - 1.0: 0 + trading_strategy: strategy_name bet_threshold: 100000000000000000 blacklisting_duration: 3600 ipfs_address: https://gateway.autonolas.tech/ipfs/ @@ -211,6 +198,13 @@ models: file_hash_to_strategies_json: - - hash - - strategy_name + strategies_kwargs: + - - bet_kelly_fraction + - 1.0 + - - floor_balance + - 500000000000000000 + - - bet_amount_per_threshold + - {0.0: 0, 0.1: 0, 0.2: 0, 0.3: 0, 0.4: 0, 0.5: 0, 0.6: 0, 0.7: 0, 0.8: 0, 0.9: 0, 1.0: 0} class_name: DecisionMakerParams mech_response: args: diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index cb2fcfef1..35e5ae3b5 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -146,20 +146,7 @@ models: abt_error_mult: 5 mech_agent_address: '0xff82123dfb52ab75c417195c5fdb87630145ae81' sample_bets_closing_days: 10 - trading_strategy: bet_amount_per_conf_threshold - bet_kelly_fraction: 1.0 - bet_amount_per_threshold: - 0.0: 0 - 0.1: 0 - 0.2: 0 - 0.3: 0 - 0.4: 0 - 0.5: 0 - 0.6: 0 - 0.7: 0 - 0.8: 0 - 0.9: 0 - 1.0: 0 + trading_strategy: strategy_name bet_threshold: 100000000000000000 blacklisting_duration: 3600 ipfs_address: https://gateway.autonolas.tech/ipfs/ @@ -193,6 +180,13 @@ models: file_hash_to_strategies_json: - - hash - - strategy_name + strategies_kwargs: + - - bet_kelly_fraction + - 1.0 + - - floor_balance + - 500000000000000000 + - - bet_amount_per_threshold + - { 0.0: 0, 0.1: 0, 0.2: 0, 0.3: 0, 0.4: 0, 0.5: 0, 0.6: 0, 0.7: 0, 0.8: 0, 0.9: 0, 1.0: 0 } class_name: TraderParams network_subgraph: args: From 60fbb1d4ff05ae2cc04fa7b9dd754204c407d82e Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:20:49 +0200 Subject: [PATCH 07/17] chore: update the agent and service configs --- packages/valory/agents/trader/aea-config.yaml | 19 +++------- packages/valory/services/trader/service.yaml | 35 +++++++------------ 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index d90dd93aa..f9c3bfdc9 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -164,22 +164,9 @@ models: languages: ${list:["en_US"]} average_block_time: ${int:5} abt_error_mult: ${int:5} - mech_agent_address: ${str:0xff82123dfb52ab75c417195c5fdb87630145ae81} + mech_agent_address: ${str:0x77af31De935740567Cf4fF1986D04B2c964A786a} sample_bets_closing_days: ${int:10} - trading_strategy: ${str:bet_amount_per_conf_threshold} - bet_kelly_fraction: ${float:1.0} - bet_amount_per_threshold: - 0.0: ${int:0} - 0.1: ${int:0} - 0.2: ${int:0} - 0.3: ${int:0} - 0.4: ${int:0} - 0.5: ${int:0} - 0.6: ${int:600000000000000000} - 0.7: ${int:900000000000000000} - 0.8: ${int:1000000000000000000} - 0.9: ${int:10000000000000000000} - 1.0: ${int:100000000000000000000} + trading_strategy: ${str:kelly_criterion} bet_threshold: ${int:100000000000000000} blacklisting_duration: ${int:3600} ipfs_address: ${str:https://gateway.autonolas.tech/ipfs/} @@ -205,6 +192,8 @@ models: agent_balance_threshold: ${int:10000000000000000} refill_check_interval: ${int:10} tool_punishment_multiplier: ${int:1} + file_hash_to_strategies_json: ${list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + strategies_kwargs: ${list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} --- public_id: valory/p2p_libp2p_client:0.1.0 type: connection diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index f7bae1c28..7083cba31 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -79,20 +79,7 @@ type: skill abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} - trading_strategy: ${TRADING_STRATEGY:str:bet_amount_per_conf_threshold} - bet_kelly_fraction: ${BET_KELLY_FRACTION:float:1.0} - bet_amount_per_threshold: &id004 - 0.0: ${BET_AMOUNT_PER_THRESHOLD_000:int:0} - 0.1: ${BET_AMOUNT_PER_THRESHOLD_010:int:0} - 0.2: ${BET_AMOUNT_PER_THRESHOLD_020:int:0} - 0.3: ${BET_AMOUNT_PER_THRESHOLD_030:int:0} - 0.4: ${BET_AMOUNT_PER_THRESHOLD_040:int:0} - 0.5: ${BET_AMOUNT_PER_THRESHOLD_050:int:0} - 0.6: ${BET_AMOUNT_PER_THRESHOLD_060:int:600000000000000000} - 0.7: ${BET_AMOUNT_PER_THRESHOLD_070:int:900000000000000000} - 0.8: ${BET_AMOUNT_PER_THRESHOLD_080:int:1000000000000000000} - 0.9: ${BET_AMOUNT_PER_THRESHOLD_090:int:10000000000000000000} - 1.0: ${BET_AMOUNT_PER_THRESHOLD_100:int:100000000000000000000} + trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} ipfs_address: ${IPFS_ADDRESS:str:https://gateway.autonolas.tech/ipfs/} @@ -119,6 +106,8 @@ type: skill agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000} refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10} tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} benchmark_tool: &id005 args: log_dir: ${LOG_DIR:str:/benchmarks} @@ -169,9 +158,7 @@ type: skill abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} - trading_strategy: ${TRADING_STRATEGY:str:bet_amount_per_conf_threshold} - bet_kelly_fraction: ${BET_KELLY_FRACTION:float:1.0} - bet_amount_per_threshold: *id004 + trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} ipfs_address: ${IPFS_ADDRESS:str:https://gateway.autonolas.tech/ipfs/} @@ -198,6 +185,8 @@ type: skill agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000} refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10} tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} benchmark_tool: *id005 2: models: @@ -246,9 +235,7 @@ type: skill abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} - trading_strategy: ${TRADING_STRATEGY:str:bet_amount_per_conf_threshold} - bet_kelly_fraction: ${BET_KELLY_FRACTION:float:1.0} - bet_amount_per_threshold: *id004 + trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} ipfs_address: ${IPFS_ADDRESS:str:https://gateway.autonolas.tech/ipfs/} @@ -275,6 +262,8 @@ type: skill agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000} refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10} tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} benchmark_tool: *id005 3: models: @@ -323,9 +312,7 @@ type: skill abt_error_mult: ${ABT_ERROR_MULT:int:5} mech_agent_address: ${MECH_AGENT_ADDRESS:str:0xff82123dfb52ab75c417195c5fdb87630145ae81} sample_bets_closing_days: ${SAMPLE_BETS_CLOSING_DAYS:int:10} - trading_strategy: ${TRADING_STRATEGY:str:bet_amount_per_conf_threshold} - bet_kelly_fraction: ${BET_KELLY_FRACTION:float:1.0} - bet_amount_per_threshold: *id004 + trading_strategy: ${TRADING_STRATEGY:str:kelly_criterion} bet_threshold: ${BET_THRESHOLD:int:100000000000000000} blacklisting_duration: ${BLACKLISTING_DURATION:int:3600} ipfs_address: ${IPFS_ADDRESS:str:https://gateway.autonolas.tech/ipfs/} @@ -352,6 +339,8 @@ type: skill agent_balance_threshold: ${AGENT_BALANCE_THRESHOLD:int:10000000000000000} refill_check_interval: ${REFILL_CHECK_INTERVAL:int:10} tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} benchmark_tool: *id005 --- public_id: valory/ledger:0.19.0 From 8a4f52010b6dcdf640972494650e0957132994f3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:22:16 +0200 Subject: [PATCH 08/17] chore: remove max bet amount depending on removed property --- .../behaviours/decision_request.py | 5 ++--- .../skills/decision_maker_abci/models.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py index fce0e127d..66bfce342 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_request.py @@ -116,9 +116,8 @@ def n_slots_supported(self) -> bool: @property def xdai_deficit(self) -> int: - """Get the amount of missing xDAI for sending the request plus betting the maximum amount.""" - max_bet_amount = 0 if self.params.using_kelly else self.params.max_bet_amount - return (self.price + max_bet_amount) - self.wallet_balance + """Get the amount of missing xDAI for sending the request.""" + return self.price - self.wallet_balance @property def multisend_optional(self) -> bool: diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 0ccd58bf9..9689a9557 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -25,7 +25,18 @@ from dataclasses import dataclass, field from pathlib import Path from string import Template -from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union, Callable, Iterable +from typing import ( + Any, + Callable, + Dict, + Iterable, + List, + Optional, + Set, + Tuple, + Type, + Union, +) from aea.exceptions import enforce from aea.skills.base import SkillContext @@ -298,11 +309,6 @@ def using_kelly(self) -> bool: """Get the max bet amount if the `bet_amount_per_conf_threshold` strategy is used.""" return self.trading_strategy == STRATEGY_KELLY_CRITERION - @property - def max_bet_amount(self) -> int: - """Get the max bet amount for the `bet_amount_per_conf_threshold` strategy.""" - return max(self.bet_amount_per_threshold.values()) - @property def ipfs_address(self) -> str: """Get the IPFS address.""" From 45a5ea6cad8d206974c82d5fcd222e617e47893c Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:22:42 +0200 Subject: [PATCH 09/17] chore: do not shadow `dataclass`' `field` --- packages/valory/skills/decision_maker_abci/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 9689a9557..91258416c 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -385,7 +385,7 @@ def __init__(self, **kwargs: Any) -> None: self.info_utility = float(kwargs.pop("info_utility")) # all the fields are probabilities; run checks on whether the current prediction response is valid or not. - probabilities = (getattr(self, field) for field in self.__annotations__) + probabilities = (getattr(self, field_) for field_ in self.__annotations__) if ( any(not (0 <= prob <= 1) for prob in probabilities) or self.p_yes + self.p_no != 1 From e372fd71d3ff27e700e343855f1e290fd4178226 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Mon, 4 Dec 2023 20:29:49 +0200 Subject: [PATCH 10/17] chore: run generators --- packages/packages.json | 10 ++--- packages/valory/agents/trader/aea-config.yaml | 6 +-- packages/valory/services/trader/service.yaml | 10 ++--- .../skills/decision_maker_abci/skill.yaml | 39 +++++++++++-------- packages/valory/skills/trader_abci/skill.yaml | 32 +++++++++------ .../tx_settlement_multiplexer_abci/skill.yaml | 2 +- 6 files changed, 58 insertions(+), 41 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 9822efcc6..785943014 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i", - "skill/valory/decision_maker_abci/0.1.0": "bafybeialhiifvrhehvh7gtmkirrodcywrpztxxcz6e4grrfwkxdsv7wody", - "skill/valory/trader_abci/0.1.0": "bafybeibov6x4ifi4775dmqq74ngvjxtsu56stkpaxfzkapk5nsdjqonfcq", + "skill/valory/decision_maker_abci/0.1.0": "bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha", + "skill/valory/trader_abci/0.1.0": "bafybeicv3wxg4sdyj6yda32a5lcygicxy55baai2qvu2spwqcxdcfnri7i", "contract/valory/market_maker/0.1.0": "bafybeid5jnetbsusgxkpqzwyiqlwut55xktfbeloipxcemcuu5oopmqtl4", - "agent/valory/trader/0.1.0": "bafybeihspfzzsl4rx2x2zijgunoiqizmeqj64lxepnrcqzcefophwpfofq", - "service/valory/trader/0.1.0": "bafybeiabuoarf6stx6a7ojfo6jdhofpu4ch75dtkvc7leniiqnhbj3cwb4", + "agent/valory/trader/0.1.0": "bafybeiccvcjf4zavbrurltv6eyduvdt7dzlulvdx7zowdna7iww76czynm", + "service/valory/trader/0.1.0": "bafybeiflyaf3w5zywjt4kvph7paki7dusieyzykdd2z6p4tdmrvj44rgwa", "contract/valory/erc20/0.1.0": "bafybeiepg5ymxhtylgijs3mf3lezz6cwcsougbrv2gr4xcq3bp5wxusi64", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiaufmwkixphmda3jax4vprbdjn57axe655cbougexwml5ymsc6si4", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y", "contract/valory/mech/0.1.0": "bafybeieo65rtidzgrx22la7z7azoqbisd35hnoqfw7l3xxctotvctjlkju", "contract/valory/realitio/0.1.0": "bafybeieoily22pasgkzzcyawhqyrsko7b52lghnvwuskhomavb7tlb6pxa", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index f9c3bfdc9..a0ca11eff 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -43,10 +43,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiencz2uytz6fqj5wg7mcunevxjh4xg5gd6pqcgkshgqywhcimweyi - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiaufmwkixphmda3jax4vprbdjn57axe655cbougexwml5ymsc6si4 +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeialhiifvrhehvh7gtmkirrodcywrpztxxcz6e4grrfwkxdsv7wody -- valory/trader_abci:0.1.0:bafybeibov6x4ifi4775dmqq74ngvjxtsu56stkpaxfzkapk5nsdjqonfcq +- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha +- valory/trader_abci:0.1.0:bafybeicv3wxg4sdyj6yda32a5lcygicxy55baai2qvu2spwqcxdcfnri7i - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 7083cba31..22fe27ae9 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeihspfzzsl4rx2x2zijgunoiqizmeqj64lxepnrcqzcefophwpfofq +agent: valory/trader:0.1.0:bafybeiccvcjf4zavbrurltv6eyduvdt7dzlulvdx7zowdna7iww76czynm number_of_agents: 4 deployment: {} --- @@ -108,7 +108,7 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} - benchmark_tool: &id005 + benchmark_tool: &id004 args: log_dir: ${LOG_DIR:str:/benchmarks} 1: @@ -187,7 +187,7 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} - benchmark_tool: *id005 + benchmark_tool: *id004 2: models: params: @@ -264,7 +264,7 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} - benchmark_tool: *id005 + benchmark_tool: *id004 3: models: params: @@ -341,7 +341,7 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} - benchmark_tool: *id005 + benchmark_tool: *id004 --- public_id: valory/ledger:0.19.0 type: connection diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 2ab1ccd85..8802cd70e 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,11 +12,11 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeif6rvycsnnbipxyv3yklbnnt4cgvj7elgeg55jzys5z24ncubdrxa + behaviours/base.py: bafybeihe53zczkaubcjfrq3wrke2ebrsyewpvkweptltobtktv43pgctvu behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa behaviours/blacklisting.py: bafybeierwdzn6vav54l6zym77hhx2vdx3jtnnwpbhwmwwyrqzncwjwkxu4 - behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m - behaviours/decision_request.py: bafybeievr7vae43e7jr4eqqhwe3emvgiih7ysa66jcb5g2oz5lbxua232q + behaviours/decision_receive.py: bafybeia4me35pkspnytwb7lfo3hoxey7d6rolkn57ixwqeecmgtiliw27m + behaviours/decision_request.py: bafybeidhmhjxt5xjhznxchqqqh6ohdssyyyzuqxv6dfdvpza7c2bxigajq behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm behaviours/reedem.py: bafybeiekq77eatvf7xczbnyd4s6met4ci57ethwwoyxf5mhrcq7vuwiaxu behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm @@ -24,8 +24,8 @@ fingerprint: behaviours/tool_selection.py: bafybeifpvrrbftlkjsoiysnasihzttousk6hxnukzrln6z2d33e3zexkje dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya - handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeihmqhxixmklpp656o7i27fas2afabusmar2heyfnx5e3kgzdcvkji + handlers.py: bafybeibrn7asqnilxzr7tamapg2ymuvxu4bapgqm6hegnqeqfzb7tgdrse + models.py: bafybeig5qavsmh6acdh4rhpv6qpbqaew7kiy6u2g3q5ks4pyqxxf6nm5sa payloads.py: bafybeigcic4vewdglakzpyqevhfwsolh4ywnbvxo5bgned7gl5uo3jif7m policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm @@ -41,9 +41,6 @@ fingerprint: states/redeem.py: bafybeie63laufsdxhf4vngmon5lne7cpmvvosqervp6l2riysqnwuotzim states/sampling.py: bafybeidnvdogjlthjfe7jpaiuezm3xydrbxxukyoss4gx6t5fdin52rsta states/tool_selection.py: bafybeiaaijv6dukp3bmsptcwkcmumc6wu6ztzkvaqzsqqjbfn4ozgyuykq - tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i - tests/conftest.py: bafybeic2xlujtbkyqk2zzpo5vorefwa3nwgfwmrk5rx77vu4gfyrn3pv5m - tests/test_behaviours.py: bafybeif5cb3kvmaytv77ur6mbc7uyoiyjbon7vpqv6xo7m4dy634wlbsku fingerprint_ignore_patterns: [] connections: [] contracts: @@ -196,15 +193,25 @@ models: - stabilityai-stable-diffusion-768-v2-1 tool_punishment_multiplier: 1 file_hash_to_strategies_json: - - - hash - - - strategy_name + - - hash + - - strategy_name strategies_kwargs: - - - bet_kelly_fraction - - 1.0 - - - floor_balance - - 500000000000000000 - - - bet_amount_per_threshold - - {0.0: 0, 0.1: 0, 0.2: 0, 0.3: 0, 0.4: 0, 0.5: 0, 0.6: 0, 0.7: 0, 0.8: 0, 0.9: 0, 1.0: 0} + - - bet_kelly_fraction + - 1.0 + - - floor_balance + - 500000000000000000 + - - bet_amount_per_threshold + - 0.0: 0 + 0.1: 0 + 0.2: 0 + 0.3: 0 + 0.4: 0 + 0.5: 0 + 0.6: 0 + 0.7: 0 + 0.8: 0 + 0.9: 0 + 1.0: 0 class_name: DecisionMakerParams mech_response: args: diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 35e5ae3b5..72ddc3a7f 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -12,7 +12,7 @@ fingerprint: composition.py: bafybeiajga2m7pv7v4bxsjsnncavdns6gujg7qg7opfjyznlzip3gbd3nm dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm fsm_specification.yaml: bafybeihlhdsmmihnvwtggc2t2neqkm5uduw5krpgcxpz7m7xp5kjkf6jsm - handlers.py: bafybeicamc6vmozij5dwvkxmbxjazsgf3sacojhstbjtq7vfggszxugvey + handlers.py: bafybeibkiqwe7hoqccjirimd44nzeqkabc7oo74romqklssion27s5sa2a models.py: bafybeifxiptjrnv4hbw5l3mfxvb7hksmxf726kvab5lcms5btuc3vaahem fingerprint_ignore_patterns: [] connections: [] @@ -25,8 +25,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeialhiifvrhehvh7gtmkirrodcywrpztxxcz6e4grrfwkxdsv7wody -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiaufmwkixphmda3jax4vprbdjn57axe655cbougexwml5ymsc6si4 +- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: @@ -178,15 +178,25 @@ models: refill_check_interval: 10 tool_punishment_multiplier: 1 file_hash_to_strategies_json: - - - hash - - - strategy_name + - - hash + - - strategy_name strategies_kwargs: - - - bet_kelly_fraction - - 1.0 - - - floor_balance - - 500000000000000000 - - - bet_amount_per_threshold - - { 0.0: 0, 0.1: 0, 0.2: 0, 0.3: 0, 0.4: 0, 0.5: 0, 0.6: 0, 0.7: 0, 0.8: 0, 0.9: 0, 1.0: 0 } + - - bet_kelly_fraction + - 1.0 + - - floor_balance + - 500000000000000000 + - - bet_amount_per_threshold + - 0.0: 0 + 0.1: 0 + 0.2: 0 + 0.3: 0 + 0.4: 0 + 0.5: 0 + 0.6: 0 + 0.7: 0 + 0.8: 0 + 0.9: 0 + 1.0: 0 class_name: TraderParams network_subgraph: args: diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index cc31799c2..3ce43ca50 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -21,7 +21,7 @@ protocols: - valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru skills: - valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e -- valory/decision_maker_abci:0.1.0:bafybeialhiifvrhehvh7gtmkirrodcywrpztxxcz6e4grrfwkxdsv7wody +- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: From b085fa27eea9e07853d2b3fd50c025c15e0b4df0 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 5 Dec 2023 13:06:57 +0200 Subject: [PATCH 11/17] refactor: persist strategies executable across periods --- .../valory/skills/decision_maker_abci/behaviours/base.py | 7 +++---- packages/valory/skills/decision_maker_abci/models.py | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index ac3eecd73..becc11a33 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -90,12 +90,11 @@ def __init__(self, **kwargs: Any) -> None: self._safe_tx_hash = "" self._policy: Optional[EGreedyPolicy] = None self._inflight_strategy_req: Optional[str] = None - self._strategies_executables: Dict[str, str] = {} @property def strategy_exec(self) -> str: """Get the executable strategy file's content.""" - return self._strategies_executables[self.params.trading_strategy] + return self.shared_state.strategies_executables[self.params.trading_strategy] def execute_strategy(self, *args: Any, **kwargs: Any) -> Dict[str, Any]: """Execute the strategy and return the results.""" @@ -251,7 +250,7 @@ def send_message( self.shared_state.in_flight_req = True def _handle_get_strategy(self, message: IpfsMessage, _: Dialogue) -> None: - """Handle get strategy response""" + """Handle get strategy response.""" strategy_req = self._inflight_strategy_req if strategy_req is None: self.context.logger.error(f"No strategy request to handle for {message=}.") @@ -267,7 +266,7 @@ def _handle_get_strategy(self, message: IpfsMessage, _: Dialogue) -> None: # store the executable and remove the hash from the mapping because we have downloaded it strategy_exec = files[0] - self._strategies_executables[strategy_req] = strategy_exec + self.shared_state.strategies_executables[strategy_req] = strategy_exec self.shared_state.strategy_to_filehash.pop(strategy_req) self._inflight_strategy_req = None diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 91258416c..e00551c43 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -151,6 +151,7 @@ def __init__(self, *args: Any, skill_context: SkillContext, **kwargs: Any) -> No super().__init__(*args, skill_context=skill_context, **kwargs) self.redeeming_progress: RedeemingProgress = RedeemingProgress() self.strategy_to_filehash: Dict[str, str] = {} + self.strategies_executables: Dict[str, str] = {} self.in_flight_req: bool = False self.req_to_callback: Dict[str, Callable] = {} From 942494b443fbc69437cc6b99f475e74ec2d49ab2 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 5 Dec 2023 13:09:54 +0200 Subject: [PATCH 12/17] feat: add support for `IPFS_HASH` too --- .../skills/decision_maker_abci/handlers.py | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/handlers.py b/packages/valory/skills/decision_maker_abci/handlers.py index 0ac2ab56d..defe8e3ca 100644 --- a/packages/valory/skills/decision_maker_abci/handlers.py +++ b/packages/valory/skills/decision_maker_abci/handlers.py @@ -21,12 +21,11 @@ from typing import cast -from aea.skills.base import Handler - from packages.valory.protocols.ipfs import IpfsMessage from packages.valory.skills.abstract_round_abci.handlers import ( ABCIRoundHandler as BaseABCIRoundHandler, ) +from packages.valory.skills.abstract_round_abci.handlers import AbstractResponseHandler from packages.valory.skills.abstract_round_abci.handlers import ( ContractApiHandler as BaseContractApiHandler, ) @@ -53,16 +52,12 @@ TendermintHandler = BaseTendermintHandler -class IpfsHandler(Handler): +class IpfsHandler(AbstractResponseHandler): """IPFS message handler.""" SUPPORTED_PROTOCOL = IpfsMessage.protocol_id - - def setup(self) -> None: - """Setup""" - - def teardown(self) -> None: - """Teardown.""" + allowed_response_performatives = frozenset({IpfsMessage.Performative.IPFS_HASH}) + custom_support_performative = IpfsMessage.Performative.FILES @property def shared_state(self) -> SharedState: @@ -74,18 +69,15 @@ def handle(self, message: IpfsMessage) -> None: Implement the reaction to an IPFS message. :param message: the message + :return: None """ self.context.logger.debug(f"Received message: {message}") - supported_performative = IpfsMessage.Performative.FILES - if message.performative != supported_performative: - self.context.logger.warning( - f"Only IPFS Message {supported_performative} performative is supported. Got {message.performative}." - ) - self.shared_state.in_flight_req = False - return + self.shared_state.in_flight_req = False + + if message.performative != self.custom_support_performative: + return super().handle(message) dialogue = self.context.ipfs_dialogues.update(message) nonce = dialogue.dialogue_label.dialogue_reference[0] callback = self.shared_state.req_to_callback.pop(nonce) callback(message, dialogue) - self.shared_state.in_flight_req = False From e0aee95b49a8372263ec40bcf4b7e60b080c9a94 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 5 Dec 2023 13:20:56 +0200 Subject: [PATCH 13/17] chore: run generators --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 6 +++--- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 785943014..f5cdcbf7f 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i", - "skill/valory/decision_maker_abci/0.1.0": "bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha", - "skill/valory/trader_abci/0.1.0": "bafybeicv3wxg4sdyj6yda32a5lcygicxy55baai2qvu2spwqcxdcfnri7i", + "skill/valory/decision_maker_abci/0.1.0": "bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu", + "skill/valory/trader_abci/0.1.0": "bafybeihb3u5asle3i43uffzs4johkxu2qnswiewjugzhxtlthmb4py6j4y", "contract/valory/market_maker/0.1.0": "bafybeid5jnetbsusgxkpqzwyiqlwut55xktfbeloipxcemcuu5oopmqtl4", - "agent/valory/trader/0.1.0": "bafybeiccvcjf4zavbrurltv6eyduvdt7dzlulvdx7zowdna7iww76czynm", - "service/valory/trader/0.1.0": "bafybeiflyaf3w5zywjt4kvph7paki7dusieyzykdd2z6p4tdmrvj44rgwa", + "agent/valory/trader/0.1.0": "bafybeidcovbb3efuufbeldvmhn3khpl57nq6srhwakxzj4h56duggyz3tm", + "service/valory/trader/0.1.0": "bafybeia6qr63f3favmxkqfcfyd5b5ydyom6o7qtiyrz4oq3yjar2b62znq", "contract/valory/erc20/0.1.0": "bafybeiepg5ymxhtylgijs3mf3lezz6cwcsougbrv2gr4xcq3bp5wxusi64", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki", "contract/valory/mech/0.1.0": "bafybeieo65rtidzgrx22la7z7azoqbisd35hnoqfw7l3xxctotvctjlkju", "contract/valory/realitio/0.1.0": "bafybeieoily22pasgkzzcyawhqyrsko7b52lghnvwuskhomavb7tlb6pxa", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index a0ca11eff..246b800fb 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -43,10 +43,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiencz2uytz6fqj5wg7mcunevxjh4xg5gd6pqcgkshgqywhcimweyi - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha -- valory/trader_abci:0.1.0:bafybeicv3wxg4sdyj6yda32a5lcygicxy55baai2qvu2spwqcxdcfnri7i +- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu +- valory/trader_abci:0.1.0:bafybeihb3u5asle3i43uffzs4johkxu2qnswiewjugzhxtlthmb4py6j4y - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 22fe27ae9..d9a3129f8 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeiccvcjf4zavbrurltv6eyduvdt7dzlulvdx7zowdna7iww76czynm +agent: valory/trader:0.1.0:bafybeidcovbb3efuufbeldvmhn3khpl57nq6srhwakxzj4h56duggyz3tm number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 8802cd70e..ee1a3ad69 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,7 +12,7 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeihe53zczkaubcjfrq3wrke2ebrsyewpvkweptltobtktv43pgctvu + behaviours/base.py: bafybeib7abyudoksbo5qq4bl5cjwnlejieisyr2dr4ikjbp2c3woivssxy behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa behaviours/blacklisting.py: bafybeierwdzn6vav54l6zym77hhx2vdx3jtnnwpbhwmwwyrqzncwjwkxu4 behaviours/decision_receive.py: bafybeia4me35pkspnytwb7lfo3hoxey7d6rolkn57ixwqeecmgtiliw27m @@ -24,8 +24,8 @@ fingerprint: behaviours/tool_selection.py: bafybeifpvrrbftlkjsoiysnasihzttousk6hxnukzrln6z2d33e3zexkje dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya - handlers.py: bafybeibrn7asqnilxzr7tamapg2ymuvxu4bapgqm6hegnqeqfzb7tgdrse - models.py: bafybeig5qavsmh6acdh4rhpv6qpbqaew7kiy6u2g3q5ks4pyqxxf6nm5sa + handlers.py: bafybeiggoetspwcvdojmbjdd67tmkoeedikmt6vsbcium3zjaljb6jzqu4 + models.py: bafybeidmqypeywbg2bn4yfv6ghgtqz7kknnnvcvkepgbsvfjxg3vrxtfte payloads.py: bafybeigcic4vewdglakzpyqevhfwsolh4ywnbvxo5bgned7gl5uo3jif7m policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 72ddc3a7f..01ada7106 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -25,8 +25,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigz4nhhofcb66npfzesuu4hncasiiqofbnljiwrqkxi6u3amnxh6y +- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 3ce43ca50..5eaaa4b31 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -21,7 +21,7 @@ protocols: - valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru skills: - valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e -- valory/decision_maker_abci:0.1.0:bafybeih5nr2ynxjs7aruc63xuhjzqefxsvvpkbn3urthc46bfiwjfyy6ha +- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: From 7c02e5dd5dc605cc8f459392e3e02bd5ee3ccc74 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 5 Dec 2023 16:48:05 +0200 Subject: [PATCH 14/17] feat: add a max bet parameter for the bankroll's adjustment --- packages/valory/agents/trader/aea-config.yaml | 2 +- strategies/kelly_criterion.py | 29 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 246b800fb..4396e55d4 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -192,7 +192,7 @@ models: agent_balance_threshold: ${int:10000000000000000} refill_check_interval: ${int:10} tool_punishment_multiplier: ${int:1} - file_hash_to_strategies_json: ${list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeid7xyoqfskjumerc7tj2ykmfprem63oyxj5hyy2ts2zckfq7zutte",["kelly_criterion"]]]} + file_hash_to_strategies_json: ${list:[["bafybeiauu6lecgrxlqlexaorsnpbzj6beto7kagdx6zawqx6z5fo5wmxhy",["bet_amount_per_threshold"]],["bafybeidbmi5zgp2ygprb3br6xpfvmty474cy3eeib5ynslispp4iijwpoe",["kelly_criterion"]]]} strategies_kwargs: ${list:[["bet_kelly_fraction",1.0],["floor_balance",500000000000000000],["bet_amount_per_threshold",{"0.0":0,"0.1":0,"0.2":0,"0.3":0,"0.4":0,"0.5":0,"0.6":0,"0.7":0,"0.8":0,"0.9":0,"1.0":0}]]} --- public_id: valory/p2p_libp2p_client:0.1.0 diff --git a/strategies/kelly_criterion.py b/strategies/kelly_criterion.py index 388f459f2..cbe4cc4f9 100644 --- a/strategies/kelly_criterion.py +++ b/strategies/kelly_criterion.py @@ -21,17 +21,22 @@ from typing import Dict, Any, List, Union -REQUIRED_FIELDS = ( - # the fraction of the calculated kelly bet amount to use for placing the bet - "bet_kelly_fraction", - "bankroll", - "win_probability", - "confidence", - "selected_type_tokens_in_pool", - "other_tokens_in_pool", - "bet_fee", - "floor_balance", +REQUIRED_FIELDS = frozenset( + { + # the fraction of the calculated kelly bet amount to use for placing the bet + "bet_kelly_fraction", + "bankroll", + "win_probability", + "confidence", + "selected_type_tokens_in_pool", + "other_tokens_in_pool", + "bet_fee", + "floor_balance", + } ) +OPTIONAL_FIELDS = frozenset({"max_bet"}) +ALL_FIELDS = REQUIRED_FIELDS.union(OPTIONAL_FIELDS) +DEFAULT_MAX_BET = 8e17 def check_missing_fields(kwargs: Dict[str, Any]) -> List[str]: @@ -45,7 +50,7 @@ def check_missing_fields(kwargs: Dict[str, Any]) -> List[str]: def remove_irrelevant_fields(kwargs: Dict[str, Any]) -> Dict[str, Any]: """Remove the irrelevant fields from the given kwargs.""" - return {key: value for key, value in kwargs.items() if key in REQUIRED_FIELDS} + return {key: value for key, value in kwargs.items() if key in ALL_FIELDS} def calculate_kelly_bet_amount( @@ -102,10 +107,12 @@ def get_bet_amount_kelly( # pylint: disable=too-many-arguments other_tokens_in_pool: int, bet_fee: int, floor_balance: int, + max_bet: int = DEFAULT_MAX_BET, ) -> Dict[str, Union[int, List[str]]]: """Calculate the Kelly bet amount.""" # keep `floor_balance` xDAI in the bankroll bankroll_adj = bankroll - floor_balance + bankroll_adj = min(bankroll_adj, max_bet) bankroll_adj_xdai = wei_to_native(bankroll_adj) info = [f"Adjusted bankroll: {bankroll_adj_xdai} xDAI."] error = [] From be4a72b99fcfe8da2ae59ee79fba5123264aa8c1 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Tue, 5 Dec 2023 18:42:11 +0200 Subject: [PATCH 15/17] chore: run generators --- packages/packages.json | 4 ++-- packages/valory/services/trader/service.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index f5cdcbf7f..0a6e0ec40 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -4,8 +4,8 @@ "skill/valory/decision_maker_abci/0.1.0": "bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu", "skill/valory/trader_abci/0.1.0": "bafybeihb3u5asle3i43uffzs4johkxu2qnswiewjugzhxtlthmb4py6j4y", "contract/valory/market_maker/0.1.0": "bafybeid5jnetbsusgxkpqzwyiqlwut55xktfbeloipxcemcuu5oopmqtl4", - "agent/valory/trader/0.1.0": "bafybeidcovbb3efuufbeldvmhn3khpl57nq6srhwakxzj4h56duggyz3tm", - "service/valory/trader/0.1.0": "bafybeia6qr63f3favmxkqfcfyd5b5ydyom6o7qtiyrz4oq3yjar2b62znq", + "agent/valory/trader/0.1.0": "bafybeiejzq4tqdsjzrinmmcvsahsdzztefc73wvobnrpggxslp3p3lg76u", + "service/valory/trader/0.1.0": "bafybeigmzt3cscoacgasxwb26qwppwdfp6uhumnk2cmyygmrrrprlymk2m", "contract/valory/erc20/0.1.0": "bafybeiepg5ymxhtylgijs3mf3lezz6cwcsougbrv2gr4xcq3bp5wxusi64", "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki", "contract/valory/mech/0.1.0": "bafybeieo65rtidzgrx22la7z7azoqbisd35hnoqfw7l3xxctotvctjlkju", diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index d9a3129f8..052d95608 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeidcovbb3efuufbeldvmhn3khpl57nq6srhwakxzj4h56duggyz3tm +agent: valory/trader:0.1.0:bafybeiejzq4tqdsjzrinmmcvsahsdzztefc73wvobnrpggxslp3p3lg76u number_of_agents: 4 deployment: {} --- From 7225bc3b79a1a6511e3c4124376fcebaa1a81555 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 6 Dec 2023 12:42:06 +0200 Subject: [PATCH 16/17] feat: implement test for `remove_fraction_wei` --- .../decision_maker_abci/tests/__init__.py | 25 +++++++ .../tests/behaviours/__init__.py | 20 ++++++ .../tests/behaviours/test_base.py | 68 +++++++++++++++++++ .../decision_maker_abci/tests/conftest.py | 34 ++++++++++ 4 files changed, 147 insertions(+) create mode 100644 packages/valory/skills/decision_maker_abci/tests/__init__.py create mode 100644 packages/valory/skills/decision_maker_abci/tests/behaviours/__init__.py create mode 100644 packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py create mode 100644 packages/valory/skills/decision_maker_abci/tests/conftest.py diff --git a/packages/valory/skills/decision_maker_abci/tests/__init__.py b/packages/valory/skills/decision_maker_abci/tests/__init__.py new file mode 100644 index 000000000..da96e5260 --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/tests/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""This module contains the tests for valory/decision_maker_abci.""" + +from aea.configurations.base import PublicId + + +PUBLIC_ID = PublicId.from_str("valory/decision_maker_abci:0.1.0") diff --git a/packages/valory/skills/decision_maker_abci/tests/behaviours/__init__.py b/packages/valory/skills/decision_maker_abci/tests/behaviours/__init__.py new file mode 100644 index 000000000..ce9c4fc94 --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/tests/behaviours/__init__.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""This module contains the tests for valory/decision_maker_abci's behaviours.""" diff --git a/packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py b/packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py new file mode 100644 index 000000000..2eb3f596a --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""This module contains the tests for valory/decision_maker_abci's base behaviour.""" + +import re +from typing import Tuple + +import pytest +from hypothesis import given, settings +from hypothesis import strategies as st +from hypothesis.strategies import composite + +from packages.valory.skills.decision_maker_abci.behaviours.base import ( + remove_fraction_wei, +) +from packages.valory.skills.decision_maker_abci.tests.conftest import profile_name + + +settings.load_profile(profile_name) +FRACTION_REMOVAL_PRECISION = 2 + + +@composite +def remove_fraction_args(draw: st.DrawFn) -> Tuple[int, float, int]: + """A strategy for building the values of the `test_remove_fraction_wei` with the desired constraints.""" + amount = draw(st.integers()) + fraction = draw(st.floats(min_value=0, max_value=1)) + keep_percentage = 1 - fraction + assert 0 <= keep_percentage <= 1 + expected = int(amount * keep_percentage) + return amount, fraction, expected + + +@given(remove_fraction_args()) +def test_remove_fraction_wei(strategy: Tuple[int, float, int]) -> None: + """Test the `remove_fraction_wei` function.""" + amount, fraction, expected = strategy + assert remove_fraction_wei(amount, fraction) == expected + + +@given( + amount=st.integers(), + fraction=st.floats().filter(lambda x: x < 0 or x > 1), +) +def test_remove_fraction_wei_incorrect_fraction(amount: int, fraction: float) -> None: + """Test the `remove_fraction_wei` function.""" + with pytest.raises( + ValueError, + match=re.escape(f"The given fraction {fraction!r} is not in the range [0, 1]."), + ): + remove_fraction_wei(amount, fraction) diff --git a/packages/valory/skills/decision_maker_abci/tests/conftest.py b/packages/valory/skills/decision_maker_abci/tests/conftest.py new file mode 100644 index 000000000..d690940ab --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/tests/conftest.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2023 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""Conftest module for decision maker tests.""" + +import os +from pathlib import Path + +from hypothesis import settings + + +# pylint: skip-file + + +CI = "CI" +PACKAGE_DIR = Path(__file__).parent.parent +settings.register_profile(CI, deadline=5000) +profile_name = ("default", "CI")[bool(os.getenv("CI"))] From 3f07634ead0498a13f526a2ee9473c64e6d4a3bf Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 6 Dec 2023 12:44:45 +0200 Subject: [PATCH 17/17] chore: run generators --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 4 ++++ packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 0a6e0ec40..606e97129 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i", - "skill/valory/decision_maker_abci/0.1.0": "bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu", - "skill/valory/trader_abci/0.1.0": "bafybeihb3u5asle3i43uffzs4johkxu2qnswiewjugzhxtlthmb4py6j4y", + "skill/valory/decision_maker_abci/0.1.0": "bafybeiftg2nzs3lelkxka7wxc2f6zzmzq6sxq5ng5ix5zkkdkqutapx3ku", + "skill/valory/trader_abci/0.1.0": "bafybeidrqtnn3idmczc467m3ogttnce7e4iao46yccnkoenjctce6jib6e", "contract/valory/market_maker/0.1.0": "bafybeid5jnetbsusgxkpqzwyiqlwut55xktfbeloipxcemcuu5oopmqtl4", - "agent/valory/trader/0.1.0": "bafybeiejzq4tqdsjzrinmmcvsahsdzztefc73wvobnrpggxslp3p3lg76u", - "service/valory/trader/0.1.0": "bafybeigmzt3cscoacgasxwb26qwppwdfp6uhumnk2cmyygmrrrprlymk2m", + "agent/valory/trader/0.1.0": "bafybeihrk63u6imk3pywsj3wnxrljabtouid4mh724gr5ahaasip7bokti", + "service/valory/trader/0.1.0": "bafybeihae3y7cqjrkqma3jph4cy4rk2cmcnj53xyvxbaj3qlycz4upbv2u", "contract/valory/erc20/0.1.0": "bafybeiepg5ymxhtylgijs3mf3lezz6cwcsougbrv2gr4xcq3bp5wxusi64", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeigesnu3d4slpj7gpsn7kbjsafk7xnwoplef7fvsuxg245wphkn66a", "contract/valory/mech/0.1.0": "bafybeieo65rtidzgrx22la7z7azoqbisd35hnoqfw7l3xxctotvctjlkju", "contract/valory/realitio/0.1.0": "bafybeieoily22pasgkzzcyawhqyrsko7b52lghnvwuskhomavb7tlb6pxa", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 4396e55d4..71c26cedf 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -43,10 +43,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiencz2uytz6fqj5wg7mcunevxjh4xg5gd6pqcgkshgqywhcimweyi - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigesnu3d4slpj7gpsn7kbjsafk7xnwoplef7fvsuxg245wphkn66a - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu -- valory/trader_abci:0.1.0:bafybeihb3u5asle3i43uffzs4johkxu2qnswiewjugzhxtlthmb4py6j4y +- valory/decision_maker_abci:0.1.0:bafybeiftg2nzs3lelkxka7wxc2f6zzmzq6sxq5ng5ix5zkkdkqutapx3ku +- valory/trader_abci:0.1.0:bafybeidrqtnn3idmczc467m3ogttnce7e4iao46yccnkoenjctce6jib6e - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 052d95608..5c809664f 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeiejzq4tqdsjzrinmmcvsahsdzztefc73wvobnrpggxslp3p3lg76u +agent: valory/trader:0.1.0:bafybeihrk63u6imk3pywsj3wnxrljabtouid4mh724gr5ahaasip7bokti number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index ee1a3ad69..2c395f5af 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -41,6 +41,10 @@ fingerprint: states/redeem.py: bafybeie63laufsdxhf4vngmon5lne7cpmvvosqervp6l2riysqnwuotzim states/sampling.py: bafybeidnvdogjlthjfe7jpaiuezm3xydrbxxukyoss4gx6t5fdin52rsta states/tool_selection.py: bafybeiaaijv6dukp3bmsptcwkcmumc6wu6ztzkvaqzsqqjbfn4ozgyuykq + tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i + tests/behaviours/__init__.py: bafybeic7icz7lfhfepdkqkase7y7zn3a6pwdw6fx4ah2hajmgejawpolc4 + tests/behaviours/test_base.py: bafybeidemmwjhtr6i4tq66jyqkpmb425ersfmk7k7zzjmeaz2idqnpcwve + tests/conftest.py: bafybeidy5hw56kw5mxudnfbhvogofn6k4rqb4ux2bd45baedrrhmgyrude fingerprint_ignore_patterns: [] connections: [] contracts: diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 01ada7106..77791685c 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -25,8 +25,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeigk3debp6dswutqsuls2lqfvyj4ghe6kwjc2zfinnsvj6hujynxtq - valory/termination_abci:0.1.0:bafybeigainmpy37gb33ogbrpggjbkuasodhthh5oz4vbzjdfjozerpf224 - valory/market_manager_abci:0.1.0:bafybeic7o4pclkhnugyn7js5g3asxuqhkxpvunlp3mpup7aovhg2fto22i -- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeifgq5zgxcwzdlwixu5lfe34a4m4ddqqv7xzxhir47yn7tavg3fdki +- valory/decision_maker_abci:0.1.0:bafybeiftg2nzs3lelkxka7wxc2f6zzmzq6sxq5ng5ix5zkkdkqutapx3ku +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeigesnu3d4slpj7gpsn7kbjsafk7xnwoplef7fvsuxg245wphkn66a - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 5eaaa4b31..ba10dcca4 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -21,7 +21,7 @@ protocols: - valory/ledger_api:1.0.0:bafybeige5agrztgzfevyglf7mb4o7pzfttmq4f6zi765y4g2zvftbyowru skills: - valory/abstract_round_abci:0.1.0:bafybeidau7loztcfy3mxvoqrv7otbpciemd2wf3lsxyjraq4dcvuvib25e -- valory/decision_maker_abci:0.1.0:bafybeibqncxj2gijdrglaeg5f3sjpsde4hw3vlltfz3lrxidt4lcu5lrxu +- valory/decision_maker_abci:0.1.0:bafybeiftg2nzs3lelkxka7wxc2f6zzmzq6sxq5ng5ix5zkkdkqutapx3ku - valory/staking_abci:0.1.0:bafybeia3acxumkjg566dvgagv3swz7htf5xpvwq6ovmecvp5j2zdxdoabe behaviours: main: