diff --git a/.github/workflows/common_checks.yaml b/.github/workflows/common_checks.yaml index a09c08584..d7e5ee978 100644 --- a/.github/workflows/common_checks.yaml +++ b/.github/workflows/common_checks.yaml @@ -63,7 +63,7 @@ jobs: - name: Install dependencies run: pip install tomte[tox,cli]==0.2.14 - name: Check copyright headers - run: tomte check-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part mech --exclude-part mech_interact_abci --exclude-part http_server --exclude-part mech_marketplace + run: tomte check-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part mech --exclude-part mech_interact_abci --exclude-part http_server --exclude-part mech_marketplace --exclude-part erc20 - name: License compatibility check run: tox -e liccheck - name: Check dependencies diff --git a/.gitignore b/.gitignore index afc4b8303..3c8c8dec6 100644 --- a/.gitignore +++ b/.gitignore @@ -38,7 +38,7 @@ packages/valory/protocols/tendermint .idea **/__pycache__/ *.DS_Store - +trader_backup/ .mypy_cache /.tox/ diff --git a/Makefile b/Makefile index 37649eeaa..1333cfb6d 100644 --- a/Makefile +++ b/Makefile @@ -74,13 +74,13 @@ security: .PHONY: generators generators: clean-cache fix-abci-app-specs tox -e abci-docstrings - tomte format-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part mech --exclude-part mech_interact_abci --exclude-part http_server --exclude-part mech_marketplace --exclude-part agent_registry + tomte format-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part http_server --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part erc20 --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part mech --exclude-part mech_marketplace --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part mech_interact_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part agent_registry autonomy packages lock tox -e fix-doc-hashes .PHONY: common-checks-1 common-checks-1: - tomte check-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part mech --exclude-part mech_interact_abci --exclude-part http_server --exclude-part mech_marketplace --exclude-part agent_registry + tomte check-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part http_server --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part erc20 --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part mech --exclude-part mech_marketplace --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part mech_interact_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription - tomte format-copyright --author valory --exclude-part abci --exclude-part http_client --exclude-part http_server --exclude-part ipfs --exclude-part ledger --exclude-part p2p_libp2p_client --exclude-part erc20 --exclude-part gnosis_safe --exclude-part gnosis_safe_proxy_factory --exclude-part mech --exclude-part mech_marketplace --exclude-part multisend --exclude-part service_registry --exclude-part protocols --exclude-part abstract_abci --exclude-part abstract_round_abci --exclude-part mech_interact_abci --exclude-part registration_abci --exclude-part reset_pause_abci --exclude-part termination_abci --exclude-part transaction_settlement_abci --exclude-part websocket_client --exclude-part contract_subscription --exclude-part agent_registry tomte check-doc-links tox -p -e check-hash -e check-packages -e check-doc-hashes -e analyse-service diff --git a/packages/packages.json b/packages/packages.json index 355b0af49..fbef07494 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -9,20 +9,21 @@ "contract/valory/realitio/0.1.0": "bafybeietgux6kkhdquspy35qera7gjwwqwrremmoeatjzwwokjb2lzsata", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", "contract/valory/conditional_tokens/0.1.0": "bafybeibnzmqmeph4cj5vfh3s622mo2o5627vjjwc6bptrhj4dk65mzgvhe", + "contract/valory/agent_registry/0.1.0": "bafybeibfqhrpvuaibi6pgwsrot3ybt77hf4itjw6pklwnpxi3wcrrg2gr4", "contract/valory/service_staking_token/0.1.0": "bafybeiarxffrwdq47rmydgffyxhe6ntfb5unp44yt47kxqg7fzc7vburni", "contract/valory/transfer_nft_condition/0.1.0": "bafybeicfl4jldwjf6ngk3x4b36krcqogzbgqzs4zkzxipmtgveeefus264", "contract/valory/mech_activity/0.1.0": "bafybeiey6n7fjehm5k4g5h4toygqq3zzyxadqj3zabf67jmn5vzw5kndre", "contract/valory/staking_token/0.1.0": "bafybeiabkkhjpybqpzdfc4vcbiz4vefctfpvwetbmo7pqpiuxprmpvnti4", "contract/valory/relayer/0.1.0": "bafybeibvqc3lwxtcnu6dgfkf7mzefdgtfyosyq2dow7ogyxsl25vkxjwea", - "skill/valory/market_manager_abci/0.1.0": "bafybeid75ggv2pk22gtf6ae5prtwlahmgkxjla3tgw5mykn7agcndrbs5e", - "skill/valory/decision_maker_abci/0.1.0": "bafybeiexu6ttsv6gqlwsxbn5zoq4fgjboiq5v65q3fwlamsxabha2xjihq", - "skill/valory/trader_abci/0.1.0": "bafybeifvlcs7ak6kjemueeqwv4uwrjgrcd4g2qumflaxkgcgrrzqfbnuae", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeictbhf3hittfibpo6hr2435y4gtvppgmg4uu4d2xpudw3z2ek5hgm", + "skill/valory/market_manager_abci/0.1.0": "bafybeihmyqkzl3bm5zvjnc4auj32qjf3pk73scyq7mntmpsudqnisb4gey", + "skill/valory/decision_maker_abci/0.1.0": "bafybeigehrtalp3ppnog25yuvfcdt3gmrgvxb2zm2zyngxxfcvps2s3tza", + "skill/valory/trader_abci/0.1.0": "bafybeideek7oe3rbcnaymd4bnwsm2kull75wfdvljv5prvcsok5sgti7bq", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeih2s2dwnyxm7xhd3knc3wlaejzyvfulxkipwnidmzxgx7t3ofqbpq", "skill/valory/staking_abci/0.1.0": "bafybeial5xtgzf37e2khvdrc2q2wa2xhirjwioi2szwvcgtupidjxhg7tq", "skill/valory/check_stop_trading_abci/0.1.0": "bafybeid7l74lmjnkeerkbvwhoo2l4cawb7c545rhcx3mjpsjux4zwy5wpm", - "agent/valory/trader/0.1.0": "bafybeiggtcerws6srpq7lljq54gnbmiqvoclre7jsjuhxqiiu3e7oop6yq", - "service/valory/trader/0.1.0": "bafybeiaaa3fufe4gwmrdeml5ixrqr42jz7paubqvbg7hucdqjvbbxwpbua", - "service/valory/trader_pearl/0.1.0": "bafybeigzwsotc2ku27gagstefantjvr2yr7usdytljwtb5cuupyt2jl2dm" + "agent/valory/trader/0.1.0": "bafybeicy63hsvgcui5p6vwjdgfwrm7ldvjxui4nyy7zykm675xjfnmdbza", + "service/valory/trader/0.1.0": "bafybeiawu46p7whmf6aiywqyechsolmhb56ew7c7pjphmrhzen7umk6lc4", + "service/valory/trader_pearl/0.1.0": "bafybeia3eztsz325jy2sbtilulfnl6pngz3bltkvogowx6xym3kr5re4ei" }, "third_party": { "protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index 9fdee81e8..e7149df62 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -50,10 +50,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeigebq46oqz2mx2iajupr6p5pgm6z5pvfye5w6zypsseuqtvta7b4a - valory/termination_abci:0.1.0:bafybeieurwmfernodqyczj5ertsgfbjtjnrlgvte7sli4sajnbopty7inu - valory/transaction_settlement_abci:0.1.0:bafybeifkftgkyzrxwxjdyqixpp7vk6aqmufikalmwx3kydtlg74tonu47u -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeictbhf3hittfibpo6hr2435y4gtvppgmg4uu4d2xpudw3z2ek5hgm -- valory/market_manager_abci:0.1.0:bafybeid75ggv2pk22gtf6ae5prtwlahmgkxjla3tgw5mykn7agcndrbs5e -- valory/decision_maker_abci:0.1.0:bafybeiexu6ttsv6gqlwsxbn5zoq4fgjboiq5v65q3fwlamsxabha2xjihq -- valory/trader_abci:0.1.0:bafybeifvlcs7ak6kjemueeqwv4uwrjgrcd4g2qumflaxkgcgrrzqfbnuae +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeih2s2dwnyxm7xhd3knc3wlaejzyvfulxkipwnidmzxgx7t3ofqbpq +- valory/market_manager_abci:0.1.0:bafybeihmyqkzl3bm5zvjnc4auj32qjf3pk73scyq7mntmpsudqnisb4gey +- valory/decision_maker_abci:0.1.0:bafybeigehrtalp3ppnog25yuvfcdt3gmrgvxb2zm2zyngxxfcvps2s3tza +- valory/trader_abci:0.1.0:bafybeideek7oe3rbcnaymd4bnwsm2kull75wfdvljv5prvcsok5sgti7bq - valory/staking_abci:0.1.0:bafybeial5xtgzf37e2khvdrc2q2wa2xhirjwioi2szwvcgtupidjxhg7tq - valory/check_stop_trading_abci:0.1.0:bafybeid7l74lmjnkeerkbvwhoo2l4cawb7c545rhcx3mjpsjux4zwy5wpm - valory/mech_interact_abci:0.1.0:bafybeif2tpz2zet6p4z4vi3b254oxzyyzoe5tehj3me3znzt7h7otkpd54 @@ -268,6 +268,7 @@ models: bet_amount_field: ${str:collateral_amount} results_filename: ${str:benchmarking_results.csv} randomness: ${str:benchmarking_randomness} + nr_mech_calls: ${int:60} acc_info_fields: args: tool: ${str:tool} diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index cb96e27e2..dfd27d010 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:bafybeiggtcerws6srpq7lljq54gnbmiqvoclre7jsjuhxqiiu3e7oop6yq +agent: valory/trader:0.1.0:bafybeicy63hsvgcui5p6vwjdgfwrm7ldvjxui4nyy7zykm675xjfnmdbza number_of_agents: 4 deployment: agent: @@ -174,6 +174,7 @@ type: skill bet_amount_field: ${BENCHMARKING_MODE_BET_AMOUNT_FIELD:str:collateral_amount} results_filename: ${BENCHMARKING_MODE_RESULTS_FILENAME:str:benchmarking_results.csv} randomness: ${BENCHMARKING_MODE_RANDOMNESS:str:benchmarking_randomness} + nr_mech_calls: ${BENCHMARKING_MECH_CALLS:int:60} acc_info_fields: &id004 args: tool: ${ACC_INFO_FIELDS_TOOL:str:tool} diff --git a/packages/valory/services/trader_pearl/service.yaml b/packages/valory/services/trader_pearl/service.yaml index 44d577076..863befdcd 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:bafybeiggtcerws6srpq7lljq54gnbmiqvoclre7jsjuhxqiiu3e7oop6yq +agent: valory/trader:0.1.0:bafybeicy63hsvgcui5p6vwjdgfwrm7ldvjxui4nyy7zykm675xjfnmdbza 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 85501f44c..ea6699a49 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/base.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023-2024 Valory AG +# Copyright 2023-2025 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -48,7 +48,6 @@ from packages.valory.skills.decision_maker_abci.models import ( AccuracyInfoFields, BenchmarkingMockData, - BenchmarkingMode, DecisionMakerParams, L0_END_FIELD, L0_START_FIELD, @@ -171,11 +170,6 @@ def params(self) -> DecisionMakerParams: """Return the params.""" return cast(DecisionMakerParams, self.context.params) - @property - def benchmarking_mode(self) -> BenchmarkingMode: - """Return the benchmarking mode configurations.""" - return cast(BenchmarkingMode, self.context.benchmarking_mode) - @property def mock_data(self) -> BenchmarkingMockData: """Return the mock data for the benchmarking mode.""" diff --git a/packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py b/packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py index dc4844aba..6039db0f9 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/bet_placement.py @@ -213,6 +213,7 @@ def async_act(self) -> Generator: if self.benchmarking_mode.enabled: # simulate the bet placement with self.context.benchmark_tool.measure(self.behaviour_id).local(): + self.update_bet_transaction_information() payload = BetPlacementPayload( agent, None, None, True, self.wallet_balance ) 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 7e17bb43f..f673a4899 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/decision_receive.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023-2024 Valory AG +# Copyright 2023-2025 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -49,6 +49,7 @@ P_NO_FIELD, P_YES_FIELD, PredictionResponse, + QueueStatus, ) from packages.valory.skills.mech_interact_abci.states.base import ( MechInteractionResponse, @@ -126,6 +127,7 @@ def _next_dataset_row(self) -> Optional[Dict[str, str]]: else: # no more bets available for this market msg = f"No more mock responses for the market with id: {sampled_bet_id}" + self.sampled_bet.queue_status = QueueStatus.BENCHMARKING_DONE self.context.logger.info(msg) self.shared_state.last_benchmarking_has_run = True self._rows_exceeded = True @@ -514,6 +516,9 @@ def _is_profitable( else: self._write_benchmark_results(prediction_response) + self.context.logger.info("Increasing Mech call count by 1") + self.shared_state.benchmarking_mech_calls += 1 + return is_profitable, bet_amount def _update_selected_bet( @@ -569,6 +574,8 @@ def async_act(self) -> Generator: prediction_response, bet_amount, ) + self.context.logger.info("Increasing Mech call count by 1") + self.shared_state.benchmarking_mech_calls += 1 if prediction_response is not None: self.policy.tool_responded( diff --git a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py index 944149a49..dd8048076 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py @@ -138,6 +138,31 @@ def _sampled_bet_idx(self, bets: List[Bet]) -> int: return self.bets.index(sorted_bets[0]) + def _sampling_benchmarking_bet(self, bets: List[Bet]) -> Optional[int]: + """Sample bet for benchmarking""" + to_process_bets, processed_bets, reprocessed_bets = self._get_bets_queue_wise( + bets + ) + + self.context.logger.info(f"TO_PROCESS_LEN: {len(to_process_bets)}") + self.context.logger.info(f"PROCESSED_LEN: {len(processed_bets)}") + self.context.logger.info(f"REPROCESSED_LEN: {len(reprocessed_bets)}") + + self.context.logger.info( + f"MECH CALLS MADE: {self.shared_state.benchmarking_mech_calls}" + ) + + if ( + self.shared_state.benchmarking_mech_calls + == self.benchmarking_mode.nr_mech_calls + ): + return None + + bets_to_sort: List[Bet] = to_process_bets or processed_bets or reprocessed_bets + sorted_bets = self._sort_by_priority_logic(bets_to_sort) + + return self.bets.index(sorted_bets[0]) + def _sample(self) -> Optional[int]: """Sample a bet, mark it as processed, and return its index.""" # modify time "NOW" in benchmarking mode @@ -164,6 +189,11 @@ def _sample(self) -> Optional[int]: self.context.logger.warning(msg) return None + if self.benchmarking_mode.enabled: + idx = self._sampling_benchmarking_bet(available_bets) + if not idx: + return None + # sample a bet using the priority logic idx = self._sampled_bet_idx(available_bets) sampled_bet = self.bets[idx] @@ -190,6 +220,8 @@ def _benchmarking_inc_day(self) -> Tuple[bool, bool]: if benchmarking_finished: self.context.logger.info("No more days to simulate in benchmarking mode.") + self.shared_state.benchmarking_mech_calls = 0 + day_increased = True return benchmarking_finished, day_increased @@ -204,6 +236,9 @@ def async_act(self) -> Generator: # day increase simulation and benchmarking finished check if idx is None and self.benchmarking_mode.enabled: benchmarking_finished, day_increased = self._benchmarking_inc_day() + for bet in self.bets: + bet.queue_status = bet.queue_status.move_to_fresh() + bet.queue_status = bet.queue_status.move_to_process() self.store_bets() diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 1528a6076..f0df7a5a0 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -215,6 +215,9 @@ def __init__(self, *args: Any, skill_context: SkillContext, **kwargs: Any) -> No # the key is the market id/question_id self.bet_id_row_manager: Dict[str, List[int]] = {} + # mech call counter for benchmarking behaviour + self.benchmarking_mech_calls: int = 0 + @property def mock_question_id(self) -> Any: """Get the mock question id.""" @@ -497,39 +500,6 @@ def get_store_path(self, kwargs: Dict) -> Path: return Path(path) -class BenchmarkingMode(Model, TypeCheckMixin): - """Configuration for the benchmarking mode.""" - - def __init__(self, *args: Any, **kwargs: Any) -> None: - """Initialize the `BenchmarkingMode` object.""" - self.enabled: bool = self._ensure("enabled", kwargs, bool) - self.native_balance: int = self._ensure("native_balance", kwargs, int) - self.collateral_balance: int = self._ensure("collateral_balance", kwargs, int) - self.mech_cost: int = self._ensure("mech_cost", kwargs, int) - self.pool_fee: int = self._ensure("pool_fee", kwargs, int) - self.sep: str = self._ensure("sep", kwargs, str) - self.dataset_filename: Path = Path( - self._ensure("dataset_filename", kwargs, str) - ) - self.question_field: str = self._ensure("question_field", kwargs, str) - self.question_id_field: str = self._ensure("question_id_field", kwargs, str) - self.answer_field: str = self._ensure("answer_field", kwargs, str) - self.p_yes_field_part: str = self._ensure("p_yes_field_part", kwargs, str) - self.p_no_field_part: str = self._ensure("p_no_field_part", kwargs, str) - self.confidence_field_part: str = self._ensure( - "confidence_field_part", kwargs, str - ) - # this is the mode for the p and confidence parts - # if the flag is `True`, then the field parts are used as prefixes, otherwise as suffixes - self.part_prefix_mode: bool = self._ensure("part_prefix_mode", kwargs, bool) - self.bet_amount_field: str = self._ensure("bet_amount_field", kwargs, str) - self.results_filename: Path = Path( - self._ensure("results_filename", kwargs, str) - ) - self.randomness: str = self._ensure("randomness", kwargs, str) - super().__init__(*args, **kwargs) - - class AccuracyInfoFields(Model, TypeCheckMixin): """Configuration which holds the accuracy information file's fieldnames.""" diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index c14591edf..a36b6ada5 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -12,19 +12,19 @@ fingerprint: README.md: bafybeia367zzdwndvlhw27rvnwodytjo3ms7gbc3q7mhrrjqjgfasnk47i __init__.py: bafybeih563ujnigeci2ldzh7hakbau6a222vsed7leg3b7lq32vcn3nm4a behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky - behaviours/base.py: bafybeibkwfsd2atjzejhsel5p4cptd2wg2shefyly5jbiywgbjvx6k2q4y - behaviours/bet_placement.py: bafybeidyucxomadfzr6eyfywlc4satl4vqb6qhdkyzdp76zkxbfjfyzai4 + behaviours/base.py: bafybeifyuhycdirvw4k5np6spfmvinzvisb5rley5xjl7nodhxjtee34oa + behaviours/bet_placement.py: bafybeibiezagww5dsbpptgvtzgch3yjrq3343gw5cyfpckegxkfzo67vru behaviours/blacklisting.py: bafybeieuqoup2vrmrtvjfqnr5mzrvkegc7afb2oeujzq2itsbhcsham2se behaviours/check_benchmarking.py: bafybeiao2lyj7apezkqrpgsyzb3dwvrdgsrgtprf6iuhsmlsufvxfl5bci behaviours/claim_subscription.py: bafybeigbqkhc6mb73rbwaks32tfiqx6u2xza43uiy6rvbtrnqd6m4fru3e - behaviours/decision_receive.py: bafybeibsthk6fjydkengwzgpgz5v44xpta67nnlyxt6uugx2voitqgojpq + behaviours/decision_receive.py: bafybeiblt4of7gykqvql7ctchakbx27uxvesizbhczlvcqzr35f7zyjjci behaviours/decision_request.py: bafybeia22omb7tvocyfe3z2ucn5au5mcas7dg37ha42u7znefzrewjpk7y behaviours/handle_failed_tx.py: bafybeiashwlfp6ty3g6ukgmliaghwu6yiunbqpjmyrzheokw3pbcr2ckaq behaviours/order_subscription.py: bafybeihwuhgykptokmeam5sacnfzedk5puvrxbjo7iypaqhsrqg5nk7psm behaviours/randomness.py: bafybeiaoj3awyyg2onhpsdsn3dyczs23gr4smuzqcbw3e5ocljwxswjkce behaviours/reedem.py: bafybeiajxsz34iy24muw4avq4vbevluhsabjcyqaadssnrs2zrfdapbnqq behaviours/round_behaviour.py: bafybeih63hpia2bwwzu563hxs5yd3t5ycvxvkfnhvxbzghbyy3mw3xjl3i - behaviours/sampling.py: bafybeicvtxjv5rxlsdrmbtetqwzzau6is47guystvw245grd6s2qs5pxea + behaviours/sampling.py: bafybeiet37e4o4s5kdf4u4denls7iaqm6b2a2mqa5eu576waiwmuwozhmi behaviours/storage_manager.py: bafybeic6wca37fkwonbsrwme55xnklfbqtheknroudayzfxdge4pxdbm7y behaviours/tool_selection.py: bafybeienlxcgjs3ogyofli3d7q3p5rst3mcxxcnwqf7qolqjeefjtixeke dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm @@ -32,7 +32,7 @@ fingerprint: handlers.py: bafybeieggvt2rh654s2jt2ablqtyzaycb7wlgrrdbsccf5652nptv45hie io_/__init__.py: bafybeifxgmmwjqzezzn3e6keh2bfo4cyo7y5dq2ept3stfmgglbrzfl5rq io_/loader.py: bafybeih3sdsx5dhe4kzhtoafexjgkutsujwqy3zcdrlrkhtdks45bc7exa - models.py: bafybeih74q5cuchpxkz2xvrrzdzaadrzxj6jqcwderlgm46hnxxadf3bne + models.py: bafybeiasqxrhudkisjohjdgbkmmj6esyw52sh66xflwkatd5dyradxb37q payloads.py: bafybeieygushjlrzwzpnhagjgpbs3goot3pnfheh6yawuwctrk3uoeesfm policy.py: bafybeidofgwvk6sudz75tvuduskuphtn3amtib2irzw5hr3qcfn5pdwuc4 redeem_info.py: bafybeifiiix4gihfo4avraxt34sfw35v6dqq45do2drrssei2shbps63mm @@ -102,7 +102,7 @@ protocols: - valory/http:1.0.0:bafybeih4azmfwtamdbkhztkm4xitep3gx6tfdnoz6tvllmaqnhu3klejfa skills: - valory/abstract_round_abci:0.1.0:bafybeia27qmw6w5ds5fcrpj2475brnz742aampe3sgochloijs2l7jovai -- valory/market_manager_abci:0.1.0:bafybeid75ggv2pk22gtf6ae5prtwlahmgkxjla3tgw5mykn7agcndrbs5e +- valory/market_manager_abci:0.1.0:bafybeihmyqkzl3bm5zvjnc4auj32qjf3pk73scyq7mntmpsudqnisb4gey - valory/transaction_settlement_abci:0.1.0:bafybeifkftgkyzrxwxjdyqixpp7vk6aqmufikalmwx3kydtlg74tonu47u - valory/mech_interact_abci:0.1.0:bafybeif2tpz2zet6p4z4vi3b254oxzyyzoe5tehj3me3znzt7h7otkpd54 - valory/staking_abci:0.1.0:bafybeial5xtgzf37e2khvdrc2q2wa2xhirjwioi2szwvcgtupidjxhg7tq @@ -306,32 +306,6 @@ models: mech_consecutive_failures_threshold: 2 tool_quarantine_duration: 18000 class_name: DecisionMakerParams - benchmarking_mode: - args: - enabled: false - native_balance: 10000000000000000000 - collateral_balance: 10000000000000000000 - mech_cost: 10000000000000000 - pool_fee: 20000000000000000 - outcome_token_amounts: - - 11000000000000000000 - - 9000000000000000000 - outcome_token_marginal_prices: - - 0.4 - - 0.6 - sep: ',' - dataset_filename: benchmark_data.csv - question_field: question - question_id_field: question_id - answer_field: answer - p_yes_field_part: p_yes_ - p_no_field_part: p_no_ - confidence_field_part: confidence_ - part_prefix_mode: true - bet_amount_field: collateral_amount - results_filename: benchmarking_results.csv - randomness: benchmarking_randomness - class_name: BenchmarkingMode acc_info_fields: args: tool: tool diff --git a/packages/valory/skills/market_manager_abci/behaviours.py b/packages/valory/skills/market_manager_abci/behaviours.py index 54750cae5..bfc8b71da 100644 --- a/packages/valory/skills/market_manager_abci/behaviours.py +++ b/packages/valory/skills/market_manager_abci/behaviours.py @@ -39,7 +39,10 @@ MAX_LOG_SIZE, QueryingBehaviour, ) -from packages.valory.skills.market_manager_abci.models import SharedState +from packages.valory.skills.market_manager_abci.models import ( + BenchmarkingMode, + SharedState, +) from packages.valory.skills.market_manager_abci.payloads import UpdateBetsPayload from packages.valory.skills.market_manager_abci.rounds import ( MarketManagerAbciApp, @@ -68,6 +71,11 @@ def shared_state(self) -> SharedState: """Get the shared state.""" return cast(SharedState, self.context.state) + @property + def benchmarking_mode(self) -> BenchmarkingMode: + """Return the benchmarking mode configurations.""" + return cast(BenchmarkingMode, self.context.benchmarking_mode) + def store_bets(self) -> None: """Store the bets to the agent's data dir as JSON.""" serialized = serialize_bets(self.bets) @@ -91,7 +99,7 @@ def read_bets(self) -> None: """Read the bets from the agent's data dir as JSON.""" self.bets = [] - if self.shared_state.first_read: + if not self.benchmarking_mode.enabled and self.shared_state.first_read: # this is a temporary hack to overcome a multi-bets issue # if a bet that is in the `TO_PROCESS` queue cannot be selected because of the constraints # (e.g., not in opening margin), then everything is blocked because the `FRESH` status will never be updated: diff --git a/packages/valory/skills/market_manager_abci/bets.py b/packages/valory/skills/market_manager_abci/bets.py index 6380aae48..614c20149 100644 --- a/packages/valory/skills/market_manager_abci/bets.py +++ b/packages/valory/skills/market_manager_abci/bets.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------------------------ # -# Copyright 2023-2024 Valory AG +# Copyright 2023-2025 Valory AG # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -44,6 +44,7 @@ class QueueStatus(Enum): TO_PROCESS = 1 # Bets that are ready to be processed PROCESSED = 2 # Bets that have been processed REPROCESSED = 3 # Bets that have been reprocessed + BENCHMARKING_DONE = 4 def is_fresh(self) -> bool: """Check if the bet is fresh.""" @@ -61,7 +62,7 @@ def move_to_process(self) -> "QueueStatus": def move_to_fresh(self) -> "QueueStatus": """Move the bet to the fresh status.""" - if self != QueueStatus.EXPIRED: + if self not in [QueueStatus.EXPIRED, QueueStatus.BENCHMARKING_DONE]: return QueueStatus.FRESH return self @@ -311,15 +312,15 @@ def hook(data: Dict[str, Any]) -> Union[Bet, PredictionResponse, Dict[str, Bet]] if bet_annotations == data_attributes: data["queue_status"] = QueueStatus(data["queue_status"]) return Bet(**data) - else: - # fetch missing attributes from the data - missing_attributes = set(bet_annotations) - set(data_attributes) - new_attributes = {"queue_status", "invested_amount"} - if missing_attributes == new_attributes: - data["queue_status"] = QueueStatus(0) - data["invested_amount"] = 0 - return Bet(**data) - + # if the data contains an id key, but does not match the bet attributes exactly, process it as a bet + elif "id" in data_attributes: + # Extract only the attributes that exist in both Bet and data to ensure compatibility + common_attributes = set(bet_annotations) & set(data_attributes) + data = {key: data[key] for key in common_attributes} + # Convert queue_status to a QueueStatus enum if present in data + if "queue_status" in data: + data["queue_status"] = QueueStatus(data["queue_status"]) + return Bet(**data) return data diff --git a/packages/valory/skills/market_manager_abci/models.py b/packages/valory/skills/market_manager_abci/models.py index f1415b5bf..21fe2635b 100644 --- a/packages/valory/skills/market_manager_abci/models.py +++ b/packages/valory/skills/market_manager_abci/models.py @@ -21,9 +21,10 @@ """Custom objects for the MarketManager ABCI application.""" import builtins +from pathlib import Path from typing import Any, Dict, Iterator, List, Tuple, Type -from aea.skills.base import SkillContext +from aea.skills.base import Model, SkillContext from packages.valory.protocols.http import HttpMessage from packages.valory.skills.abstract_round_abci.base import AbciApp @@ -35,6 +36,7 @@ from packages.valory.skills.abstract_round_abci.models import ( SharedState as BaseSharedState, ) +from packages.valory.skills.abstract_round_abci.models import TypeCheckMixin from packages.valory.skills.market_manager_abci.bets import BINARY_N_SLOTS from packages.valory.skills.market_manager_abci.rounds import MarketManagerAbciApp @@ -114,3 +116,37 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: def creators_iterator(self) -> Iterator[Tuple[str, List[str]]]: """Return an iterator of market per creators.""" return iter(self.creator_per_market.items()) + + +class BenchmarkingMode(Model, TypeCheckMixin): + """Configuration for the benchmarking mode.""" + + def __init__(self, *args: Any, **kwargs: Any) -> None: + """Initialize the `BenchmarkingMode` object.""" + self.enabled: bool = self._ensure("enabled", kwargs, bool) + self.native_balance: int = self._ensure("native_balance", kwargs, int) + self.collateral_balance: int = self._ensure("collateral_balance", kwargs, int) + self.mech_cost: int = self._ensure("mech_cost", kwargs, int) + self.pool_fee: int = self._ensure("pool_fee", kwargs, int) + self.sep: str = self._ensure("sep", kwargs, str) + self.dataset_filename: Path = Path( + self._ensure("dataset_filename", kwargs, str) + ) + self.question_field: str = self._ensure("question_field", kwargs, str) + self.question_id_field: str = self._ensure("question_id_field", kwargs, str) + self.answer_field: str = self._ensure("answer_field", kwargs, str) + self.p_yes_field_part: str = self._ensure("p_yes_field_part", kwargs, str) + self.p_no_field_part: str = self._ensure("p_no_field_part", kwargs, str) + self.confidence_field_part: str = self._ensure( + "confidence_field_part", kwargs, str + ) + # this is the mode for the p and confidence parts + # if the flag is `True`, then the field parts are used as prefixes, otherwise as suffixes + self.part_prefix_mode: bool = self._ensure("part_prefix_mode", kwargs, bool) + self.bet_amount_field: str = self._ensure("bet_amount_field", kwargs, str) + self.results_filename: Path = Path( + self._ensure("results_filename", kwargs, str) + ) + self.randomness: str = self._ensure("randomness", kwargs, str) + self.nr_mech_calls: int = self._ensure("nr_mech_calls", kwargs, int) + super().__init__(*args, **kwargs) diff --git a/packages/valory/skills/market_manager_abci/skill.yaml b/packages/valory/skills/market_manager_abci/skill.yaml index 0dbc76046..bb62eb6c3 100644 --- a/packages/valory/skills/market_manager_abci/skill.yaml +++ b/packages/valory/skills/market_manager_abci/skill.yaml @@ -8,8 +8,8 @@ aea_version: '>=1.0.0, <2.0.0' fingerprint: README.md: bafybeie6miwn67uin3bphukmf7qgiifh4xtm42i5v3nuyqxzxtehxsqvcq __init__.py: bafybeigrtedqzlq5mtql2ssjsdriw76ml3666m4e2c3fay6vmyzofl6v6e - behaviours.py: bafybeicutmw6uwldyrcr6vtcmdxioaja4n64cvzceccbeprgobw5mnei7a - bets.py: bafybeibx3x5nasuj6loneeat2lb7fr7kgsmnz7on7f4gxfbpzerzdvawou + behaviours.py: bafybeigxe7d66msaddai6zkgjtukve3zkciav4kw6qs32jathzxjjpvea4 + bets.py: bafybeid3tzd3ikwdcyplltxttycrv3bixhxuxv56p3bfpru6gzigpoeu4i dialogues.py: bafybeiebofyykseqp3fmif36cqmmyf3k7d2zbocpl6t6wnlpv4szghrxbm fsm_specification.yaml: bafybeic5cvwfbiu5pywyp3h5s2elvu7jqdrcwayay7o3v3ow47vu2jw53q graph_tooling/__init__.py: bafybeigzo7nhbzafyq3fuhrlewksjvmzttiuk4vonrggtjtph4rw4ncpk4 @@ -22,7 +22,7 @@ fingerprint: graph_tooling/requests.py: bafybeibjyb6av33aswnptttekj6t7k7xysgphh2bigoorcgkc54y2j3xkm graph_tooling/utils.py: bafybeig5hxhnqgyfn5ym3poc5nziqwpeozqbd6wa4s6c2hjn6iyedg3t3y handlers.py: bafybeihot2i2yvfkz2gcowvt66wdu6tkjbmv7hsmc4jzt4reqeaiuphbtu - models.py: bafybeiei6kyz44z2juokg6moaadg54xnkaxbtqxm4swvrfcqbofhk73ali + models.py: bafybeicqsuhtzernjqwdiwy6gbfvtv4ashlxsfutnqldivxc5iufgk7sbu payloads.py: bafybeicfymvvtdpkcgmkvthfzmb7dqakepkzslqrz6rcs7nxkz7qq3mrzy rounds.py: bafybeibqqq3vjotaasc67olhlqthka6e6refodguntkmpksgdbqlzme73a tests/__init__.py: bafybeigaewntxawezvygss345kytjijo56bfwddjtfm6egzxfajsgojam4 @@ -151,6 +151,33 @@ models: the_graph_payment_required_error: payment required for subsequent requests for this API key class_name: MarketManagerParams + benchmarking_mode: + args: + enabled: false + native_balance: 10000000000000000000 + collateral_balance: 10000000000000000000 + mech_cost: 10000000000000000 + pool_fee: 20000000000000000 + outcome_token_amounts: + - 11000000000000000000 + - 9000000000000000000 + outcome_token_marginal_prices: + - 0.4 + - 0.6 + sep: ',' + dataset_filename: benchmark_data.csv + question_field: question + question_id_field: question_id + answer_field: answer + p_yes_field_part: p_yes_ + p_no_field_part: p_no_ + confidence_field_part: confidence_ + part_prefix_mode: true + bet_amount_field: collateral_amount + results_filename: benchmarking_results.csv + randomness: benchmarking_randomness + nr_mech_calls: 60 + class_name: BenchmarkingMode network_subgraph: args: api_id: network diff --git a/packages/valory/skills/trader_abci/models.py b/packages/valory/skills/trader_abci/models.py index ecbb359ff..09a7b96a6 100644 --- a/packages/valory/skills/trader_abci/models.py +++ b/packages/valory/skills/trader_abci/models.py @@ -33,9 +33,6 @@ from packages.valory.skills.decision_maker_abci.models import ( AgentToolsSpecs as DecisionMakerAgentToolsSpecs, ) -from packages.valory.skills.decision_maker_abci.models import ( - BenchmarkingMode as BaseBenchmarkingMode, -) from packages.valory.skills.decision_maker_abci.models import ( ConditionalTokensSubgraph as DecisionMakerConditionalTokensSubgraph, ) @@ -52,6 +49,9 @@ from packages.valory.skills.decision_maker_abci.rounds import ( Event as DecisionMakerEvent, ) +from packages.valory.skills.market_manager_abci.models import ( + BenchmarkingMode as BaseBenchmarkingMode, +) from packages.valory.skills.market_manager_abci.models import ( NetworkSubgraph as MarketManagerNetworkSubgraph, ) diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index b1ae7a337..1c0ef531a 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -13,7 +13,7 @@ fingerprint: dialogues.py: bafybeihouxm2nl2r6h3vlymmtrge43tcnwphtzhc2q3vludpgytigggguy fsm_specification.yaml: bafybeid6u6esbfsahu3xqcgkpbsfhffghc3jgizgmzqbc4ww7wtjbkhuay handlers.py: bafybeigrqsgqupy6kds2vqieacsymx3eucntwl52rlgi4cu4lrb6bglhti - models.py: bafybeiaf53hymwsqtvhm3bugly37id3hqitq5zyjjinvrhlbbl2aqedqiu + models.py: bafybeie342ympii4zkf6cp5n7tfnwql2ftdodfwlwzgiivi43iyqia37vy tests/__init__.py: bafybeiadatapyjh3e7ucg2ehz77oms3ihrbutwb2cs2tkjehy54utwvuyi tests/tests_handlers.py: bafybeifxvd63qblqpsmyvj7k4dbqubab2pshao5zd2zs2srs7rt32zvciu fingerprint_ignore_patterns: [] @@ -26,9 +26,9 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeigebq46oqz2mx2iajupr6p5pgm6z5pvfye5w6zypsseuqtvta7b4a - valory/transaction_settlement_abci:0.1.0:bafybeifkftgkyzrxwxjdyqixpp7vk6aqmufikalmwx3kydtlg74tonu47u - valory/termination_abci:0.1.0:bafybeieurwmfernodqyczj5ertsgfbjtjnrlgvte7sli4sajnbopty7inu -- valory/market_manager_abci:0.1.0:bafybeid75ggv2pk22gtf6ae5prtwlahmgkxjla3tgw5mykn7agcndrbs5e -- valory/decision_maker_abci:0.1.0:bafybeiexu6ttsv6gqlwsxbn5zoq4fgjboiq5v65q3fwlamsxabha2xjihq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeictbhf3hittfibpo6hr2435y4gtvppgmg4uu4d2xpudw3z2ek5hgm +- valory/market_manager_abci:0.1.0:bafybeihmyqkzl3bm5zvjnc4auj32qjf3pk73scyq7mntmpsudqnisb4gey +- valory/decision_maker_abci:0.1.0:bafybeigehrtalp3ppnog25yuvfcdt3gmrgvxb2zm2zyngxxfcvps2s3tza +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeih2s2dwnyxm7xhd3knc3wlaejzyvfulxkipwnidmzxgx7t3ofqbpq - valory/staking_abci:0.1.0:bafybeial5xtgzf37e2khvdrc2q2wa2xhirjwioi2szwvcgtupidjxhg7tq - valory/check_stop_trading_abci:0.1.0:bafybeid7l74lmjnkeerkbvwhoo2l4cawb7c545rhcx3mjpsjux4zwy5wpm - valory/mech_interact_abci:0.1.0:bafybeif2tpz2zet6p4z4vi3b254oxzyyzoe5tehj3me3znzt7h7otkpd54 @@ -279,6 +279,7 @@ models: bet_amount_field: collateral_amount results_filename: benchmarking_results.csv randomness: benchmarking_randomness + nr_mech_calls: 60 class_name: BenchmarkingMode acc_info_fields: args: diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index c00af7766..a0e1b7197 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:bafybeihmqzcbj6t7vxz2aehd5726ofnzsfjs5cwlf42ro4tn6i34cbfrc4 skills: - valory/abstract_round_abci:0.1.0:bafybeia27qmw6w5ds5fcrpj2475brnz742aampe3sgochloijs2l7jovai -- valory/decision_maker_abci:0.1.0:bafybeiexu6ttsv6gqlwsxbn5zoq4fgjboiq5v65q3fwlamsxabha2xjihq +- valory/decision_maker_abci:0.1.0:bafybeigehrtalp3ppnog25yuvfcdt3gmrgvxb2zm2zyngxxfcvps2s3tza - valory/staking_abci:0.1.0:bafybeial5xtgzf37e2khvdrc2q2wa2xhirjwioi2szwvcgtupidjxhg7tq - valory/mech_interact_abci:0.1.0:bafybeif2tpz2zet6p4z4vi3b254oxzyyzoe5tehj3me3znzt7h7otkpd54 behaviours: