diff --git a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py index dc14cb64..b6fd79ba 100644 --- a/packages/valory/skills/decision_maker_abci/behaviours/sampling.py +++ b/packages/valory/skills/decision_maker_abci/behaviours/sampling.py @@ -75,6 +75,11 @@ def processable_bet(self, bet: Bet) -> bool: ) within_ranges = within_opening_range and within_safe_range + # rebetting is allowed only if we have already placed at least one bet in this market. + # conversely, if we should not rebet, no bets should have been placed in this market. + if self.should_rebet ^ bool(bet.n_bets): + return False + # if we should not rebet, we have all the information we need if not self.should_rebet: # the `has_liquidity_changed` check is dangerous; this can result in a bet never being processed @@ -86,10 +91,6 @@ def processable_bet(self, bet: Bet) -> bool: # 5. the market is never selected again, and therefore a bet is never placed on it return within_ranges and self.has_liquidity_changed(bet) - # if we should rebet, we should have at least one bet processed in the past - if not bool(bet.n_bets): - return False - # create a filter based on whether we can rebet or not lifetime = bet.openingTimestamp - now t_rebetting = (lifetime // UNIX_WEEK) + UNIX_DAY