Skip to main content

Position

Struct Position 

Source
pub struct Position {
    pub option: Options,
    pub premium: Positive,
    pub date: DateTime<Utc>,
    pub open_fee: Positive,
    pub close_fee: Positive,
    pub epic: Option<String>,
    pub extra_fields: Option<Value>,
}
Expand description

The Position struct represents a financial position in an options market.

This structure encapsulates all the necessary information to track an options position, including the underlying option details, costs associated with the position, and the date when the position was opened. It provides methods for analyzing profitability, time metrics, and position characteristics.

§Examples

use optionstratlib::{Options, Side, OptionStyle};
use positive::pos_or_panic;
use chrono::Utc;
use tracing::info;
use optionstratlib::model::Position;
use optionstratlib::model::utils::create_sample_option_simplest;

let option = create_sample_option_simplest(OptionStyle::Call, Side::Long);
let position = Position::new(
    option,
    pos_or_panic!(5.25),           // premium per contract
    Utc::now(),           // position open date
    pos_or_panic!(0.65),           // opening fee per contract
    pos_or_panic!(0.65),           // closing fee per contract
    None,
    None,
);

let total_cost = position.total_cost()?;
info!("Total position cost: {}", total_cost);

Fields§

§option: Options

The detailed options contract information, including the type, strike price, expiration, underlying asset details, and other option-specific parameters.

§premium: Positive

The premium paid or received per contract. For long positions, this represents the cost per contract; for short positions, this is the credit received.

§date: DateTime<Utc>

The date and time when the position was opened, used for calculating time-based metrics like days held and days to expiration.

§open_fee: Positive

The fee paid to open the position per contract. This typically includes broker commissions and exchange fees.

§close_fee: Positive

The fee that will be paid to close the position per contract. This is used in profit/loss calculations to account for all transaction costs.

§epic: Option<String>

Identifier for the position in an external system or platform

§extra_fields: Option<Value>

Additional custom data fields for the position stored as JSON

Implementations§

Source§

impl Position

Source

pub fn new( option: Options, premium: Positive, date: DateTime<Utc>, open_fee: Positive, close_fee: Positive, epic: Option<String>, extra_fields: Option<Value>, ) -> Self

Creates a new options position.

This constructor initializes a new Position instance representing an options trade, capturing all essential information for position tracking and analysis.

§Parameters
  • option - The options contract details including type (call/put), strike price, expiration date, underlying asset information, and other option parameters.

  • premium - The premium paid (for long positions) or received (for short positions) per contract, represented as a positive value.

  • date - The timestamp when the position was opened, used for calculating time-based metrics like days to expiration and position duration.

  • open_fee - The transaction costs paid to open the position per contract, including broker commissions and exchange fees.

  • close_fee - The anticipated transaction costs to close the position per contract, used for accurate profit/loss calculations.

§Returns

Returns a new Position instance containing the provided information.

§Examples
use optionstratlib::{Options, Side, OptionStyle};
use positive::pos_or_panic;
use chrono::Utc;
use optionstratlib::model::Position;
use optionstratlib::model::utils::create_sample_option_simplest;

let option = create_sample_option_simplest(OptionStyle::Call, Side::Long);
let position = Position::new(
    option,
    pos_or_panic!(5.25),           // premium per contract
    Utc::now(),           // position open date
    pos_or_panic!(0.65),           // opening fee per contract
    pos_or_panic!(0.65),           // closing fee per contract
   None,                  // epic (optional)
  None,                  // extra fields (optional)
);
Source

pub fn total_cost(&self) -> Result<Positive, PositionError>

Calculates the total cost of the position based on the option’s side and fees.

Depending on whether the position is long or short, different components contribute to the total cost calculation:

  • For a long position, the total cost includes the premium, open fee, and close fee multiplied by the option’s quantity.
  • For a short position, the total cost includes only the open fee and close fee multiplied by the option’s quantity.
§Returns

A f64 representing the total cost of the position. THE VALUE IS ALWAYS POSITIVE

§Errors

Currently infallible — long positions accumulate only non-negative Positive terms and short positions delegate to fees(), which is itself infallible under the current implementation. The Result signature is retained so future implementations that validate fee configuration or surface overflow on Positive arithmetic can return PositionError without a breaking change.

Source

pub fn premium_received(&self) -> Result<Positive, PositionError>

Calculates the premium received from an options position.

This method determines the premium amount received based on the position’s side:

  • For long positions, it returns zero as the trader pays premium (doesn’t receive any)
  • For short positions, it returns the total premium received (premium per contract × quantity)

The result is always returned as a Positive value, ensuring non-negative amounts.

§Returns
  • Result<Positive, PositionError> - A result containing the premium received as a Positive value if successful, or a PositionError if any calculation errors occur.
§Examples
use optionstratlib::{ Side, OptionStyle};
use positive::pos_or_panic;
use optionstratlib::model::Position;
use optionstratlib::model::utils::create_sample_option_simplest;
use chrono::Utc;
use tracing::info;

// Create a short position
let option = create_sample_option_simplest(OptionStyle::Call, Side::Short);
let position = Position::new(
    option,
    pos_or_panic!(5.25),  // premium per contract
    Utc::now(),  // position open date
    pos_or_panic!(0.65),  // opening fee
    pos_or_panic!(0.65),  // closing fee
   None,        // epic (optional)
  None,        // extra fields (optional)
);

// Calculate premium received
let received = position.premium_received()?;
info!("Premium received: {}", received);
§Errors

Currently infallible — long positions return Ok(Positive::ZERO) (no premium received) and short positions return Ok(self.premium * self.option.quantity). The Result signature is retained so future implementations that treat long-side calls as a programmer error, or that surface overflow on the premium × quantity product, can return PositionError without a breaking change.

Source

pub fn net_premium_received(&self) -> Result<Positive, PositionError>

Calculates the net premium received for the position.

This method determines the premium amount received after accounting for costs, which is relevant primarily for short positions. For long positions, this always returns zero as premium is paid rather than received.

For short positions, the method calculates the difference between the premium received and the total costs incurred. If this value is positive (meaning the premium exceeds the costs), it represents the maximum potential profit for the position. If negative, the position is considered invalid as it would represent a guaranteed loss.

§Returns
  • Ok(Positive) - The net premium received as a non-negative value
  • Err(PositionError) - If the position is invalid because the premium received is less than the costs, resulting in a guaranteed loss
§Errors

Propagates any PositionError raised by total_cost() (no variant is surfaced under the current implementation, but the call site keeps the ? for forward compatibility).

When the short-side net amount premium − total_cost is negative the function returns Ok(Positive::ZERO) (clamped) rather than an error, so a guaranteed-loss short position is reported as zero net received rather than as a failure.

Source

pub fn pnl_at_expiration( &self, price: &Option<&Positive>, ) -> Result<Decimal, PricingError>

Calculates the profit and loss (PnL) at the option’s expiration.

This function determines the total profit or loss that would be realized when the option position expires, taking into account the intrinsic value at expiration, the cost to establish the position, and any premiums received.

§Arguments
  • price - An optional reference to a positive decimal value representing the underlying asset price at expiration. If None is provided, the calculation will use the current underlying price stored in the option.
§Returns
  • Result<Decimal, PricingError> - The calculated profit or loss as a Decimal value, or an error if the calculation fails.
§Examples
// Assuming position is a properly initialized Position
use chrono::Utc;
use optionstratlib::model::utils::create_sample_option_simplest;
use optionstratlib::{OptionStyle, Side};
use positive::pos_or_panic;
use optionstratlib::model::Position;

let option = create_sample_option_simplest(OptionStyle::Call, Side::Short);
let position = Position::new(
    option,
    pos_or_panic!(5.25),  // premium per contract
    Utc::now(),  // position open date
    pos_or_panic!(0.65),  // opening fee
    pos_or_panic!(0.65),  // closing fee
   None,        // epic (optional)
  None,        // extra fields (optional)
);
let current_price = pos_or_panic!(105.0);

// Calculate PnL at expiration with specified price
let pnl_specific = position.pnl_at_expiration(&Some(&current_price))?;

// Calculate PnL at expiration using the option's current underlying price
let pnl_current = position.pnl_at_expiration(&None)?;
§Errors

Propagates any OptionsError returned by the underlying payoff evaluation (Options::intrinsic_value or Options::payoff), wrapped as PricingError::OptionError.

Source

pub fn unrealized_pnl(&self, price: Positive) -> Result<Decimal, PositionError>

Calculates the unrealized profit and loss (PnL) for an options position at a given price.

This method computes the current theoretical profit or loss of the position if it were to be closed at the specified price, taking into account the premium paid/received and all transaction fees (both opening and closing fees).

The calculation differs based on the position side:

  • For long positions: (current_price - premium - open_fee - close_fee) * quantity
  • For short positions: (premium - current_price - open_fee - close_fee) * quantity
§Parameters
  • price - A Positive value representing the current price of the option
§Returns
  • Result<Decimal, PositionError> - The calculated unrealized PnL as a Decimal if successful, or a PositionError if the calculation fails
§Example
use chrono::Utc;
use tracing::info;
use optionstratlib::model::Position;
use optionstratlib::model::utils::create_sample_option_simplest;
use optionstratlib::{ OptionStyle, Side};
use positive::pos_or_panic;
let current_price = pos_or_panic!(6.50);
let option = create_sample_option_simplest(OptionStyle::Call, Side::Short);
let position = Position::new(
    option,
    pos_or_panic!(5.25),  // premium per contract
    Utc::now(),  // position open date
    pos_or_panic!(0.65),  // opening fee
    pos_or_panic!(0.65),  // closing fee
   None,        // epic (optional)
  None,        // extra fields (optional)
);
let unrealized_pnl = position.unrealized_pnl(current_price)?;
info!("Current unrealized PnL: {}", unrealized_pnl);
§Errors

Returns PositionError wrapping any PositionValidationErrorKind surfaced by the internal Black–Scholes evaluation, or PositionError::PricingError when the implied-volatility recomputation at price fails.

Source

pub fn days_held(&self) -> Result<Positive, PositionError>

Calculates the number of days the position has been held.

This method computes the difference between the current UTC date and the position’s opening date, returning the result as a Positive value.

The calculation uses Chrono’s num_days method to determine the precise number of whole days between the position’s date and current time.

§Returns
  • Ok(Positive) - The number of days the position has been held as a positive value
  • Err(PositionError) - If there’s an error during the calculation or validation
§Errors

Returns PositionError wrapping a PositionValidationErrorKind::InvalidPositionSize if the elapsed day-count is negative (future-dated open date) or cannot be represented as a Positive.

Source

pub fn days_to_expiration(&self) -> Result<Positive, PositionError>

Calculates the number of days remaining until the option expires.

This function determines the time to expiration in days based on the option’s expiration date format. It handles both explicit day counts and datetime-based expiration dates.

§Returns
  • Ok(Positive) - The number of days to expiration as a positive value
  • Err(PositionError) - If the calculation fails due to issues with the position data

For datetime-based expirations, the function calculates the difference between the expiration date and the current date, converting the result to days.

§Errors

Returns PositionError wrapping the underlying expiration_date::error::ExpirationDateError when the expiration cannot be converted (e.g. a past datetime that would produce a negative day count).

Source

pub fn is_long(&self) -> bool

Determines if the position is a long position.

This method checks the side attribute of the option to determine the directionality of the position. Long positions profit when the underlying asset’s price increases.

§Returns
  • true if the position is long
  • false if the position is short
Source

pub fn is_short(&self) -> bool

Determines if the position is a short position.

This method checks the side attribute of the option to determine the directionality of the position. Short positions profit when the underlying asset’s price decreases.

§Returns
  • true if the position is short
  • false if the position is long
Source

pub fn net_cost(&self) -> Result<Decimal, PositionError>

Calculates the net cost of the position based on the option’s side and fees.

This method calculates the net cost of a position by determining whether the position is long or short and then computing the respective costs:

  • For a long position, the net cost is equivalent to the total_cost() of the position.
  • For a short position, the net cost is calculated by subtracting the premium from the sum of the open and close fees, and then multiplying the result by the option’s quantity.
§Returns

A Decimal representing the net cost of the position. The value should be positive but if the fee is higher than the premium it will be negative in short positions

§Errors

Currently only propagates arithmetic-failure variants surfaced by the premium × quantity and fee additions; in practice infallible for all valid positions, but the Result signature is retained to let callers handle future overflow paths uniformly.

Source

pub fn break_even(&self) -> Option<Positive>

Calculates the break-even price for an options position.

This method determines the price of the underlying asset at which the position will neither make a profit nor a loss. The calculation varies based on both the side of the position (Long/Short) and the option style (Call/Put).

The break-even price is an important reference point for options traders as it represents the threshold price that the underlying asset must cross for the position to become profitable, accounting for all costs associated with the position.

§Formula by position type:
  • Long Call: Strike Price + Total Cost per Contract
  • Short Call: Strike Price + Premium - Total Cost per Contract
  • Long Put: Strike Price - Total Cost per Contract
  • Short Put: Strike Price - Premium + Total Cost per Contract
