Skip to content

Commit

Permalink
fix: bet vs rebet logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantios committed Nov 19, 2024
1 parent 81d8df3 commit 3372153
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3372153

Please sign in to comment.