Class Security
Defined in File security.hpp
Inheritance Relationships
Derived Types
public otyca::InterestRateFuture
(Class InterestRateFuture)public otyca::InterestRateSwap
(Class InterestRateSwap)public otyca::Option
(Class Option)
Class Documentation
-
class Security
Represents a financial security with bid/ask prices and sizes.
The Security class provides methods to access and modify market pricing data, such as bid and ask prices and their respective sizes. It also provides utility methods to compute the mid-price and spread.
Subclassed by otyca::InterestRateFuture, otyca::InterestRateSwap, otyca::Option
Public Functions
-
inline Security()
Default constructor.
Initializes bid and ask prices to NaN, and sizes to zero.
-
inline Security(double bid_price, double ask_price, int bid_size = 1, int ask_size = 1)
Constructor with bid/ask prices and sizes.
- Parameters:
bid_price – The bid price.
ask_price – The ask price.
bid_size – The bid size (default 1).
ask_size – The ask size (default 1).
-
inline virtual ~Security()
Virtual destructor.
-
inline size_t id()
Gets the ID.
- Returns:
ID.
-
inline double get_ask_price() const
Gets the ask price.
- Returns:
Ask price.
-
inline double get_bid_price() const
Gets the bid price.
- Returns:
Bid price.
-
inline int get_bid_size() const
Gets the bid size.
- Returns:
Bid size.
-
inline int get_ask_size() const
Gets the ask size.
- Returns:
Ask size.
-
inline void set_bid_ask(double bid_price, int bid_size, double ask_price, int ask_size)
Sets bid/ask prices and sizes.
If any input is negative, or if bid >= ask, values are invalidated.
- Parameters:
bid_price – The bid price.
bid_size – The bid size.
ask_price – The ask price.
ask_size – The ask size.
-
inline double mid() const
Computes the mid-price.
If the bid price is positive, returns the weighted mid; otherwise, simple mid.
- Returns:
Mid-price of the security.
-
inline double simple_mid() const
Computes the simple (unweighted) mid-price.
- Returns:
Simple mid-price.
-
inline double weighted_mid() const
Computes the inverse-size-weighted mid-price.
- Returns:
Weighted mid-price.
-
inline double spread() const
Computes the spread between ask and bid.
- Returns:
The spread.
-
inline bool valid_price() const
Checks if the current bid/ask prices are valid.
A valid price has a positive ask that is greater than the bid.
- Returns:
True if the price is valid; false otherwise.
Protected Functions
-
inline size_t _generate_id()
-
inline Security()