-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove cap on bet amount for microchain agent #239
Conversation
WalkthroughThe recent modifications to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant MicrochainAgent
participant GetKellyBet
User->>MicrochainAgent: Call with amount
MicrochainAgent-->>User: Processed amount (no max limit check)
User->>GetKellyBet: Request optimal bet
GetKellyBet-->>User: Returns calculated bet size
This diagram illustrates the simplified interaction between a user and the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- prediction_market_agent/agents/microchain_agent/functions.py (2 hunks)
Additional comments not posted (3)
prediction_market_agent/agents/microchain_agent/functions.py (3)
Line range hint
14-14
: The removal of theMAX_AMOUNT
attribute simplifies theMicrochainAgent
class.
Line range hint
15-15
: The updateddescription
property correctly reflects the removal of the bet amount cap.
Line range hint
16-16
: Ensure that the removal of the maximum amount check in the__call__
method does not introduce any unintended consequences.Verification successful
The search for
MAX_AMOUNT
did not produce any results, indicating that there are no remaining references toMAX_AMOUNT
in the codebase. This suggests that the removal of the maximum amount check in the__call__
method does not affect other parts of the system.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the removal of the maximum amount check does not affect other parts of the system. # Test: Search for any remaining references to `MAX_AMOUNT`. Expect: No occurrences. rg --type python $'MAX_AMOUNT'Length of output: 60
Script:
#!/bin/bash # Description: Verify that the removal of the maximum amount check does not affect other parts of the system. # Test: Search for any remaining references to `MAX_AMOUNT`. Expect: No occurrences. rg --type py $'MAX_AMOUNT'Length of output: 25
@@ -160,9 +160,6 @@ def __init__(self, market_type: MarketType, outcome: str): | |||
) | |||
self.user_address = APIKeys().bet_from_address | |||
|
|||
# Prevent the agent from spending recklessly! | |||
self.MAX_AMOUNT = 0.1 if market_type == MarketType.OMEN else 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YOLOOO
Results from testing the agent without the cap:
I'll try changing the default trader-agent prompt and see if this helps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
prediction_market_agent/agents/microchain_agent/market_functions.py (1)
Line range hint
14-19
:
Consider adding safeguards or warnings for large bet amounts.The removal of the cap on bet amounts can lead to excessive betting. Consider adding safeguards or warnings for large bet amounts to prevent rapid depletion of the agent's wallet.
+ # Add a warning for large bet amounts + LARGE_BET_THRESHOLD = 10.0 # Example threshold, adjust as needed + if amount > LARGE_BET_THRESHOLD: + print(f"Warning: You are placing a large bet of {amount} {self.currency}.")
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- prediction_market_agent/agents/microchain_agent/market_functions.py (1 hunks)
Additional comments not posted (1)
prediction_market_agent/agents/microchain_agent/market_functions.py (1)
Line range hint
14-19
:
Verify the removal of the cap on bet amount.The
MAX_AMOUNT
attribute and associated logic have been removed, allowing for unrestricted bet amounts.
Fixed by adding a new MarketFunction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (1)
- prediction_market_agent/agents/microchain_agent/market_functions.py (4 hunks)
Additional comments not posted (5)
prediction_market_agent/agents/microchain_agent/market_functions.py (5)
382-383
: ClassGetKellyBet
added.The new class
GetKellyBet
implements functionality for calculating the optimal bet size using the Kelly Criterion.
384-389
: Description property is well-defined.The description property provides a clear and concise explanation of the class's functionality.
392-393
: Example arguments property is well-defined.The example arguments property provides a clear example of the expected input arguments.
395-409
: Verify the correctness of the__call__
method.The
__call__
method calculates the bet amount using the Kelly Criterion. Ensure that the logic is correct and that the method integrates well with the rest of the codebase.
Line range hint
411-424
:
Ensure the removal ofMAX_AMOUNT
does not introduce issues.The
MAX_AMOUNT
attribute and associated logic have been removed. Verify that this change does not introduce any issues and that the class functions correctly without it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (2)
- prediction_market_agent/agents/microchain_agent/market_functions.py (4 hunks)
- tests/agents/microchain/test_functions.py (2 hunks)
Additional comments not posted (3)
tests/agents/microchain/test_functions.py (1)
195-198
: LGTM!The
test_kelly_bet
function correctly tests theGetKellyBet
class by verifying that the bet size is zero when there is no edge.prediction_market_agent/agents/microchain_agent/market_functions.py (2)
382-411
: LGTM!The
GetKellyBet
class correctly implements the Kelly Criterion to calculate the optimal bet size and direction. The properties for description and example arguments are well-defined.
426-426
: LGTM!The removal of the
MAX_AMOUNT
attribute and related logic from theMicrochainAgent
class aligns with the PR objective of allowing unrestricted bet amounts. The description property has been updated accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
poetry.lock
is excluded by!**/*.lock
,!**/*.lock
pyproject.toml
is excluded by!**/*.toml
Files selected for processing (1)
- prediction_market_agent/agents/microchain_agent/market_functions.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
- prediction_market_agent/agents/microchain_agent/market_functions.py
Just removing the bet cap meant the agent would still sometimes place very large bets (i.e. its full wallet!). I've added a new function,
GetKellyBet
. It looks like this is enough to get the agent to bet less rashly, but also more optimally.