§Returns
  • Some(Positive) containing the break-even price if the position has non-zero quantity
  • None if the position has zero quantity (no contracts) or if the position total cost cannot be calculated
Source

pub fn fees(&self) -> Result<Positive, PositionError>

Calculates the total transaction fees for the position.

This method computes the sum of opening and closing fees for the position, scaled by the quantity of options contracts. These fees typically include broker commissions, exchange fees, and other transaction costs.

§Returns
  • Ok(Positive) - The total fees as a positive value
  • Err(PositionError) - If there’s an issue calculating the fees
§Errors

Currently infallible in practice; the Result signature is retained so that future fee models that can overflow Positive (e.g. tiered fee schedules multiplied by very large quantities) can surface their failures without a breaking API change.

Source

pub fn validate(&self) -> bool

Validates the position to ensure it meets all necessary conditions for trading.

This method performs a series of checks to determine if the position is valid:

  1. For short positions, verifies that:
    • Premium is greater than zero
    • Premium exceeds the sum of opening and closing fees
  2. Validates the underlying option parameters
§Returns
  • true if the position is valid and meets all conditions
  • false otherwise, with specific failure reasons logged via debug messages
§Examples
use optionstratlib::model::{Position, Options};
use optionstratlib::{Side, OptionStyle};
use positive::pos_or_panic;
use optionstratlib::model::utils::create_sample_option_simplest;
use chrono::Utc;

// Create a valid position
let option = create_sample_option_simplest(OptionStyle::Call, Side::Long);
let position = Position::new(
    option,
    pos_or_panic!(5.25),
    Utc::now(),
    pos_or_panic!(0.65),
    pos_or_panic!(0.65),
    None, // epic (optional)
   None, // extra fields (optional)
);

assert!(position.validate());

Trait Implementations§

Source§

impl BasicAble for Position

Source§

fn set_implied_volatility( &mut self, _volatility: &Positive, ) -> Result<(), StrategyError>

Updates the volatility for the strategy.

§Parameters
  • _volatility: A reference to a Positive value representing the new volatility to set.
§Returns
  • Ok(()): If the update operation succeeds (currently unimplemented).
  • Err(StrategyError): If there is an error during the update process (place-holder as functionality is not implemented).
§Notes

This method is currently unimplemented, and calling it will result in the unimplemented! macro being triggered, which causes a panic. This function is a stub and should be implemented to handle setting the volatility specific to the strategy.

Source§

fn get_title(&self) -> String

Retrieves the title associated with the current instance of the strategy. Read more
Source§

fn get_option_basic_type(&self) -> HashSet<OptionBasicType<'_>>

Retrieves a HashSet of OptionBasicType values associated with the current strategy. Read more
Source§

fn get_symbol(&self) -> &str

Retrieves the symbol associated with the current instance by delegating the call to the get_symbol method of the one_option object. Read more
Source§

fn get_strike(&self) -> HashMap<OptionBasicType<'_>, &Positive>

Retrieves a mapping of option basic types to their associated positive strike values. Read more
Source§

fn get_strikes(&self) -> Vec<&Positive>

Retrieves a vector of strike prices from the option types. Read more
Source§

fn get_side(&self) -> HashMap<OptionBasicType<'_>, &Side>

Retrieves a HashMap that maps each OptionBasicType to its corresponding Side. Read more
Source§

fn get_type(&self) -> &OptionType

Retrieves the type of the option. Read more
Source§

fn get_style(&self) -> HashMap<OptionBasicType<'_>, &OptionStyle>

Retrieves a mapping of OptionBasicType to their corresponding OptionStyle. Read more
Source§

fn get_expiration(&self) -> HashMap<OptionBasicType<'_>, &ExpirationDate>

Retrieves a map of option basic types to their corresponding expiration dates. Read more
Source§

fn get_implied_volatility(&self) -> HashMap<OptionBasicType<'_>, &Positive>

Retrieves the implied volatility for the current strategy. Read more
Source§

fn get_quantity(&self) -> HashMap<OptionBasicType<'_>, &Positive>

Retrieves the quantity information associated with the strategy. Read more
Source§

fn get_underlying_price(&self) -> &Positive

Retrieves the underlying price of the financial instrument (e.g., option). Read more
Source§

fn get_risk_free_rate(&self) -> HashMap<OptionBasicType<'_>, &Decimal>

