Skip to main content

run_options

Function run_options 

Source
pub fn run_options(
    name: &str,
    trades: &[Trade],
    calendar: &[NaiveDate],
    start: usize,
    end: usize,
    capital: f64,
    risk_frac: f64,
    max_open: usize,
    contract_loss: Option<&(dyn Fn(&Trade) -> f64 + Sync)>,
) -> Run
Expand description

Size option trades into an account: each trade may lose at most risk_frac of equity at entry, at most max_open at once (later ones are skipped).

contract_loss, when given, is the real-dollar maximum loss of one contract (100 shares at the price actually printed that day). Then the book buys whole contracts only: floor(budget / contract_loss), and a trade it cannot afford a single contract of is skipped. This is what makes a $5,000 account different from a $1,000,000 one.