using System;
namespace NT8.Core.Common.Models
{
///
/// Represents a financial instrument (e.g., a futures contract, stock).
///
public class Instrument
{
///
/// Unique symbol for the instrument (e.g., "ES", "AAPL").
///
public string Symbol { get; private set; }
///
/// Exchange where the instrument is traded (e.g., "CME", "NASDAQ").
///
public string Exchange { get; private set; }
///
/// Minimum price increment for the instrument (e.g., 0.25 for ES futures).
///
public double TickSize { get; private set; }
///
/// Value of one tick in currency (e.g., $12.50 for ES futures).
///
public double TickValue { get; private set; }
///
/// Contract size multiplier (e.g., 50.0 for ES futures, 1.0 for stocks).
/// This is the value of one point movement in the instrument.
///
public double ContractMultiplier { get; private set; }
///
/// The currency in which the instrument is denominated (e.g., "USD").
///
public string Currency { get; private set; }
///
/// Initializes a new instance of the Instrument class.
///
/// Unique symbol.
/// Exchange.
/// Minimum price increment.
/// Value of one tick.
/// Contract size multiplier.
/// Denomination currency.
public Instrument(
string symbol,
string exchange,
double tickSize,
double tickValue,
double contractMultiplier,
string currency)
{
if (string.IsNullOrEmpty(symbol))
throw new ArgumentNullException("symbol");
if (string.IsNullOrEmpty(exchange))
throw new ArgumentNullException("exchange");
if (tickSize <= 0)
throw new ArgumentOutOfRangeException("tickSize", "Tick size must be positive.");
if (tickValue <= 0)
throw new ArgumentOutOfRangeException("tickValue", "Tick value must be positive.");
if (contractMultiplier <= 0)
throw new ArgumentOutOfRangeException("contractMultiplier", "Contract multiplier must be positive.");
if (string.IsNullOrEmpty(currency))
throw new ArgumentNullException("currency");
Symbol = symbol;
Exchange = exchange;
TickSize = tickSize;
TickValue = tickValue;
ContractMultiplier = contractMultiplier;
Currency = currency;
}
///
/// Creates a default, invalid instrument.
///
/// An invalid Instrument instance.
public static Instrument CreateInvalid()
{
return new Instrument(
symbol: "INVALID",
exchange: "N/A",
tickSize: 0.01,
tickValue: 0.01,
contractMultiplier: 1.0,
currency: "USD");
}
///
/// Provides a string representation of the instrument.
///
/// A string with symbol and exchange.
public override string ToString()
{
return String.Format("{0} ({1})", Symbol, Exchange);
}
}
}