Skip to content

Commit

Permalink
Simplify symbol properties holder and updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jhonabreul committed Jan 30, 2025
1 parent 65efe3b commit b55a948
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 65 deletions.
53 changes: 3 additions & 50 deletions Common/Securities/Option/OptionSymbolProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ namespace QuantConnect.Securities.Option
/// </summary>
public class OptionSymbolProperties : SymbolProperties
{
private SymbolProperties _baseProperties;

/// <summary>
/// The contract multiplier for the security.
/// </summary>
Expand All @@ -32,20 +30,10 @@ public class OptionSymbolProperties : SymbolProperties
/// </remarks>
private decimal? _contractMultiplier;

/// <summary>
/// The description of the security
/// </summary>
public override string Description => _baseProperties.Description;

/// <summary>
/// The quote currency of the security
/// </summary>
public override string QuoteCurrency => _baseProperties.QuoteCurrency;

/// <summary>
/// The contract multiplier for the security
/// </summary>
public override decimal ContractMultiplier => _contractMultiplier ?? _baseProperties.ContractMultiplier;
public override decimal ContractMultiplier => _contractMultiplier ?? base.ContractMultiplier;

/// <summary>
/// When the holder of an equity option exercises one contract, or when the writer of an equity option is assigned
Expand All @@ -56,41 +44,6 @@ public int ContractUnitOfTrade
get; protected set;
}

/// <summary>
/// Minimum price variation, required for index options contracts with
/// variable sized quoted prices depending on the premium of the option.
/// </summary>
public override decimal MinimumPriceVariation => _baseProperties.MinimumPriceVariation;

/// <summary>
/// The lot size (lot size of the order) for the security
/// </summary>
public override decimal LotSize => _baseProperties.LotSize;

/// <summary>
/// The market ticker
/// </summary>
public override string MarketTicker => _baseProperties.MarketTicker;

/// <summary>
/// The minimum order size allowed
/// </summary>
public override decimal? MinimumOrderSize => _baseProperties.MinimumOrderSize;

/// <summary>
/// Allows normalizing live asset prices to US Dollars for Lean consumption. In some exchanges,
/// for some securities, data is expressed in cents like for example for corn futures ('ZC').
/// </summary>
public override decimal PriceMagnifier => _baseProperties.PriceMagnifier;

/// <summary>
/// Scale factor for option's strike price. For some options, such as NQX, the strike price
/// is based on a fraction of the underlying, thus this paramater scales the strike price so
/// that it can be used in comparation with the underlying such as
/// in <see cref="OptionFilterUniverse.Strikes(int, int)"/>
/// </summary>
public override decimal StrikeMultiplier => _baseProperties.StrikeMultiplier;

/// <summary>
/// Creates an instance of the <see cref="OptionSymbolProperties"/> class
/// </summary>
Expand All @@ -103,8 +56,8 @@ public OptionSymbolProperties(string description, string quoteCurrency, decimal
/// Creates an instance of the <see cref="OptionSymbolProperties"/> class from <see cref="SymbolProperties"/> class
/// </summary>
public OptionSymbolProperties(SymbolProperties properties)
: base(properties)
{
_baseProperties = properties;
ContractUnitOfTrade = (int)properties.ContractMultiplier;
}

Expand All @@ -124,7 +77,7 @@ internal void SetContractMultiplier(decimal multiplier)
/// <param name="other">The symbol properties to take values from</param>
internal override void Update(SymbolProperties other)
{
_baseProperties.Update(other);
base.Update(other);
if (other is OptionSymbolProperties optionSymbolProperties)
{
ContractUnitOfTrade = optionSymbolProperties.ContractUnitOfTrade;
Expand Down
24 changes: 9 additions & 15 deletions Common/Securities/SymbolProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public class SymbolProperties
/// <summary>
/// The description of the security
/// </summary>
public virtual string Description => _properties.Description;
public string Description => _properties.Description;

/// <summary>
/// The quote currency of the security
/// </summary>
public virtual string QuoteCurrency => _properties.QuoteCurrency;
public string QuoteCurrency => _properties.QuoteCurrency;

/// <summary>
/// The contract multiplier for the security
Expand All @@ -58,42 +58,42 @@ public virtual decimal ContractMultiplier
/// <summary>
/// The lot size (lot size of the order) for the security
/// </summary>
public virtual decimal LotSize => _properties.LotSize;
public decimal LotSize => _properties.LotSize;

/// <summary>
/// The market ticker
/// </summary>
public virtual string MarketTicker => _properties.MarketTicker;
public string MarketTicker => _properties.MarketTicker;

/// <summary>
/// The minimum order size allowed
/// For crypto/forex pairs it's expected to be expressed in base or quote currency
/// i.e For BTC/USD the minimum order size allowed with Coinbase is 0.0001 BTC
/// while on Binance the minimum order size allowed is 10 USD
/// </summary>
public virtual decimal? MinimumOrderSize => _properties.MinimumOrderSize;
public decimal? MinimumOrderSize => _properties.MinimumOrderSize;

/// <summary>
/// Allows normalizing live asset prices to US Dollars for Lean consumption. In some exchanges,
/// for some securities, data is expressed in cents like for example for corn futures ('ZC').
/// </summary>
/// <remarks>Default value is 1 but for some futures in cents it's 100</remarks>
public virtual decimal PriceMagnifier => _properties.PriceMagnifier;
public decimal PriceMagnifier => _properties.PriceMagnifier;

/// <summary>
/// Scale factor for option's strike price. For some options, such as NQX, the strike price
/// is based on a fraction of the underlying, thus this paramater scales the strike price so
/// that it can be used in comparation with the underlying such as
/// in <see cref="OptionFilterUniverse.Strikes(int, int)"/>
/// </summary>
public virtual decimal StrikeMultiplier => _properties.StrikeMultiplier;
public decimal StrikeMultiplier => _properties.StrikeMultiplier;

/// <summary>
/// Creates an instance of the <see cref="SymbolProperties"/> class
/// </summary>
protected SymbolProperties()
protected SymbolProperties(SymbolProperties properties)
{
_properties = new SymbolPropertiesHolder();
_properties = properties._properties;
}

/// <summary>
Expand Down Expand Up @@ -157,12 +157,6 @@ private class SymbolPropertiesHolder

public decimal StrikeMultiplier { get; }

/// <summary>
/// Creates an empty instance of the <see cref="SymbolPropertiesHolder"/> class
/// </summary>
public SymbolPropertiesHolder()
{
}

/// <summary>
/// Creates an instance of the <see cref="SymbolPropertiesHolder"/> class
Expand Down

0 comments on commit b55a948

Please sign in to comment.