Skip to content
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

Add max_price_impact parameter to KellyBettingStrategy #433

Merged
merged 44 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
4bfc702
WIP
gabrielfior Sep 24, 2024
2c8389a
Added Slippage-based Kelly strategy
gabrielfior Sep 25, 2024
c9c198a
Fixing PR
gabrielfior Sep 25, 2024
5333d1d
Removed file
gabrielfior Sep 25, 2024
195f019
Removed another file
gabrielfior Sep 25, 2024
fd741d4
Removed omen corrections
gabrielfior Sep 25, 2024
f7dc54b
WIP
gabrielfior Sep 26, 2024
9b6aaa7
Payouts increased
gabrielfior Sep 27, 2024
337df5e
Merge remote-tracking branch 'refs/remotes/origin/main' into gabriel/…
gabrielfior Sep 27, 2024
c17790d
Added tests for kelly slippage | PR comments
gabrielfior Sep 27, 2024
a6804a3
WIP
gabrielfior Sep 30, 2024
ac99ce1
Fetching bets with more error checking
gabrielfior Sep 30, 2024
bda388b
Fix examples/monitor/match_bets_with_langfuse_traces.py
evangriffiths Oct 1, 2024
752c3be
tidy
evangriffiths Oct 1, 2024
6c67f15
Review comment
evangriffiths Oct 1, 2024
f6a7499
Change match_bets_with_langfuse_traces.py to calculate p_yes MSE for …
evangriffiths Oct 1, 2024
0a01259
Removed dotenv
gabrielfior Oct 1, 2024
7a04ea6
Merge remote-tracking branch 'refs/remotes/origin/evan/fix-examples/m…
gabrielfior Oct 1, 2024
d13f235
Print correlation of p_yes mse with profit
evangriffiths Oct 1, 2024
55d90a6
Merge remote-tracking branch 'refs/remotes/origin/main' into gabriel/…
gabrielfior Oct 1, 2024
4b1a6d2
Sorting output file
gabrielfior Oct 1, 2024
297a0bf
Update prediction_market_agent_tooling/deploy/betting_strategy.py
gabrielfior Oct 1, 2024
5ba66b5
Update prediction_market_agent_tooling/deploy/betting_strategy.py
gabrielfior Oct 1, 2024
572b943
Merge remote-tracking branch 'refs/remotes/origin/evan/get_p_yes_mse'…
gabrielfior Oct 1, 2024
ba2afcd
Avoided price_impact warnings
gabrielfior Oct 1, 2024
dabcc23
Update prediction_market_agent_tooling/deploy/betting_strategy.py
gabrielfior Oct 1, 2024
1a3f362
Removed load_dotenv
gabrielfior Oct 1, 2024
625d012
Merge remote-tracking branch 'origin/gabriel/track-experiments-kelly'…
gabrielfior Oct 1, 2024
5e04adf
Tidy
gabrielfior Oct 1, 2024
3ccb430
Update .env.example
gabrielfior Oct 2, 2024
b7cd215
Implemented PR comments
gabrielfior Oct 2, 2024
321cff8
Switched back betting strategy to agreed upon impl
gabrielfior Oct 2, 2024
efa1909
Fixed mypy
gabrielfior Oct 2, 2024
06be0d6
Improved mypy removing ifs
gabrielfior Oct 2, 2024
79fca0c
Final mypy improvements
gabrielfior Oct 2, 2024
04ec90d
Merge remote-tracking branch 'refs/remotes/origin/main' into gabriel/…
gabrielfior Oct 2, 2024
b8884de
Moved test | refactored Yes,No
gabrielfior Oct 3, 2024
6b7b6a7
Importing logger from loggers and not loguru
gabrielfior Oct 3, 2024
83349d4
Made minimize_scalar bounds more robust
gabrielfior Oct 3, 2024
22e4028
Merge remote-tracking branch 'refs/remotes/origin/main' into gabriel/…
gabrielfior Oct 3, 2024
6f014a6
Small changes after merge
gabrielfior Oct 3, 2024
d3f5c04
Removed incorrect slippage mentions
gabrielfior Oct 3, 2024
74d524e
Refactored assert from betting stategy into integration test
gabrielfior Oct 3, 2024
8cd4818
Small fix test
gabrielfior Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions examples/monitor/match_bets_with_langfuse_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
from prediction_market_agent_tooling.config import APIKeys
from prediction_market_agent_tooling.deploy.betting_strategy import (
BettingStrategy,
KellyBettingStrategy,
MaxAccuracyBettingStrategy,
MaxAccuracyWithKellyScaledBetsStrategy,
MaxExpectedValueBettingStrategy,
ProbabilisticAnswer,
TradeType,
KellyMaxSlippageBettingStrategy,
MaxExpectedValueBettingStrategy,
MaxAccuracyWithKellyScaledBetsStrategy,
KellyBettingStrategy,
MaxAccuracyBettingStrategy,
)
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
Expand Down Expand Up @@ -84,16 +85,18 @@ def get_outcome_for_trace(
# Get the private keys for the agents from GCP Secret Manager
agent_gcp_secret_map = {
"DeployablePredictionProphetGPT4TurboFinalAgent": "pma-prophetgpt4turbo-final",
"DeployablePredictionProphetGPT4TurboPreviewAgent": "pma-prophetgpt4",
"DeployablePredictionProphetGPT4oAgent": "pma-prophetgpt3",
"DeployableOlasEmbeddingOAAgent": "pma-evo-olas-embeddingoa",
# "DeployablePredictionProphetGPT4TurboPreviewAgent": "pma-prophetgpt4",
# "DeployablePredictionProphetGPT4oAgent": "pma-prophetgpt3",
# "DeployableOlasEmbeddingOAAgent": "pma-evo-olas-embeddingoa",
# "DeployableThinkThoroughlyAgent": "pma-think-thoroughly", # no bets!
# "DeployableThinkThoroughlyProphetResearchAgent": "pma-think-thoroughly-prophet-research", # no bets!
"DeployableKnownOutcomeAgent": "pma-knownoutcome",
# "DeployableKnownOutcomeAgent": "pma-knownoutcome",
}

agent_pkey_map = {
k: get_private_key_from_gcp_secret(v) for k, v in agent_gcp_secret_map.items()
}

# Define strategies we want to test out
strategies = [
MaxAccuracyBettingStrategy(bet_amount=1),
Expand All @@ -108,6 +111,19 @@ def get_outcome_for_trace(
MaxExpectedValueBettingStrategy(bet_amount=1),
MaxExpectedValueBettingStrategy(bet_amount=2),
MaxExpectedValueBettingStrategy(bet_amount=25),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.01),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.05),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.1),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.15),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.2),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.25),
KellyMaxSlippageBettingStrategy(max_bet_amount=2, max_slippage=0.3),
KellyMaxSlippageBettingStrategy(max_bet_amount=5, max_slippage=0.1),
KellyMaxSlippageBettingStrategy(max_bet_amount=5, max_slippage=0.15),
KellyMaxSlippageBettingStrategy(max_bet_amount=5, max_slippage=0.2),
KellyMaxSlippageBettingStrategy(max_bet_amount=25, max_slippage=0.1),
KellyMaxSlippageBettingStrategy(max_bet_amount=25, max_slippage=0.15),
KellyMaxSlippageBettingStrategy(max_bet_amount=25, max_slippage=0.2),
]

