Skip to main content

rustrade_execution/
short_option.rs

1//! What a simulated venue holds against a short option.
2
3use rust_decimal::Decimal;
4use rustrade_instrument::asset::name::AssetNameExchange;
5use serde::{Deserialize, Serialize};
6
7/// How much quote a short put holds on the
8/// [`SimulatedVenue`](crate::exchange::mock::SimulatedVenue), which takes only fully secured
9/// shorts: a put written against cash set aside to buy the underlying at the strike if it is
10/// assigned. See its `# How an option is accounted`.
11///
12/// Brokers differ on whether the premium the sale receives counts towards that cash. A short call
13/// holds the underlying it would deliver, which the premium cannot pay for, so this setting does
14/// not apply to it.
15#[non_exhaustive]
16#[derive(
17    Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Deserialize, Serialize,
18)]
19pub enum ShortPutCollateral {
20    /// The account must hold `strike × quantity × contract_size` of quote before the sale, and
21    /// the premium it receives does not count towards it. The default, and the stricter rule:
22    /// a cash-secured put as the options clearing house's risk disclosure defines it, and as
23    /// Interactive Brokers holds it in a cash account.
24    #[default]
25    Strike,
26    /// The premium the sale receives counts towards the strike, so the account needs only
27    /// `strike × quantity × contract_size` less that premium beforehand. Alpaca holds a
28    /// cash-secured put this way. A limit sale resting on the book holds the strike less the
29    /// premium at its limit price, and gives back what a better fill does not need.
30    StrikeLessPremium,
31}
32
33/// What a short option position holds as collateral on the
34/// [`SimulatedVenue`](crate::exchange::mock::SimulatedVenue): `amount` of `asset`, kept out of that
35/// asset's `free` balance and still in its `total`. A put holds quote, the strike it would pay; a
36/// call holds base, the underlying it would deliver.
37#[non_exhaustive]
38#[derive(Debug, Clone, PartialEq, Eq, Hash)]
39pub struct Collateral {
40    /// The asset held.
41    pub asset: AssetNameExchange,
42    /// How much of it is held.
43    pub amount: Decimal,
44}