Esempio n. 1
0
 /// <summary>
 /// Constructor for the option security
 /// </summary>
 /// <param name="symbol">The symbol of the security</param>
 /// <param name="exchangeHours">Defines the hours this exchange is open</param>
 /// <param name="quoteCurrency">The cash object that represent the quote currency</param>
 /// <param name="symbolProperties">The symbol properties for this security</param>
 /// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
 /// instances into units of the account currency</param>
 /// <param name="registeredTypes">Provides all data types registered in the algorithm</param>
 public Option(Symbol symbol,
               SecurityExchangeHours exchangeHours,
               Cash quoteCurrency,
               OptionSymbolProperties symbolProperties,
               ICurrencyConverter currencyConverter,
               IRegisteredSecurityDataTypesProvider registeredTypes,
               SecurityCache securityCache)
     : base(symbol,
            quoteCurrency,
            symbolProperties,
            new OptionExchange(exchangeHours),
            securityCache,
            new OptionPortfolioModel(),
            new ImmediateFillModel(),
            new InteractiveBrokersFeeModel(),
            new ConstantSlippageModel(0),
            new ImmediateSettlementModel(),
            Securities.VolatilityModel.Null,
            new OptionMarginModel(),
            new OptionDataFilter(),
            new SecurityPriceVariationModel(),
            currencyConverter,
            registeredTypes
            )
 {
     ExerciseSettlement = SettlementType.PhysicalDelivery;
     SetDataNormalizationMode(DataNormalizationMode.Raw);
     OptionExerciseModel = new DefaultExerciseModel();
     PriceModel          = new CurrentPriceOptionPriceModel();
     Holdings            = new OptionHolding(this, currencyConverter);
     _symbolProperties   = symbolProperties;
     SetFilter(-1, 1, TimeSpan.Zero, TimeSpan.FromDays(35));
 }
Esempio n. 2
0
 /// <summary>
 /// Constructor for the option security
 /// </summary>
 /// <param name="exchangeHours">Defines the hours this exchange is open</param>
 /// <param name="quoteCurrency">The cash object that represent the quote currency</param>
 /// <param name="config">The subscription configuration for this security</param>
 /// <param name="symbolProperties">The symbol properties for this security</param>
 public Option(SecurityExchangeHours exchangeHours, SubscriptionDataConfig config, Cash quoteCurrency, OptionSymbolProperties symbolProperties)
     : base(config,
            quoteCurrency,
            symbolProperties,
            new OptionExchange(exchangeHours),
            new OptionCache(),
            new OptionPortfolioModel(),
            new ImmediateFillModel(),
            new InteractiveBrokersFeeModel(),
            new ConstantSlippageModel(0),
            new ImmediateSettlementModel(),
            Securities.VolatilityModel.Null,
            new OptionMarginModel(),
            new OptionDataFilter(),
            new SecurityPriceVariationModel()
            )
 {
     ExerciseSettlement = SettlementType.PhysicalDelivery;
     SetDataNormalizationMode(DataNormalizationMode.Raw);
     OptionExerciseModel = new DefaultExerciseModel();
     PriceModel          = new CurrentPriceOptionPriceModel();
     Holdings            = new OptionHolding(this);
     _symbolProperties   = symbolProperties;
     SetFilter(-1, 1, TimeSpan.Zero, TimeSpan.FromDays(35));
 }
Esempio n. 3
0
 /// <summary>
 /// Creates instance of the Option class.
 /// </summary>
 /// <remarks>
 /// Allows for the forwarding of the security configuration to the
 /// base Security constructor
 /// </remarks>
 protected Option(Symbol symbol,
                  Cash quoteCurrency,
                  SymbolProperties symbolProperties,
                  SecurityExchange exchange,
                  SecurityCache cache,
                  ISecurityPortfolioModel portfolioModel,
                  IFillModel fillModel,
                  IFeeModel feeModel,
                  ISlippageModel slippageModel,
                  ISettlementModel settlementModel,
                  IVolatilityModel volatilityModel,
                  IBuyingPowerModel buyingPowerModel,
                  ISecurityDataFilter dataFilter,
                  IPriceVariationModel priceVariationModel,
                  ICurrencyConverter currencyConverter,
                  IRegisteredSecurityDataTypesProvider registeredTypesProvider,
                  Security underlying
                  ) : base(
         symbol,
         quoteCurrency,
         symbolProperties,
         exchange,
         cache,
         portfolioModel,
         fillModel,
         feeModel,
         slippageModel,
         settlementModel,
         volatilityModel,
         buyingPowerModel,
         dataFilter,
         priceVariationModel,
         currencyConverter,
         registeredTypesProvider
         )
 {
     ExerciseSettlement = SettlementType.PhysicalDelivery;
     SetDataNormalizationMode(DataNormalizationMode.Raw);
     OptionExerciseModel = new DefaultExerciseModel();
     PriceModel          = new CurrentPriceOptionPriceModel();
     Holdings            = new OptionHolding(this, currencyConverter);
     _symbolProperties   = (OptionSymbolProperties)symbolProperties;
     SetFilter(-1, 1, TimeSpan.Zero, TimeSpan.FromDays(35));
     Underlying = underlying;
 }
Esempio n. 4
0
        /// <summary>
        /// Applies a split to the portfolio equity options positions
        /// </summary>
        /// <param name="split">The split to be applied</param>
        private void ApplySplitToOptions(Split split)
        {
            // only apply to the option positions that have correct underlying symbol
            var optionSecurities = Securities
                                   .Where(x => x.Value.Type == SecurityType.Option && split.Symbol == x.Key.Underlying && x.Value.Holdings.Invested)
                                   .ToList();

            foreach (var securityKV in optionSecurities)
            {
                var symbol   = securityKV.Key;
                var security = securityKV.Value;

                // only apply splits in raw data mode,
                var mode = security.DataNormalizationMode;
                if (mode != DataNormalizationMode.Raw)
                {
                    continue;
                }

                var splitFactor = split.SplitFactor;
                var newSymbol   = GetSplitAdjustedSymbol(symbol, splitFactor);

                if (newSymbol != null)
                {
                    Securities.Remove(symbol);
                    var optionHoldings = new Option.OptionHolding(Securities[newSymbol], (Option.OptionHolding)security.Holdings);
                    optionHoldings.SplitUnderlying(splitFactor);
                    Securities[newSymbol].Holdings = optionHoldings;
                }
                else
                {
                    var optionHoldings = (Option.OptionHolding)security.Holdings;
                    optionHoldings.SplitUnderlying(splitFactor);
                }
            }
        }
 /// <summary>
 /// Option Holding Class constructor
 /// </summary>
 /// <param name="security">The option security being held</param>
 /// <param name="holding">The option security holding</param>
 public OptionHolding(Security security, OptionHolding holding)
     : base(holding)
 {
 }