diff --git a/packages/packages.json b/packages/packages.json index 77c84fe60..ade632881 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -4,7 +4,7 @@ "custom/valory/mike_strat/0.1.0": "bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m", "custom/jhehemann/kelly_criterion/0.1.0": "bafybeif55cu7cf6znyma7kxus4wxa2doarhau2xmndo57iegshxorivwmq", "custom/w1kke/always_blue/0.1.0": "bafybeieshu32h3es2fslduuhr7nimuvh2vuibyeqdunzrcggaeohekg3jm", - "custom/valory/kelly_criterion_no_conf/0.1.0": "bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple", + "custom/valory/kelly_criterion_no_conf/0.1.0": "bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae", "contract/valory/market_maker/0.1.0": "bafybeiba25nt26ntjzkkpfyl2ngbjxrfd44ckg3znfhqm552725vb3gaka", "contract/valory/realitio/0.1.0": "bafybeignaxfk7fjlfa4lioflwsfru2z5xln5cyvyew3if5oas2sgm5wuii", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", @@ -16,14 +16,14 @@ "contract/valory/staking_token/0.1.0": "bafybeig4fl35dn7d5gnprux2nwsqbirm7zkiujz3xvrwcjuktz6hkq4as4", "contract/valory/relayer/0.1.0": "bafybeihzgjyvhtorugjw3yldznqsbwo3aqpxowm7k2nrvj6qtwpsc7jl7u", "skill/valory/market_manager_abci/0.1.0": "bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e", - "skill/valory/decision_maker_abci/0.1.0": "bafybeigykiciajiq5za7szupck5jbj6z6dvnmoufdam7eyigpn4mr6c6bq", - "skill/valory/trader_abci/0.1.0": "bafybeid23zogdrlauifqprlogztejgb2yl3ohcvqcat7nab2hgvez4bzru", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidcw2bzonvlgtyuv76zkutjs7qv5j4wgvi6azthqpyefds6i5cvdm", + "skill/valory/decision_maker_abci/0.1.0": "bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu", + "skill/valory/trader_abci/0.1.0": "bafybeidqh5nmjg6jk5hwqzf3abvjd4jiabs6eroisw5nh6d557isorxely", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiatr5y2qhqkqc7xtllwagk66wfnmbvdjmokb6ptlrhczzwwn76fce", "skill/valory/staking_abci/0.1.0": "bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi", "skill/valory/check_stop_trading_abci/0.1.0": "bafybeiepylk35n3faurvp7dskjkdovehftzfjrjxfkpekzuaovt5gojxne", - "agent/valory/trader/0.1.0": "bafybeigw6e7b5riiinbxa263q2k7qrk3zbejuabngdm2g4w2uu42qyyzsy", - "service/valory/trader/0.1.0": "bafybeigjc2g6dk26cfkjscg2qovlhjrqckw45tdfiikgqdg3xdxsllf2wm", - "service/valory/trader_pearl/0.1.0": "bafybeia2pb5efg3hxwpq7aa332puxyrpyvjkpnktsnjjaqw7ytutqifkvq" + "agent/valory/trader/0.1.0": "bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm", + "service/valory/trader/0.1.0": "bafybeidgliu5ylcpznirtn6vfs3g4d74utzfciuo4yqgcuj3ux6iwz5v2y", + "service/valory/trader_pearl/0.1.0": "bafybeihtghhxevo7yp46znaexcpoytqkxgi2tc56wusak525vdwwfrjfla" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 7c133ed9e..579b38da5 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -47,17 +47,17 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie - valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq - valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidcw2bzonvlgtyuv76zkutjs7qv5j4wgvi6azthqpyefds6i5cvdm +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiatr5y2qhqkqc7xtllwagk66wfnmbvdjmokb6ptlrhczzwwn76fce - valory/market_manager_abci:0.1.0:bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e -- valory/decision_maker_abci:0.1.0:bafybeigykiciajiq5za7szupck5jbj6z6dvnmoufdam7eyigpn4mr6c6bq -- valory/trader_abci:0.1.0:bafybeid23zogdrlauifqprlogztejgb2yl3ohcvqcat7nab2hgvez4bzru +- valory/decision_maker_abci:0.1.0:bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu +- valory/trader_abci:0.1.0:bafybeidqh5nmjg6jk5hwqzf3abvjd4jiabs6eroisw5nh6d557isorxely - valory/staking_abci:0.1.0:bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi - valory/check_stop_trading_abci:0.1.0:bafybeiepylk35n3faurvp7dskjkdovehftzfjrjxfkpekzuaovt5gojxne - valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e customs: - valory/mike_strat:0.1.0:bafybeihjiol7f4ch4piwfikurdtfwzsh6qydkbsztpbwbwb2yrqdqf726m - valory/bet_amount_per_threshold:0.1.0:bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24 -- valory/kelly_criterion_no_conf:0.1.0:bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple +- valory/kelly_criterion_no_conf:0.1.0:bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae - w1kke/always_blue:0.1.0:bafybeieshu32h3es2fslduuhr7nimuvh2vuibyeqdunzrcggaeohekg3jm - jhehemann/kelly_criterion:0.1.0:bafybeif55cu7cf6znyma7kxus4wxa2doarhau2xmndo57iegshxorivwmq default_ledger: ethereum @@ -232,8 +232,8 @@ models: refill_check_interval: ${int:10} tool_punishment_multiplier: ${int:1} contract_timeout: ${float:300.0} - file_hash_to_strategies_json: ${list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple",["kelly_criterion_no_conf"]]]} - strategies_kwargs: ${list:[["bet_kelly_fraction",0.5],["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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} + file_hash_to_strategies_json: ${list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",["kelly_criterion_no_conf"]]]} + 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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} service_endpoint: ${str:https://trader.staging.autonolas.tech/} rpc_sleep_time: ${int:10} mech_interaction_sleep_time: ${int:10} diff --git a/packages/valory/customs/kelly_criterion_no_conf/component.yaml b/packages/valory/customs/kelly_criterion_no_conf/component.yaml index 0596a9605..66dd77c4b 100644 --- a/packages/valory/customs/kelly_criterion_no_conf/component.yaml +++ b/packages/valory/customs/kelly_criterion_no_conf/component.yaml @@ -8,7 +8,7 @@ license: Apache-2.0 aea_version: '>=1.0.0, <2.0.0' fingerprint: __init__.py: bafybeidog73nvs6bfta5pmaxufwly6pc52knbnxqlwcwka4cpnyneeykqi - kelly_criterion_no_conf.py: bafybeiffkggwm23e7rfek5skvxd455sjxosjstkabrteyld7bgxuyz6bo4 + kelly_criterion_no_conf.py: bafybeifrdnpes4jbhnkesuuk5pktyz2udlx4d5yr73ebgqpzpiqywixhom fingerprint_ignore_patterns: [] entry_point: kelly_criterion_no_conf.py callable: run diff --git a/packages/valory/customs/kelly_criterion_no_conf/kelly_criterion_no_conf.py b/packages/valory/customs/kelly_criterion_no_conf/kelly_criterion_no_conf.py index 4a6f0a78c..71be7fc7d 100644 --- a/packages/valory/customs/kelly_criterion_no_conf/kelly_criterion_no_conf.py +++ b/packages/valory/customs/kelly_criterion_no_conf/kelly_criterion_no_conf.py @@ -19,7 +19,7 @@ """This module contains the kelly criterion strategy without confidence factor in the formula.""" -from typing import Dict, Any, List, Union +from typing import Dict, Any, List, Union, Optional REQUIRED_FIELDS = frozenset( { @@ -31,6 +31,7 @@ "selected_type_tokens_in_pool", "other_tokens_in_pool", "bet_fee", + "weighted_accuracy", "floor_balance", } ) @@ -53,6 +54,30 @@ def remove_irrelevant_fields(kwargs: Dict[str, Any]) -> Dict[str, Any]: return {key: value for key, value in kwargs.items() if key in ALL_FIELDS} +def get_adjusted_kelly_amount( + kelly_bet_amount: float, + weighted_accuracy: Optional[float], + static_kelly_fraction: float, + error: list, +): + """This function adjusts the kelly bet amount based on the weighted accuracy metric + of the selected tool to make the prediction. Default use-case: it uses the static kelly fraction + """ + if weighted_accuracy is None: + error.append( + f"No weighted accuracy information for this tool. Using static fraction." + ) + return int(kelly_bet_amount * static_kelly_fraction) + # weighted_accuracy must be always between [0, 1] + if not (0 <= weighted_accuracy <= 1): + error.append( + f"Wrong value for the weighted accuracy {weighted_accuracy}. Accepted range [0, 1]. Using static fraction" + ) + return int(kelly_bet_amount * static_kelly_fraction) + dynamic_kelly_fraction = static_kelly_fraction + weighted_accuracy + return int(kelly_bet_amount * dynamic_kelly_fraction) + + def calculate_kelly_bet_amount_no_conf( x: int, y: int, p: float, b: int, f: float ) -> int: @@ -104,6 +129,7 @@ def get_bet_amount_kelly( # pylint: disable=too-many-arguments selected_type_tokens_in_pool: int, other_tokens_in_pool: int, bet_fee: int, + weighted_accuracy: float, floor_balance: int, max_bet: int = DEFAULT_MAX_BET, ) -> Dict[str, Union[int, List[str]]]: @@ -139,7 +165,12 @@ def get_bet_amount_kelly( # pylint: disable=too-many-arguments 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"Applying dynamic kelly fraction to all bets. Weighted accuracy of the tool={weighted_accuracy}" + ) + adj_kelly_bet_amount = get_adjusted_kelly_amount( + kelly_bet_amount, weighted_accuracy, bet_kelly_fraction, error + ) info.append( f"Adjusted Kelly bet amount: {wei_to_native(adj_kelly_bet_amount)} xDAI" ) diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index 08193e5dc..e9ff9f902 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:bafybeigw6e7b5riiinbxa263q2k7qrk3zbejuabngdm2g4w2uu42qyyzsy +agent: valory/trader:0.1.0:bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm number_of_agents: 4 deployment: agent: @@ -127,8 +127,8 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0} contract_timeout: ${CONTRACT_TIMEOUT:float:300.0} - file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple",["kelly_criterion_no_conf"]]]} - strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",0.5],["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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",["kelly_criterion_no_conf"]]]} + 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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} use_subgraph_for_redeeming: ${USE_SUBGRAPH_FOR_REDEEMING:bool:true} use_nevermined: ${USE_NEVERMINED:bool:false} mech_to_subscription_params: ${SUBSCRIPTION_PARAMS:list:[["base_url", "https://marketplace-api.gnosis.nevermined.app/api/v1/metadata/assets/ddo"], @@ -348,8 +348,8 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0} contract_timeout: ${CONTRACT_TIMEOUT:float:300.0} - file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple",["kelly_criterion_no_conf"]]]} - strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",0.5],["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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",["kelly_criterion_no_conf"]]]} + 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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} use_subgraph_for_redeeming: ${USE_SUBGRAPH_FOR_REDEEMING:bool:true} use_nevermined: ${USE_NEVERMINED:bool:false} mech_to_subscription_params: ${SUBSCRIPTION_PARAMS:list:[["base_url", "https://marketplace-api.gnosis.nevermined.app/api/v1/metadata/assets/ddo"], @@ -463,8 +463,8 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0} contract_timeout: ${CONTRACT_TIMEOUT:float:300.0} - file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple",["kelly_criterion_no_conf"]]]} - strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",0.5],["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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",["kelly_criterion_no_conf"]]]} + 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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} use_subgraph_for_redeeming: ${USE_SUBGRAPH_FOR_REDEEMING:bool:true} use_nevermined: ${USE_NEVERMINED:bool:false} mech_to_subscription_params: ${SUBSCRIPTION_PARAMS:list:[["base_url", "https://marketplace-api.gnosis.nevermined.app/api/v1/metadata/assets/ddo"], @@ -578,8 +578,8 @@ type: skill tool_punishment_multiplier: ${TOOL_PUNISHMENT_MULTIPLIER:int:1} redeem_round_timeout: ${REDEEM_ROUND_TIMEOUT:float:3600.0} contract_timeout: ${CONTRACT_TIMEOUT:float:300.0} - file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeihnweebd6lxqtiat2mgspp5tpal4e2hntwdxvptkmbunpdxq2fple",["kelly_criterion_no_conf"]]]} - strategies_kwargs: ${STRATEGIES_KWARGS:list:[["bet_kelly_fraction",0.5],["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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} + file_hash_to_strategies_json: ${FILE_HASH_TO_STRATEGIES_JSON:list:[["bafybeihufqu2ra7vud4h6g2nwahx7mvdido7ff6prwnib2tdlc4np7dw24",["bet_amount_per_threshold"]],["bafybeibxfp27rzrfnp7sxq62vwv32pdvrijxi7vzg7ihukkaka3bwzrgae",["kelly_criterion_no_conf"]]]} + 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":60000000000000000,"0.7":90000000000000000,"0.8":100000000000000000,"0.9":1000000000000000000,"1.0":10000000000000000000}]]} use_subgraph_for_redeeming: ${USE_SUBGRAPH_FOR_REDEEMING:bool:true} use_nevermined: ${USE_NEVERMINED:bool:false} mech_to_subscription_params: ${SUBSCRIPTION_PARAMS:list:[["base_url", "https://marketplace-api.gnosis.nevermined.app/api/v1/metadata/assets/ddo"], diff --git a/packages/valory/services/trader_pearl/service.yaml b/packages/valory/services/trader_pearl/service.yaml index d653c69c4..4de276613 100644 --- a/packages/valory/services/trader_pearl/service.yaml +++ b/packages/valory/services/trader_pearl/service.yaml @@ -8,7 +8,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeigw6e7b5riiinbxa263q2k7qrk3zbejuabngdm2g4w2uu42qyyzsy +agent: valory/trader:0.1.0:bafybeifinxnuxu4ye2catrgrma7uyqm3f2hlurs4xsch27xftfo6im5ihm number_of_agents: 1 deployment: agent: diff --git a/packages/valory/skills/decision_maker_abci/behaviours/base.py b/packages/valory/skills/decision_maker_abci/behaviours/base.py index c3f843cc9..2ef43c45d 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -403,6 +403,7 @@ def get_bet_amount( selected_type_tokens_in_pool: int, other_tokens_in_pool: int, bet_fee: int, + weighted_accuracy: float, ) -> Generator[None, None, int]: """Get the bet amount given a specified trading strategy.""" yield from self.download_strategies() @@ -423,6 +424,7 @@ def get_bet_amount( "selected_type_tokens_in_pool": selected_type_tokens_in_pool, "other_tokens_in_pool": other_tokens_in_pool, "bet_fee": bet_fee, + "weighted_accuracy": weighted_accuracy, } ) results = self.execute_strategy(**kwargs) 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 fbb9345d1..2198b08e6 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -360,6 +360,7 @@ def _is_profitable( selected_type_tokens_in_pool, other_tokens_in_pool, bet.fee, + self.synchronized_data.weighted_accuracy, ) bet_threshold = self.params.bet_threshold bet_amount = max(bet_amount, bet_threshold) diff --git a/packages/valory/skills/decision_maker_abci/behaviours/storage_manager.py b/packages/valory/skills/decision_maker_abci/behaviours/storage_manager.py index 78496ae28..f22cae313 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/storage_manager.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/storage_manager.py @@ -296,11 +296,15 @@ def _update_accuracy_store(self, local_tools: List[str]) -> None: def _set_policy(self) -> Generator: """Set the E Greedy Policy.""" if self.is_first_period or not self.synchronized_data.is_policy_set: + self.context.logger.debug("Setting initial policy") self._policy = self._get_init_policy() local_tools = self._try_recover_mech_tools() if local_tools is None: local_tools = self.mech_tools else: + self.context.logger.debug( + "Reading policy information from synchronized data" + ) self._policy = self.synchronized_data.policy local_tools = self.synchronized_data.available_mech_tools diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index f82606e4d..7deb33e00 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,12 +12,12 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeidpo2jaunr2odotiapfkc7v6pxq6nzqckjjge6vavbsh3ejc54pti + behaviours/base.py: bafybeidmat7boku24xi3rtkj26aytnu2eynydm5dcxiswi6flrsj3lxgm4 behaviours/bet_placement.py: bafybeihmia64t2payxfqcnfdqg675ui2yp3hnyfwb2xhj2hn7wl237b4re behaviours/blacklisting.py: bafybeibofq3emoxxcndkozupsyo2xrigewy6ojvzfdvzwruvsvgyilokbu behaviours/check_benchmarking.py: bafybeiao2lyj7apezkqrpgsyzb3dwvrdgsrgtprf6iuhsmlsufvxfl5bci behaviours/claim_subscription.py: bafybeigbqkhc6mb73rbwaks32tfiqx6u2xza43uiy6rvbtrnqd6m4fru3e - behaviours/decision_receive.py: bafybeiay7cbzzngvtatswrgxczt5257jgwc6ppfi43fwc6rso36kipxmr4 + behaviours/decision_receive.py: bafybeifbgsa7ssnqgnyxkbzcc6t2pt372z3jhgn5rzw6yhevad6r7qiapy behaviours/decision_request.py: bafybeiabjzzcwcfbfmtoftjhewmkgbhxfnigbc5cwmmxl6cob5gv64jwwa behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm behaviours/order_subscription.py: bafybeicrmdvhci5prfldvuf3bclbbqi6j7lpv6hmphw3qwgmkmwat3od44 @@ -25,7 +25,7 @@ fingerprint: behaviours/reedem.py: bafybeiaszvuwfamdq5m7zaxf3tvbyp6wocsksezfajqv5xpkh43r62cj6u behaviours/round_behaviour.py: bafybeibvhobpvzzd37ecleuyp2jrbed6nontcw7urtsilbbzvqsmmupx64 behaviours/sampling.py: bafybeibtkli72qsvotkrsepkgpiumtr5sershtkpb427oygnszs3dpgxry - behaviours/storage_manager.py: bafybeifelwjwstg5dwrnzeav5mumz47kqrlmv4crfn27a3vliomychd2x4 + behaviours/storage_manager.py: bafybeibnlg2eirzcxdpnuwbhzne77ear44cqwm4yae5bacgfu4vqqq7d7a behaviours/tool_selection.py: bafybeienlxcgjs3ogyofli3d7q3p5rst3mcxxcnwqf7qolqjeefjtixeke dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeicvrvzcjt4hg5jyr2eleoajpbb7q2fbq2bopmbnwy33fsjdblzygu @@ -38,7 +38,7 @@ fingerprint: redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm rounds.py: bafybeihmj6x7utewuo6yqk4li7pxwkumiz4nsm5mfb6sd35j7kmfhzkhm4 states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy - states/base.py: bafybeiayitlxvdnl3pcm54l3zt5z5bcexbxixchrwtrmbhwoimm4555p7m + states/base.py: bafybeicrzw6p4dq52adkdjlduplt3expzajqmd3nkcpsw5yalfc3dwv75q states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda states/blacklisting.py: bafybeiapelgjhbjjn4uq4z5gspyirqzwzgccg5anktrp5kxdwamfnfw5mi states/check_benchmarking.py: bafybeiabv6pq7q45jd3nkor5afmlycqgec5ctuwcfbdukkjjm4imesv4ni @@ -57,7 +57,7 @@ fingerprint: tests/behaviours/data/.gitkeep: bafybeiekl43sjsyqfgl6y27ve5ydo4svcngrptgtffblokmspfezroxvvi tests/behaviours/dummy_strategy/__init__.py: bafybeiep5w5yckjzy724v63qd5cmzfn3uxytmnizynomxggfobbysfcttq tests/behaviours/dummy_strategy/dummy_strategy.py: bafybeig5e3xfr7gxsakfj4stbxqcwdiljl7klvgahkuwe3obzxgkg3qt2e - tests/behaviours/test_base.py: bafybeiagdrveenk62parzchxg2nd2krpzm2pflfv3p4gszjfpnv3r2kpf4 + tests/behaviours/test_base.py: bafybeif6pglmr7pvojylatfzaxtlk65igx6a2omyrbxfihnnft6o7p75p4 tests/conftest.py: bafybeidy5hw56kw5mxudnfbhvogofn6k4rqb4ux2bd45baedrrhmgyrude tests/test_handlers.py: bafybeihpkgtjjm3uegpup6zkznpoaxqpu6kmp3ujiggrzbe73p5fzlq7im tests/test_payloads.py: bafybeigsftkoc7ursy7okfznbwfiy3pk2kitndfgbn35ebbz4yoptkw3zy diff --git a/packages/valory/skills/decision_maker_abci/states/base.py b/packages/valory/skills/decision_maker_abci/states/base.py index 01e7cf9a9..320457259 100644 --- a/packages/valory/skills/decision_maker_abci/states/base.py +++ b/packages/valory/skills/decision_maker_abci/states/base.py @@ -150,6 +150,17 @@ def bet_amount(self) -> int: """Get the calculated bet amount.""" return int(self.db.get_strict("bet_amount")) + @property + def weighted_accuracy(self) -> float: + """Get the weighted accuracy of the selected tool.""" + tool_name = self.mech_tool + store_tools = set(self.policy.weighted_accuracy.keys()) + if tool_name not in store_tools: + raise ValueError( + f"The tool {tool_name} was selected but it is not available in the policy!" + ) + return self.policy.weighted_accuracy[tool_name] + @property def is_profitable(self) -> bool: """Get whether the current vote is profitable or not.""" 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 index a1f338aa9..5f48f32e3 100644 --- a/packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py +++ b/packages/valory/skills/decision_maker_abci/tests/behaviours/test_base.py @@ -262,6 +262,7 @@ def test_get_bet_amount( 0, 0, 0, + 0, ) for _ in range(2): # `download_strategies` and `wait_for_condition_with_sleep` mock calls diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 5f1303133..4bbfe94d5 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -27,8 +27,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote - valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq - valory/market_manager_abci:0.1.0:bafybeiai6djelf6d4dkxgkv46l24q2gz7736b3jdhbxslvcydpvnvrse6e -- valory/decision_maker_abci:0.1.0:bafybeigykiciajiq5za7szupck5jbj6z6dvnmoufdam7eyigpn4mr6c6bq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidcw2bzonvlgtyuv76zkutjs7qv5j4wgvi6azthqpyefds6i5cvdm +- valory/decision_maker_abci:0.1.0:bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiatr5y2qhqkqc7xtllwagk66wfnmbvdjmokb6ptlrhczzwwn76fce - valory/staking_abci:0.1.0:bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi - valory/check_stop_trading_abci:0.1.0:bafybeiepylk35n3faurvp7dskjkdovehftzfjrjxfkpekzuaovt5gojxne - valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index ee919d92b..547c5f421 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -23,7 +23,7 @@ protocols: - valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni skills: - valory/abstract_round_abci:0.1.0:bafybeiar2yhzxacfe3qqamqhaihtlcimquwedffctw55sowx6rac3cm3ui -- valory/decision_maker_abci:0.1.0:bafybeigykiciajiq5za7szupck5jbj6z6dvnmoufdam7eyigpn4mr6c6bq +- valory/decision_maker_abci:0.1.0:bafybeieaenzaucsz7234gynswn7f2ufsvhkhbniuc4mhh3kvu7atvdjqwu - valory/staking_abci:0.1.0:bafybeiduborfqevheegy3plk7bzhkl4fukwixvlb57tenijdepintubbdi - valory/mech_interact_abci:0.1.0:bafybeih2cck5xu6yaibomwtm5zbcp6llghr3ighdnk56fzwu3ihu5xx35e behaviours: