From 7e221be0d151fe1d4b7cfa085d877bb488133692 Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sat, 18 Nov 2023 11:05:07 +0000 Subject: [PATCH 1/7] fix: towards a fix of kelly indeterminacy --- .../decision_maker_abci/behaviours/base.py | 94 +++++++++++-------- .../skills/decision_maker_abci/skill.yaml | 2 + .../decision_maker_abci/tests/__init__.py | 25 +++++ .../decision_maker_abci/tests/conftest.py | 34 +++++++ .../tests/test_behaviours.py | 43 +++++++++ 5 files changed, 157 insertions(+), 41 deletions(-) create mode 100644 packages/valory/skills/decision_maker_abci/tests/__init__.py create mode 100644 packages/valory/skills/decision_maker_abci/tests/conftest.py create mode 100644 packages/valory/skills/decision_maker_abci/tests/test_behaviours.py diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index 9a4e5d5d0..ed4b7355e 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -20,6 +20,7 @@ """This module contains the base behaviour for the 'decision_maker_abci' skill.""" import dataclasses +import random from abc import ABC from datetime import datetime, timedelta from typing import Any, Callable, Generator, List, Optional, cast @@ -61,7 +62,7 @@ SAFE_GAS = 0 CID_PREFIX = "f01701220" WXDAI = "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" -EPSILON = 1e-7 +EPSILON = 1e-5 def remove_fraction_wei(amount: int, fraction: float) -> int: @@ -72,6 +73,53 @@ def remove_fraction_wei(amount: int, fraction: float) -> int: raise ValueError(f"The given fraction {fraction!r} is not in the range [0, 1].") +def perturb_y_if_x_equals_y(x: int, y: int, epsilon: float = EPSILON) -> float: + """Introduce perturbation to the y value if x equals y.""" + y += epsilon if random.choice([True, False]) else -epsilon + return y + + +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 + if x == y: + # o/w kelly traders will never be the first to bet in a new market + y = perturb_y_if_x_equals_y(x, y) + kelly_bet_amount = ( + -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) + ) / (2 * (x**2 * f - y**2 * f)) + return int(kelly_bet_amount) + + class DecisionMakerBaseBehaviour(BaseBehaviour, ABC): """Represents the base class for the decision-making FSM behaviour.""" @@ -216,45 +264,6 @@ def check_balance(self) -> WaitableConditionType: self.context.logger.info(f"The safe has {native} xDAI and {collateral}.") return True - def _calculate_kelly_bet_amount( - self, x: int, y: int, p: float, c: float, b: int, f: float - ) -> int: - """Calculate the Kelly bet amount.""" - if b == 0: - error = "Cannot calculate Kelly bet amount with no bankroll." - self.context.logger.error(error) - return 0 - kelly_bet_amount = ( - -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) - ) / (2 * (x**2 * f - y**2 * f) + EPSILON) - return int(kelly_bet_amount) - def get_max_bet_amount(self, a: int, x: int, y: int, f: float) -> int: """Get max bet amount based on available shares.""" if x**2 * f**2 + 2 * x * y * f**2 + y**2 * f**2 == 0: @@ -323,7 +332,10 @@ def get_bet_amount( fee_fraction = 1 - self.wei_to_native(bet_fee) self.context.logger.info(f"Fee fraction: {fee_fraction}") - kelly_bet_amount = self._calculate_kelly_bet_amount( + if bankroll_adj == 0: + error = "Cannot calculate Kelly bet amount with no bankroll." + self.context.logger.error(error) + kelly_bet_amount = calculate_kelly_bet_amount( selected_type_tokens_in_pool, other_tokens_in_pool, win_probability, diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 4009e5b08..d6dbbef65 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -243,6 +243,8 @@ models: dependencies: hexbytes: version: ==0.3.1 + hypothesis: + version: ==6.21.6 py-multibase: version: ==1.0.3 py-multicodec: 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/conftest.py b/packages/valory/skills/decision_maker_abci/tests/conftest.py new file mode 100644 index 000000000..432304d24 --- /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 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 new file mode 100644 index 000000000..ea80af67f --- /dev/null +++ b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py @@ -0,0 +1,43 @@ +# -*- 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 packages.valory.skills.decision_maker_abci.tests.conftest import profile_name +from packages.valory.skills.decision_maker_abci.behaviours.base import calculate_kelly_bet_amount + +from hypothesis import given, settings +from hypothesis import strategies as st + + +settings.load_profile(profile_name) + + +@given( + x=st.integers(min_value=0, max_value=100000), + y=st.integers(min_value=0, max_value=100000), + p=st.floats(min_value=0.0, max_value=1.0), + c=st.floats(min_value=0.0, max_value=1.0), + b=st.floats(min_value=0.5, max_value=2.0), + f=st.floats(min_value=0.0, max_value=1.0), +) +def test_calculate_kelly_bet_amount( + x: int, y: int, p: float, c: float, b: int, f: float + ): + assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= 0 \ No newline at end of file From c8141cc3b6d29ac4cfc070d956ddb797d8f8000c Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sat, 18 Nov 2023 11:37:27 +0000 Subject: [PATCH 2/7] chore: make test pass --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/behaviours/base.py | 10 ++++++---- .../valory/skills/decision_maker_abci/skill.yaml | 5 ++++- .../decision_maker_abci/tests/test_behaviours.py | 12 ++++++------ packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 82c028cac..e5d09f3e5 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeihuuqnr7egnlak5p23hu6aglo3ih6om2ih42btezylzebayrjah4m", - "skill/valory/trader_abci/0.1.0": "bafybeig2ynpufv4jmw4rhii5k4j7gpoesupoufnr6nzgnljeiyxp3vv6lq", + "skill/valory/decision_maker_abci/0.1.0": "bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui", + "skill/valory/trader_abci/0.1.0": "bafybeiepvc33hfknuld5pxmgam2si7wxidm23tqfayhox5jyjeebqduloq", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeifgxbaukxagyzfgzg7me2sdr6w73oe2fjofwpzclogzexsft2alxe", - "service/valory/trader/0.1.0": "bafybeifirhjukt7h5ndrbq2kufowmponinvm5q6eos3t6qgzn6mgi4s6ea", + "agent/valory/trader/0.1.0": "bafybeiajdjarpa2h65ldevsbkqgbqbxaisiybtv5lvazi463iirmdfh7ry", + "service/valory/trader/0.1.0": "bafybeieqojkojz4ak5sbvyosx26wn2opbzu3svnyxx6yg2krtcrjrvnkqm", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeic56a3mpezdy7ri4onwvoifj725wjep3n5kiqoxa32eel4b7qt6mm", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 0b2df8d8a..3487208c9 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeic56a3mpezdy7ri4onwvoifj725wjep3n5kiqoxa32eel4b7qt6mm +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeihuuqnr7egnlak5p23hu6aglo3ih6om2ih42btezylzebayrjah4m -- valory/trader_abci:0.1.0:bafybeig2ynpufv4jmw4rhii5k4j7gpoesupoufnr6nzgnljeiyxp3vv6lq +- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui +- valory/trader_abci:0.1.0:bafybeiepvc33hfknuld5pxmgam2si7wxidm23tqfayhox5jyjeebqduloq - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index bb7710b33..d2ef9c369 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:bafybeifgxbaukxagyzfgzg7me2sdr6w73oe2fjofwpzclogzexsft2alxe +agent: valory/trader:0.1.0:bafybeiajdjarpa2h65ldevsbkqgbqbxaisiybtv5lvazi463iirmdfh7ry number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index ed4b7355e..a0c0bbf06 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -62,7 +62,6 @@ SAFE_GAS = 0 CID_PREFIX = "f01701220" WXDAI = "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" -EPSILON = 1e-5 def remove_fraction_wei(amount: int, fraction: float) -> int: @@ -73,8 +72,9 @@ def remove_fraction_wei(amount: int, fraction: float) -> int: raise ValueError(f"The given fraction {fraction!r} is not in the range [0, 1].") -def perturb_y_if_x_equals_y(x: int, y: int, epsilon: float = EPSILON) -> float: +def perturb_y_if_x_equals_y(x: int, y: int) -> float: """Introduce perturbation to the y value if x equals y.""" + epsilon = (x + y) / 10000 y += epsilon if random.choice([True, False]) else -epsilon return y @@ -88,7 +88,7 @@ def calculate_kelly_bet_amount( if x == y: # o/w kelly traders will never be the first to bet in a new market y = perturb_y_if_x_equals_y(x, y) - kelly_bet_amount = ( + numerator = ( -4 * x**2 * y + b * y**2 * p * c * f + 2 * b * x * y * p * c * f @@ -116,7 +116,9 @@ def calculate_kelly_bet_amount( ) ) ** (1 / 2) - ) / (2 * (x**2 * f - y**2 * f)) + ) + denominator = (2 * (x**2 * f - y**2 * f)) + kelly_bet_amount = numerator / denominator return int(kelly_bet_amount) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index d6dbbef65..99b03a229 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: bafybeicu45h2jj6u462shnb3e7nrp7aynt6ezgpbznpyyjrkjtkkxnht3u + behaviours/base.py: bafybeibo47y2ihdrkg4wyyullrb2gwde3bqnf44pe3cepsxgskqvzxgyfe behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa behaviours/blacklisting.py: bafybeicl6b4hcmqmekta2mcuhkkydnzk7jmic6k44e6ns3u2ibad3awzvu behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m @@ -41,6 +41,9 @@ fingerprint: states/redeem.py: bafybeib2y6v3vuvw3upjz75ie7j2bkhclwzp7j77esunabjatdtmdvzqlm states/sampling.py: bafybeidnvdogjlthjfe7jpaiuezm3xydrbxxukyoss4gx6t5fdin52rsta states/tool_selection.py: bafybeiaaijv6dukp3bmsptcwkcmumc6wu6ztzkvaqzsqqjbfn4ozgyuykq + tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i + tests/conftest.py: bafybeic2xlujtbkyqk2zzpo5vorefwa3nwgfwmrk5rx77vu4gfyrn3pv5m + tests/test_behaviours.py: bafybeibmnf2w4s27fjk6qdjbnmci3xeoh7xwaxlhmffed4mtf42minsqky fingerprint_ignore_patterns: [] connections: [] contracts: diff --git a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py index ea80af67f..cdddd636a 100644 --- a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py +++ b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py @@ -30,14 +30,14 @@ @given( - x=st.integers(min_value=0, max_value=100000), - y=st.integers(min_value=0, max_value=100000), - p=st.floats(min_value=0.0, max_value=1.0), - c=st.floats(min_value=0.0, max_value=1.0), + 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.0, max_value=1.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 ): - assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= 0 \ No newline at end of file + assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= -10 \ No newline at end of file diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 4276c5c69..d5e4ee738 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeihuuqnr7egnlak5p23hu6aglo3ih6om2ih42btezylzebayrjah4m -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeic56a3mpezdy7ri4onwvoifj725wjep3n5kiqoxa32eel4b7qt6mm +- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 af5a4a1bf..10c2d2a71 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeihuuqnr7egnlak5p23hu6aglo3ih6om2ih42btezylzebayrjah4m +- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: From e109827e21208d520801fc40d89a94510402ff10 Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sat, 18 Nov 2023 21:36:44 +0000 Subject: [PATCH 3/7] chore: fix security linter --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/behaviours/base.py | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index e5d09f3e5..f5661d0d0 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui", - "skill/valory/trader_abci/0.1.0": "bafybeiepvc33hfknuld5pxmgam2si7wxidm23tqfayhox5jyjeebqduloq", + "skill/valory/decision_maker_abci/0.1.0": "bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu", + "skill/valory/trader_abci/0.1.0": "bafybeiawfnk2t3t2vc2rxuwywdpwnixwcl35xpwibvnc6uj2kkrm3fiosu", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeiajdjarpa2h65ldevsbkqgbqbxaisiybtv5lvazi463iirmdfh7ry", - "service/valory/trader/0.1.0": "bafybeieqojkojz4ak5sbvyosx26wn2opbzu3svnyxx6yg2krtcrjrvnkqm", + "agent/valory/trader/0.1.0": "bafybeif767jocewxohmknjf2fhqnryds327r74stjg5ykqw3jtolibifoi", + "service/valory/trader/0.1.0": "bafybeic44fdusoljstyptuopnpbqzptyebuvdojze77gj7q6nsqpb4pihy", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 3487208c9..545aa7e4c 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui -- valory/trader_abci:0.1.0:bafybeiepvc33hfknuld5pxmgam2si7wxidm23tqfayhox5jyjeebqduloq +- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu +- valory/trader_abci:0.1.0:bafybeiawfnk2t3t2vc2rxuwywdpwnixwcl35xpwibvnc6uj2kkrm3fiosu - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index d2ef9c369..5ec554592 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:bafybeiajdjarpa2h65ldevsbkqgbqbxaisiybtv5lvazi463iirmdfh7ry +agent: valory/trader:0.1.0:bafybeif767jocewxohmknjf2fhqnryds327r74stjg5ykqw3jtolibifoi number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index a0c0bbf06..62cfc48df 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -75,7 +75,7 @@ def remove_fraction_wei(amount: int, fraction: float) -> int: def perturb_y_if_x_equals_y(x: int, y: int) -> float: """Introduce perturbation to the y value if x equals y.""" epsilon = (x + y) / 10000 - y += epsilon if random.choice([True, False]) else -epsilon + y += epsilon if random.choice([True, False]) else -epsilon # nosec return y diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 99b03a229..7d377627c 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: bafybeibo47y2ihdrkg4wyyullrb2gwde3bqnf44pe3cepsxgskqvzxgyfe + behaviours/base.py: bafybeigjneci2qmj5odhey3vuwc6g5stes4aqoly2ks3owrxe2a2rcco7e behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa behaviours/blacklisting.py: bafybeicl6b4hcmqmekta2mcuhkkydnzk7jmic6k44e6ns3u2ibad3awzvu behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index d5e4ee738..3dda9fcbe 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiexztx5sdnxp3ddxntfzpcsu4y27pnk6w25nf7b2sdiq2pveyq4uy +- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 10c2d2a71..db618a654 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeiczir7k6kbz3qsxjmptr2tanndvqt7ulduy2nblzvdu6ho6ks3rui +- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: From 130388713ae59acfa26aef755e4a2b9ba4b5c718 Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sat, 18 Nov 2023 22:38:41 +0000 Subject: [PATCH 4/7] chore: refactor and clean --- packages/packages.json | 10 ++++---- packages/valory/agents/trader/aea-config.yaml | 6 ++--- packages/valory/services/trader/service.yaml | 2 +- .../decision_maker_abci/behaviours/base.py | 23 ++++++------------- .../skills/decision_maker_abci/models.py | 11 ++++++++- .../skills/decision_maker_abci/skill.yaml | 6 ++--- .../tests/test_behaviours.py | 13 +++++++---- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../tx_settlement_multiplexer_abci/skill.yaml | 2 +- 9 files changed, 40 insertions(+), 37 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index f5661d0d0..1ed1f796e 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu", - "skill/valory/trader_abci/0.1.0": "bafybeiawfnk2t3t2vc2rxuwywdpwnixwcl35xpwibvnc6uj2kkrm3fiosu", + "skill/valory/decision_maker_abci/0.1.0": "bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4", + "skill/valory/trader_abci/0.1.0": "bafybeialxshboebcgs5ucgi5upu6y4vrkgnbbx3oyaynwgjk74vmpcyqnu", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeif767jocewxohmknjf2fhqnryds327r74stjg5ykqw3jtolibifoi", - "service/valory/trader/0.1.0": "bafybeic44fdusoljstyptuopnpbqzptyebuvdojze77gj7q6nsqpb4pihy", + "agent/valory/trader/0.1.0": "bafybeihnjel5x4rs6fptwz5g2d5prwanuwvb4ntlxtsunsgg64rkuc6u3u", + "service/valory/trader/0.1.0": "bafybeid3jvs6dkkln3t7xfngn6zguqs6whsx5jodqkqtic7zbg2guadfp4", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 545aa7e4c..9fdf42264 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu -- valory/trader_abci:0.1.0:bafybeiawfnk2t3t2vc2rxuwywdpwnixwcl35xpwibvnc6uj2kkrm3fiosu +- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 +- valory/trader_abci:0.1.0:bafybeialxshboebcgs5ucgi5upu6y4vrkgnbbx3oyaynwgjk74vmpcyqnu - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 5ec554592..0fcc55407 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:bafybeif767jocewxohmknjf2fhqnryds327r74stjg5ykqw3jtolibifoi +agent: valory/trader:0.1.0:bafybeihnjel5x4rs6fptwz5g2d5prwanuwvb4ntlxtsunsgg64rkuc6u3u number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index 62cfc48df..4077f5fbb 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -20,7 +20,6 @@ """This module contains the base behaviour for the 'decision_maker_abci' skill.""" import dataclasses -import random from abc import ABC from datetime import datetime, timedelta from typing import Any, Callable, Generator, List, Optional, cast @@ -43,6 +42,7 @@ 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 @@ -72,22 +72,12 @@ def remove_fraction_wei(amount: int, fraction: float) -> int: raise ValueError(f"The given fraction {fraction!r} is not in the range [0, 1].") -def perturb_y_if_x_equals_y(x: int, y: int) -> float: - """Introduce perturbation to the y value if x equals y.""" - epsilon = (x + y) / 10000 - y += epsilon if random.choice([True, False]) else -epsilon # nosec - return y - - 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 - if x == y: - # o/w kelly traders will never be the first to bet in a new market - y = perturb_y_if_x_equals_y(x, y) numerator = ( -4 * x**2 * y + b * y**2 * p * c * f @@ -117,7 +107,7 @@ def calculate_kelly_bet_amount( ) ** (1 / 2) ) - denominator = (2 * (x**2 * f - y**2 * f)) + denominator = 2 * (x**2 * f - y**2 * f) kelly_bet_amount = numerator / denominator return int(kelly_bet_amount) @@ -304,7 +294,11 @@ def get_bet_amount( ) -> Generator[None, None, int]: """Get the bet amount given a specified trading strategy.""" - if strategy == "bet_amount_per_conf_threshold": + # 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" ) @@ -312,9 +306,6 @@ def get_bet_amount( bet_amount = self.params.bet_amount_per_threshold[threshold] return bet_amount - if strategy != "kelly_criterion": - raise ValueError(f"Invalid trading strategy: {strategy}") - self.context.logger.info("Used trading strategy: Kelly Criterion") # bankroll: the max amount of DAI available to trade yield from self.wait_for_condition_with_sleep(self.check_balance) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 82bd646f2..28aa9c7ec 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -58,6 +58,8 @@ DEFAULT_FROM_BLOCK = "earliest" ZERO_HEX = HASH_ZERO[2:] ZERO_BYTES = bytes.fromhex(ZERO_HEX) +STRATEGY_BET_AMOUNT_PER_CONF_THRESHOLD = "bet_amount_per_conf_threshold" +STRATEGY_KELLY_CRITERION = "kelly_criterion" class PromptTemplate(Template): @@ -178,6 +180,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: # the trading strategy to use for placing bets self.trading_strategy: str = self._ensure("trading_strategy", kwargs, str) + if self.trading_strategy not in [ + STRATEGY_BET_AMOUNT_PER_CONF_THRESHOLD, + STRATEGY_KELLY_CRITERION, + ]: + 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 @@ -235,7 +244,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: @property def using_kelly(self) -> bool: """Get the max bet amount if the `bet_amount_per_conf_threshold` strategy is used.""" - return self.trading_strategy == "kelly_criterion" + return self.trading_strategy == STRATEGY_KELLY_CRITERION @property def max_bet_amount(self) -> int: diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 7d377627c..5b28c6862 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: bafybeigjneci2qmj5odhey3vuwc6g5stes4aqoly2ks3owrxe2a2rcco7e + behaviours/base.py: bafybeifwz5zbbaia4q4oll6cldtvt47w2hw2qadptkmmtovmitzgpizyki behaviours/bet_placement.py: bafybeigtz4uimsqjjwq4r5p3a5v6niqdtqezbuf2ghy6o7syhsh4k5gjfa behaviours/blacklisting.py: bafybeicl6b4hcmqmekta2mcuhkkydnzk7jmic6k44e6ns3u2ibad3awzvu behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m @@ -25,7 +25,7 @@ fingerprint: dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeifskab7b3nqalkenjgk745ky4h7bsqar73zzvrnygymhjl4qxl2ga + models.py: bafybeifvohs24ddh5lujdx6rgmulzoovs3dmmsza3vieugstq3idv2iday payloads.py: bafybeifhq6stu4vp2ef4qvihxgpos3yc2zcuaja2safwt7efdidoejgvqa policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm @@ -43,7 +43,7 @@ fingerprint: states/tool_selection.py: bafybeiaaijv6dukp3bmsptcwkcmumc6wu6ztzkvaqzsqqjbfn4ozgyuykq tests/__init__.py: bafybeiakpi3k3kc7wrjj7hrluvjcj36lu2gezpmrctwiz5yg2fe7ggnf3i tests/conftest.py: bafybeic2xlujtbkyqk2zzpo5vorefwa3nwgfwmrk5rx77vu4gfyrn3pv5m - tests/test_behaviours.py: bafybeibmnf2w4s27fjk6qdjbnmci3xeoh7xwaxlhmffed4mtf42minsqky + tests/test_behaviours.py: bafybeigfrzuqlxok7zmkyjd4t2p6wovmenx7n3zo7xu5jprv46jkzp2kqa fingerprint_ignore_patterns: [] connections: [] contracts: diff --git a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py index cdddd636a..60e633f30 100644 --- a/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py +++ b/packages/valory/skills/decision_maker_abci/tests/test_behaviours.py @@ -19,12 +19,14 @@ """This module contains the tests for valory/decision_maker_abci's behaviours.""" -from packages.valory.skills.decision_maker_abci.tests.conftest import profile_name -from packages.valory.skills.decision_maker_abci.behaviours.base import calculate_kelly_bet_amount - from hypothesis import given, settings from hypothesis import strategies as st +from packages.valory.skills.decision_maker_abci.behaviours.base import ( + calculate_kelly_bet_amount, +) +from packages.valory.skills.decision_maker_abci.tests.conftest import profile_name + settings.load_profile(profile_name) @@ -39,5 +41,6 @@ ) def test_calculate_kelly_bet_amount( x: int, y: int, p: float, c: float, b: int, f: float - ): - assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= -10 \ No newline at end of file +) -> None: + """Test the calculate_kelly_bet_amount function.""" + assert calculate_kelly_bet_amount(x, y, p, c, b, f) >= -10 diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 3dda9fcbe..59c860e40 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeieg23bd2fj5xaelys5uz2iggdx7zdxv2vnzfgfw7ndipw5b4so3xe +- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 db618a654..63c19d628 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeihgb4hxrlfviop5keq37wt6a4se4crxgldzkyyagvtfunurlrj7vu +- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: From c7b246858c3bf7145ace87597e8c9fb18a7d8894 Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sat, 18 Nov 2023 22:52:28 +0000 Subject: [PATCH 5/7] fix: add missing local var --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/behaviours/reedem.py | 1 + packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 7 files changed, 14 insertions(+), 13 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 1ed1f796e..7e7cffdf0 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4", - "skill/valory/trader_abci/0.1.0": "bafybeialxshboebcgs5ucgi5upu6y4vrkgnbbx3oyaynwgjk74vmpcyqnu", + "skill/valory/decision_maker_abci/0.1.0": "bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u", + "skill/valory/trader_abci/0.1.0": "bafybeidq7hthnfgcq7q5lp6k72d44uv2f7uice53nok42oxtugl6ngqfdq", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeihnjel5x4rs6fptwz5g2d5prwanuwvb4ntlxtsunsgg64rkuc6u3u", - "service/valory/trader/0.1.0": "bafybeid3jvs6dkkln3t7xfngn6zguqs6whsx5jodqkqtic7zbg2guadfp4", + "agent/valory/trader/0.1.0": "bafybeies2mnlm6vvm6wte37ocskc2vka33znf2ty6x2lszepnk5udnh6t4", + "service/valory/trader/0.1.0": "bafybeifiznfvhb7bzsctafypiu2xgvf5c5yr3aqpcs7s5cqxsahpntultm", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 9fdf42264..7cac03054 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 -- valory/trader_abci:0.1.0:bafybeialxshboebcgs5ucgi5upu6y4vrkgnbbx3oyaynwgjk74vmpcyqnu +- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u +- valory/trader_abci:0.1.0:bafybeidq7hthnfgcq7q5lp6k72d44uv2f7uice53nok42oxtugl6ngqfdq - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 0fcc55407..b6a1fa3ca 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:bafybeihnjel5x4rs6fptwz5g2d5prwanuwvb4ntlxtsunsgg64rkuc6u3u +agent: valory/trader:0.1.0:bafybeies2mnlm6vvm6wte37ocskc2vka33znf2ty6x2lszepnk5udnh6t4 number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index c6572fcd1..63a5894e6 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -769,6 +769,7 @@ def async_act(self) -> Generator: self.context.logger.info(msg) self._load_progress() + success = False if not self.redeeming_progress.check_finished: success = yield from self._clean_redeem_info() diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 5b28c6862..0eead2a81 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -18,7 +18,7 @@ fingerprint: behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m behaviours/decision_request.py: bafybeievr7vae43e7jr4eqqhwe3emvgiih7ysa66jcb5g2oz5lbxua232q behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeifgsgp655ml4om4ko3j24hqzwjdqcnobiege4lpy5roen5omxtnby + behaviours/reedem.py: bafybeifps3zaqa5m2qqa6lwyo6muy4fnpc65z7nebunavvh43l6oghjyzu behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeifzhm4sspdvt227ksl5hjn26offgqpwempgbcwbr6dq7gyi2a46sm behaviours/tool_selection.py: bafybeigfr2frkljrxyfxs5p3j42equzehgaqtkyuxk6eiujyudr6ajqakm diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 59c860e40..1578a1ebc 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiagiyzwolc3hc5gt3wuzvgfqdh25e5wi4jbouq2rsb67twgopucnm +- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 63c19d628..b88e70391 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeiczcpdknyev4mzp72un4lre6tmddpbagju7ecwbmtsbjemmr5d2x4 +- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: From 72f556c1b3f618ef73cdd25ba22b0f090908d6b0 Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sun, 19 Nov 2023 10:27:48 +0000 Subject: [PATCH 6/7] fix: properly handle batch size reduction --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/behaviours/reedem.py | 10 ++++------ packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 7 files changed, 17 insertions(+), 19 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 7e7cffdf0..a90ce116e 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u", - "skill/valory/trader_abci/0.1.0": "bafybeidq7hthnfgcq7q5lp6k72d44uv2f7uice53nok42oxtugl6ngqfdq", + "skill/valory/decision_maker_abci/0.1.0": "bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu", + "skill/valory/trader_abci/0.1.0": "bafybeibpoqlzlvssrqezu4ljw5lahi2np6fr5pupzrmqjd6kypbdr6r4s4", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeies2mnlm6vvm6wte37ocskc2vka33znf2ty6x2lszepnk5udnh6t4", - "service/valory/trader/0.1.0": "bafybeifiznfvhb7bzsctafypiu2xgvf5c5yr3aqpcs7s5cqxsahpntultm", + "agent/valory/trader/0.1.0": "bafybeidvjnydkachtrkc26sjyorp4w2aujhn4mabfmat64dih5rwef4vrq", + "service/valory/trader/0.1.0": "bafybeiap4lmidxj4l3cxuj4w27k5teiyhn5pnnftf5lwsksqecrzcyzg24", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 7cac03054..4b06f1695 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u -- valory/trader_abci:0.1.0:bafybeidq7hthnfgcq7q5lp6k72d44uv2f7uice53nok42oxtugl6ngqfdq +- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu +- valory/trader_abci:0.1.0:bafybeibpoqlzlvssrqezu4ljw5lahi2np6fr5pupzrmqjd6kypbdr6r4s4 - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index b6a1fa3ca..1755b676b 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:bafybeies2mnlm6vvm6wte37ocskc2vka33znf2ty6x2lszepnk5udnh6t4 +agent: valory/trader:0.1.0:bafybeidvjnydkachtrkc26sjyorp4w2aujhn4mabfmat64dih5rwef4vrq number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index 63a5894e6..bd7add103 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -435,10 +435,9 @@ def _check_already_redeemed(self) -> WaitableConditionType: if not result: n_retries += 1 keep_fraction = (1 - self.params.reduce_factor) ** n_retries - step = int(batch_size * keep_fraction) - msg = f"Repeating this call with a decreased batch size of {step}." + batch_size = int(self.params.event_filtering_batch_size * keep_fraction) + msg = f"Repeating this call with a decreased batch size of {batch_size}." self.context.logger.warning(msg) - from_block += step continue self.redeeming_progress.payouts.update(self.payouts_batch) @@ -568,10 +567,9 @@ def get_claim_params(self) -> WaitableConditionType: if not result: n_retries += 1 keep_fraction = (1 - self.params.reduce_factor) ** n_retries - step = int(batch_size * keep_fraction) - msg = f"Repeating this call with a decreased batch size of {step}." + batch_size = int(self.params.event_filtering_batch_size * keep_fraction) + msg = f"Repeating this call with a decreased batch size of {batch_size}." self.context.logger.warning(msg) - from_block += step continue self.redeeming_progress.answered.extend(self.claim_params_batch) diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 0eead2a81..e45a18cc7 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -18,7 +18,7 @@ fingerprint: behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m behaviours/decision_request.py: bafybeievr7vae43e7jr4eqqhwe3emvgiih7ysa66jcb5g2oz5lbxua232q behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeifps3zaqa5m2qqa6lwyo6muy4fnpc65z7nebunavvh43l6oghjyzu + behaviours/reedem.py: bafybeicugygn4x34yrlmbzl2q7dn2zveexiichbbjce4ssk3cogx5r2cqy behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeifzhm4sspdvt227ksl5hjn26offgqpwempgbcwbr6dq7gyi2a46sm behaviours/tool_selection.py: bafybeigfr2frkljrxyfxs5p3j42equzehgaqtkyuxk6eiujyudr6ajqakm diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 1578a1ebc..ba7de63fc 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiglqwysg243dnxgefvshls67fmqwzkstgqxzt3wtosiwzhgvt63zi +- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 b88e70391..6d2af3927 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeieswda72gp3nm75rwwilvwkjvup2hmqxj5ji6ewsqnsdfujpuh63u +- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: From 44502358f5cee48e2f9fd74284fab1ff03c5a36d Mon Sep 17 00:00:00 2001 From: David Minarsch Date: Sun, 19 Nov 2023 10:33:43 +0000 Subject: [PATCH 7/7] chore: linter fixes --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- .../skills/decision_maker_abci/behaviours/reedem.py | 8 ++++++-- packages/valory/skills/decision_maker_abci/skill.yaml | 2 +- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index a90ce116e..c4e9d87d6 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti", - "skill/valory/decision_maker_abci/0.1.0": "bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu", - "skill/valory/trader_abci/0.1.0": "bafybeibpoqlzlvssrqezu4ljw5lahi2np6fr5pupzrmqjd6kypbdr6r4s4", + "skill/valory/decision_maker_abci/0.1.0": "bafybeifr5sqhtsnj2z4jv2lgcridolfbl23plqdbrdjmg2wyltmgr3zsui", + "skill/valory/trader_abci/0.1.0": "bafybeih72cnauzvc4lhpxjwyqxhx2vfxoztucfast7jyl6oqgbaqcctop4", "contract/valory/market_maker/0.1.0": "bafybeih4r35d3plsjw56ham6xvi6dn4semmuihc53lh3qofpwj242rnjkq", - "agent/valory/trader/0.1.0": "bafybeidvjnydkachtrkc26sjyorp4w2aujhn4mabfmat64dih5rwef4vrq", - "service/valory/trader/0.1.0": "bafybeiap4lmidxj4l3cxuj4w27k5teiyhn5pnnftf5lwsksqecrzcyzg24", + "agent/valory/trader/0.1.0": "bafybeibxipsj5g6mkgz5p6an6berhl5lqc7mkuqjhb3khzvgnmegmjam2q", + "service/valory/trader/0.1.0": "bafybeida22sohxo25ba5pspp75x6jh53ouhvkozp2ylndfitsd5cqwh5oq", "contract/valory/erc20/0.1.0": "bafybeidpjppgs7jlig2gdpdr3a6q3etbejpxrifjhzlcufpo5zf23dqv7y", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeig6nwyji7tkrpmc227z6p32gu5l3cge3jznjv5j3wzg4jh6x2rj7y", "contract/valory/mech/0.1.0": "bafybeigjn4q6mxal2hxzjyzldl4t4aykkpxjnbsgnli2c3xwf6binkmn74", "contract/valory/realitio/0.1.0": "bafybeiamgkwwqhray4fs2hlipwxkq7mosmi7ev7jut4vneetaaycc4ruji", "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 4b06f1695..eba86a8e7 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:bafybeiflxcl2dtzayyzzddc4f2astzxunyp66meutornanrgeemicdea5q - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/transaction_settlement_abci:0.1.0:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig6nwyji7tkrpmc227z6p32gu5l3cge3jznjv5j3wzg4jh6x2rj7y - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu -- valory/trader_abci:0.1.0:bafybeibpoqlzlvssrqezu4ljw5lahi2np6fr5pupzrmqjd6kypbdr6r4s4 +- valory/decision_maker_abci:0.1.0:bafybeifr5sqhtsnj2z4jv2lgcridolfbl23plqdbrdjmg2wyltmgr3zsui +- valory/trader_abci:0.1.0:bafybeih72cnauzvc4lhpxjwyqxhx2vfxoztucfast7jyl6oqgbaqcctop4 - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui default_ledger: ethereum required_ledgers: diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 1755b676b..049df9d32 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:bafybeidvjnydkachtrkc26sjyorp4w2aujhn4mabfmat64dih5rwef4vrq +agent: valory/trader:0.1.0:bafybeibxipsj5g6mkgz5p6an6berhl5lqc7mkuqjhb3khzvgnmegmjam2q number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py index bd7add103..d746990f5 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/reedem.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/reedem.py @@ -436,7 +436,9 @@ def _check_already_redeemed(self) -> WaitableConditionType: n_retries += 1 keep_fraction = (1 - self.params.reduce_factor) ** n_retries batch_size = int(self.params.event_filtering_batch_size * keep_fraction) - msg = f"Repeating this call with a decreased batch size of {batch_size}." + msg = ( + f"Repeating this call with a decreased batch size of {batch_size}." + ) self.context.logger.warning(msg) continue @@ -568,7 +570,9 @@ def get_claim_params(self) -> WaitableConditionType: n_retries += 1 keep_fraction = (1 - self.params.reduce_factor) ** n_retries batch_size = int(self.params.event_filtering_batch_size * keep_fraction) - msg = f"Repeating this call with a decreased batch size of {batch_size}." + msg = ( + f"Repeating this call with a decreased batch size of {batch_size}." + ) self.context.logger.warning(msg) continue diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index e45a18cc7..00302ffab 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -18,7 +18,7 @@ fingerprint: behaviours/decision_receive.py: bafybeifacce2ke7oltnwnpdjdqfd74eaaw5wxnjfzk6c5tqdsxsmbzjj3m behaviours/decision_request.py: bafybeievr7vae43e7jr4eqqhwe3emvgiih7ysa66jcb5g2oz5lbxua232q behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeicugygn4x34yrlmbzl2q7dn2zveexiichbbjce4ssk3cogx5r2cqy + behaviours/reedem.py: bafybeia2xoyrlbh55tv227hezqjck75irk6vmnpglw4lqfpx22a7bsjl4q behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeifzhm4sspdvt227ksl5hjn26offgqpwempgbcwbr6dq7gyi2a46sm behaviours/tool_selection.py: bafybeigfr2frkljrxyfxs5p3j42equzehgaqtkyuxk6eiujyudr6ajqakm diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index ba7de63fc..46d18bf61 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:bafybeigxkdujugzvve2dszkwr5kgfx4uhz2epofo4lorbcnthmzfjegwzi - valory/termination_abci:0.1.0:bafybeifazwrksp756h7z42qqfcgi6lya6wmhbx46l7ghlaooe45gqnju7q - valory/market_manager_abci:0.1.0:bafybeigesvgfjjtzxnsofhwutsp4pyclxnn62z2luy4xt7yarm64u6pbti -- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig4nzfbswrjdjjimmozzf5u6wtc4tx6cz3rxmipfk3mbloa5h54ty +- valory/decision_maker_abci:0.1.0:bafybeifr5sqhtsnj2z4jv2lgcridolfbl23plqdbrdjmg2wyltmgr3zsui +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeig6nwyji7tkrpmc227z6p32gu5l3cge3jznjv5j3wzg4jh6x2rj7y - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui 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 6d2af3927..b429e4f56 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:bafybeigrqhygo2hl2owisj5rqyh3acdvee773ajije64snlzalcgtaac7q -- valory/decision_maker_abci:0.1.0:bafybeibadaxe5jnye6scj6cr3m5gdzdo2aisohp7pvyydpg5j5ps6c7vfu +- valory/decision_maker_abci:0.1.0:bafybeifr5sqhtsnj2z4jv2lgcridolfbl23plqdbrdjmg2wyltmgr3zsui - valory/staking_abci:0.1.0:bafybeifoejd5q6wgmqohhwp46uwk3g4ysr7f5mf2fbmjhxulwzwdy2udui behaviours: main: