use optionstratlib::model::types::ExpirationDate; use optionstratlib::model::types::PositiveF64; use optionstratlib::pos; use optionstratlib::strategies::base::Strategies; use optionstratlib::strategies::iron_condor::IronCondor; use optionstratlib::utils::logger::setup_logger; use optionstratlib::visualization::utils::Graph; use std::error::Error; use tracing::info; fn main() -> Result<(), Box> { setup_logger(); let underlying_price = pos!(2646.9); let strategy = IronCondor::new( "GOLD".to_string(), underlying_price, // underlying_price pos!(2725.0), // short_call_strike pos!(2560.0), // short_put_strike pos!(2800.0), // long_call_strike pos!(2500.0), // long_put_strike ExpirationDate::Days(30.0), 0.1548, // implied_volatility 0.05, // risk_free_rate 0.0, // dividend_yield pos!(2.0), // quantity 38.8, // premium_short_call 30.4, // premium_short_put 23.3, // premium_long_call 16.8, // premium_long_put 0.96, // open_fee 0.96, // close_fee ); let price_range = strategy.best_range_to_show(pos!(1.0)).unwrap(); let range = strategy.break_even_points[1] - strategy.break_even_points[0]; info!("Title: {}", strategy.title()); info!("Break Even Points: {:?}", strategy.break_even_points); info!( "Net Premium Received: ${:.2}", strategy.net_premium_received() ); info!("Max Profit: ${:.2}", strategy.max_profit()); info!("Max Loss: ${:.2}", strategy.max_loss()); info!("Total Fees: ${:.2}", strategy.fees()); info!( "Range of Profit: ${:.2} {:.2}%", range, (range / 2.0) / underlying_price * 100.0 ); info!("Profit Area: {:.2}%", strategy.profit_area()); // Generate the profit/loss graph strategy.graph( &price_range, "Draws/Strategy/iron_condor_profit_loss_chart.png", 20, (1400, 933), )?; Ok(()) }