print("# Agent Bet vs Simulated Bet Comparison")
Expand Down Expand Up @@ -145,16 +161,17 @@ def get_outcome_for_trace(
# All bets should have a trace, but not all traces should have a bet
# (e.g. if all markets are deemed unpredictable), so iterate over bets
bets_with_traces: list[ResolvedBetWithTrace] = []
missing_bets = []
for bet in bets:
trace = get_trace_for_bet(bet, process_market_traces)
if trace:
bets_with_traces.append(ResolvedBetWithTrace(bet=bet, trace=trace))
else:
missing_bets.append(bet)

print(f"Number of bets since {start_time}: {len(bets_with_traces)}\n")
if len(bets_with_traces) != len(bets):
raise ValueError(
f"{len(bets) - len(bets_with_traces)} bets do not have a corresponding trace"
)
if missing_bets:
print(f"Bets without traces : {missing_bets}")

simulations: list[dict[str, Any]] = []

Expand Down Expand Up @@ -207,4 +224,6 @@ def get_outcome_for_trace(
}
)

print(pd.DataFrame.from_records(simulations).to_markdown(index=False))
simulations_df = pd.DataFrame.from_records(simulations)
simulations_df.to_csv("simulations.csv")
print(simulations_df.to_markdown(index=False))
Loading