Retrieves the risk-free interest rate associated with a given set of options. Read more
Source§

fn get_dividend_yield(&self) -> HashMap<OptionBasicType<'_>, &Positive>

Retrieves the dividend yield of a financial option. Read more
Source§

fn one_option(&self) -> &Options

Retrieves a shared reference to the strategy’s primary Options value. Read more
Source§

fn one_option_mut(&mut self) -> &mut Options

Provides a mutable reference to the strategy’s primary Options value. Read more
Source§

fn set_expiration_date( &mut self, expiration_date: ExpirationDate, ) -> Result<(), StrategyError>

Sets the expiration date for the strategy. Read more
Source§

fn set_underlying_price( &mut self, _price: &Positive, ) -> Result<(), StrategyError>

Sets the underlying price for this strategy. Read more
Source§

impl Clone for Position

Source§

fn clone(&self) -> Position

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ComposeSchema for Position

Source§

impl Debug for Position

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Position

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Position

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Position

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Position> for Leg

Source§

fn from(position: Position) -> Self

Converts to this type from the input type.
Source§

impl Graph for Position

Implementation of the Graph trait for the Position struct, enabling graphical representation of financial options positions.

This implementation provides methods to visualize the profit/loss (PnL) profile of an options position across different price levels of the underlying asset. It handles the generation of appropriate title, data values for plotting, and special chart elements like break-even points.

The visualization capabilities allow traders to analyze the potential outcomes of their options positions at expiration across various price scenarios.

Source§

fn graph_data(&self) -> GraphData

Return the raw data ready for plotting.
Source§

fn graph_config(&self) -> GraphConfig

Optional per‑object configuration overrides.
Source§

impl Greeks for Position

Implementation of the Greeks trait for the Position struct.

This implementation allows a Position to calculate option Greeks (delta, gamma, theta, vega, rho, etc.) by accessing its underlying option contract. The implementation provides a way to expose the position’s option for use in Greek calculations.

Source§

fn get_options(&self) -> Result<Vec<&Options>, GreeksError>

Returns a vector containing a reference to the option contract associated with this position.

This method satisfies the Greeks trait requirement by providing access to the option contract that will be used for calculating various Greek values.

§Returns
  • Ok(Vec<&Options>) - A vector containing a reference to the position’s underlying option
  • Err(GreeksError) - If there is an error accessing the option data
Source§

fn greeks(&self) -> Result<Greek, GreeksError>

Calculates and returns all Greeks as a single Greek struct. Read more
Source§

