diff --git a/src/bots.rs b/src/bots.rs index af71b5f..2f5c1e4 100644 --- a/src/bots.rs +++ b/src/bots.rs @@ -5,6 +5,7 @@ use log::{debug, info, warn}; use tokio::sync::broadcast::Receiver; use crate::manifold_types; +use crate::market_handler; #[async_trait] pub trait Bot { @@ -44,6 +45,25 @@ impl ArbitrageBot { } tot_prob } + + fn bet_amount(&self) -> f64 { + let mut bet_map: HashMap = HashMap::new(); + let inverse_sum: f64 = self.answers.values().map(|a| 1.0 / a.probability).sum(); + + for answer in self.answers.values() { + let bb = manifold_types::BotBet { + amount: 100. * (1. / answer.probability) / inverse_sum, + contract_id: self.market.lite_market.id.clone(), + outcome: manifold_types::MarketOutcome::Other(answer.id.clone()), + }; + bet_map.insert(answer.id.clone(), bb); + }; + info!("BET MAP{:?}", bet_map); + + assert!((bet_map.values().map(|bb| bb.amount).sum::() - 100.).abs() < 1e-5, "sum of bets {} != 100", bet_map.values().map(|bb| bb.amount).sum::()); + + 0. + } } #[async_trait] @@ -57,6 +77,7 @@ impl Bot for ArbitrageBot { } else { info!("NOT ARB OPPORTUNITY {tot_prob}"); } + self.bet_amount(); let mut i: u64 = 0; loop { @@ -93,6 +114,8 @@ impl Bot for ArbitrageBot { info!("NOT ARB OPPORTUNITY {tot_prob}"); } + self.bet_amount(); + i += 1; } Err(e) => { diff --git a/src/main.rs b/src/main.rs index 81173ce..92250bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,13 +17,13 @@ async fn main() { assert!(market_handler.check_alive().await, "Manifold API is down"); - let whoami = market_handler.whoami().await; + let me = market_handler.whoami().await; - info!("Logged in as {} (balance {})", whoami.name, whoami.balance); + info!("Logged in as {} (balance {})", me.name, me.balance); let arb_market = { let market = market_handler - .market_search("How many Twitter followers will @Mira have? (unlinked)".to_string()); + .market_search("Which video game confirmed for released in Q1 2024 will average the highest score on Opencritic.com by 4/1/24?".to_string()); match market.await { Ok(market) => market, @@ -39,7 +39,7 @@ async fn main() { serde_json::to_string_pretty(&arb_market).unwrap() ); - let mut bot = ArbitrageBot::new(arb_market.clone()); + let mut bot = ArbitrageBot::new(me.clone(), arb_market.clone()); let rx = market_handler .get_bet_stream_for_market_id(arb_market.lite_market.id)