fn delta(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate delta value for all options. Read more
Source§

fn gamma(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate gamma value for all options. Read more
Source§

fn theta(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate theta value for all options. Read more
Source§

fn vega(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate vega value for all options. Read more
Source§

fn rho(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate rho value for all options. Read more
Source§

fn rho_d(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate rho_d value for all options. Read more
Source§

fn alpha(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate alpha value for all options. Read more
Source§

fn vanna(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate vanna value for all options. Read more
Source§

fn vomma(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate vomma value for all options. Read more
Source§

fn veta(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate veta value for all options. Read more
Source§

fn charm(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate charm value for all options. Read more
Source§

fn color(&self) -> Result<Decimal, GreeksError>

Calculates the aggregate color value for all options. Read more
Source§

impl PartialEq for Position

Source§

fn eq(&self, other: &Position) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PnLCalculator for Position

§Position Profit and Loss (PnL) Calculator

This trait implementation provides methods to calculate the profit and loss (PnL) for option positions under different market scenarios.

The implementation offers two main calculations:

  1. Current PnL based on updated market conditions
  2. PnL at expiration based on a projected underlying price

These calculations are essential for risk management, position monitoring, and strategy planning in options trading.

Source§

fn calculate_pnl( &self, underlying_price: &Positive, expiration_date: ExpirationDate, implied_volatility: &Positive, ) -> Result<PnL, PricingError>

Calculates the current unrealized profit and loss for an option position based on updated market conditions.

This method computes the difference between the option’s price at entry and its current theoretical price using the Black-Scholes model. It factors in changes to:

  • The underlying asset price
  • Time to expiration
  • Implied volatility
§Arguments
  • underlying_price - The current price of the underlying asset
  • expiration_date - The updated expiration date for the calculation
  • implied_volatility - The current implied volatility of the option
§Returns
  • Result<PnL, PricingError> - A PnL object containing unrealized profit/loss and position cost details, or an error if the calculation fails
Source§

fn calculate_pnl_at_expiration( &self, underlying_price: &Positive, ) -> Result<PnL, PricingError>

Calculates the expected profit and loss at option expiration for a given underlying price.

This method determines the realized profit or loss that would occur if the option expires with the underlying at the specified price. It uses intrinsic value calculation at expiration rather than Black-Scholes pricing.

§Arguments
  • underlying_price - The projected price of the underlying asset at expiration
§Returns
  • Result<PnL, PricingError> - A PnL object containing realized profit/loss and position cost details, or an error if the calculation fails
Source§

fn diff_position_pnl(&self, position: &Position) -> Result<PnL, PricingError>

Calculates the profit and loss (PnL) for a given trading position. Read more
Source§

fn adjustments_pnl( &self, _adjustments: &DeltaAdjustment, ) -> Result<PnL, PricingError>

Calculates the Profit and Loss (PnL) for a single delta adjustment applied to a trading strategy. Read more
Source§

impl Profit for Position

Implementation of the Profit trait for the Position struct.

This allows calculating the profit of a position at a given price by using the position’s profit and loss (PnL) calculation at expiration.

Source§

fn calculate_profit_at(&self, price: &Positive) -> Result<Decimal, PricingError>

Calculates the profit of the position at a specific price.

This method computes the profit or loss that would be realized if the position were to expire with the underlying asset at the specified price.

§Parameters
  • price - The price at which to calculate the profit, represented as a Positive value.
§Returns
  • Result<Decimal, PricingError> - The calculated profit as a Decimal if successful, or an error if the calculation fails.
Source§

fn get_point_at_price( &self, _price: &Positive, ) -> Result<(Decimal, Decimal), PricingError>

Creates a chart point representation of the profit at the given price. Read more
Source§

impl Serialize for Position

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Position

Source§

impl ToSchema for Position

Source§

fn name() -> Cow<'static, str>

Return name of the schema. Read more
Source§

fn schemas(schemas: &mut Vec<(String, RefOr<Schema>)>)

Implement reference utoipa::openapi::schema::Schemas for this type. Read more
Source§

impl TradeAble for Position

Source§

fn trade(&self) -> Result<Trade, TradeError>

Retrieves a reference to a Trade instance associated with the current object. Read more
Source§

fn trade_ref(&self) -> Result<&Trade, TradeError>

Returns a reference to the Trade associated with the current instance. Read more
Source§

fn trade_mut(&mut self) -> Result<&mut Trade, TradeError>

Provides a mutable reference to the Trade instance contained within the current structure. Read more
Source§

impl TradeStatusAble for Position

Source§

fn open(&self) -> Result<Trade, TradeError>

open: Return a Trade instance representing the trade in its open status or a TradeError if the transition is invalid. Read more
Source§

fn close(&self) -> Result<Trade, TradeError>

closed: Return a Trade instance representing the trade in its closed status or a TradeError if the transition is invalid. Read more
Source§

fn expired(&self) -> Result<Trade, TradeError>

expired: Return a Trade instance representing the trade in its expired status or a TradeError if the transition is invalid. Read more
Source§

fn exercised(&self) -> Result<Trade, TradeError>

exercised: Return a Trade instance representing the trade in its exercised status or a TradeError if the transition is invalid. Read more
Source§

fn assigned(&self) -> Result<Trade, TradeError>

assigned: Return a Trade instance representing the trade in its assigned status or a TradeError if the transition is invalid. Read more
Source§

fn status_other(&self) -> Result<Trade, TradeError>

status_other: Return a Trade instance representing undeclared status or a TradeError if the transition is invalid. Read more
Source§

impl TransactionAble for Position

Source§

fn add_transaction( &mut self, _transaction: Transaction, ) -> Result<(), TransactionError>

Position does not track an internal transaction history. This impl is intentionally unsupported; callers that need transaction tracking should store transactions in a higher-level container.

§Errors

Always returns a TransactionError — this operation is intentionally unsupported on Position.

Source§

fn get_transactions(&self) -> Result<Vec<Transaction>, TransactionError>

See Self::add_transaction — this method is intentionally unsupported on Position and always errors.

§Errors

Always returns a TransactionError::NotImplemented — this operation is intentionally unsupported on Position.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PartialSchema for T
where T: ComposeSchema + ?Sized,

Source§

fn schema() -> RefOr<Schema>

Return ref or schema of implementing type that can then be used to construct combined schemas.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more