Esempio n. 1
0
        /********************************************************
         * CONSTRUCTOR/DELEGATE DEFINITIONS
         *********************************************************/
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        public Security(string symbol, SecurityType type, Resolution resolution, bool fillDataForward, decimal leverage, bool extendedMarketHours, bool useQuantConnectData = false)
        {
            //Set Basics:
            _symbol                = symbol;
            _type                  = type;
            _resolution            = resolution;
            _isFillDataForward     = fillDataForward;
            _leverage              = leverage;
            _isExtendedMarketHours = extendedMarketHours;
            _isQuantConnectData    = useQuantConnectData;

            //Setup Transaction Model for this Asset
            switch (type)
            {
            case SecurityType.Equity:
                Model      = new EquityTransactionModel();
                DataFilter = new EquityDataFilter();
                break;

            case SecurityType.Forex:
                Model      = new ForexTransactionModel();
                DataFilter = new ForexDataFilter();
                break;

            case SecurityType.Base:
                Model      = new SecurityTransactionModel();
                DataFilter = new SecurityDataFilter();
                break;
            }

            //Holdings for new Vehicle:
            Cache    = new SecurityCache();
            Holdings = new SecurityHolding(symbol, Model);
            Exchange = new SecurityExchange();
        }
Esempio n. 2
0
 /// <summary>
 /// Temporary convenience constructor
 /// </summary>
 protected Security(SubscriptionDataConfig config,
                    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
                    )
     : this(config.Symbol,
            quoteCurrency,
            symbolProperties,
            exchange,
            cache,
            portfolioModel,
            fillModel,
            feeModel,
            slippageModel,
            settlementModel,
            volatilityModel,
            buyingPowerModel,
            dataFilter,
            priceVariationModel
            )
 {
     SubscriptionsBag.Add(config);
     UpdateSubscriptionProperties();
 }
Esempio n. 3
0
        /********************************************************
         * CONSTRUCTOR/DELEGATE DEFINITIONS
         *********************************************************/
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        public Security(string symbol, SubscriptionDataConfig config, decimal leverage, bool isDynamicallyLoadedData = false)
        {
            //Set Basics:
            _symbol = symbol;
            _config = config;
            _isDynamicallyLoadedData = isDynamicallyLoadedData;

            //Setup Transaction Model for this Asset
            switch (config.Security)
            {
            case SecurityType.Equity:
                Model      = new EquityTransactionModel();
                DataFilter = new EquityDataFilter();
                break;

            case SecurityType.Forex:
                Model      = new ForexTransactionModel();
                DataFilter = new ForexDataFilter();
                break;

            case SecurityType.Base:
                Model      = new SecurityTransactionModel();
                DataFilter = new SecurityDataFilter();
                break;
            }

            //Holdings for new Vehicle:
            Cache    = new SecurityCache();
            Holdings = new SecurityHolding(symbol, _config.Security, leverage, Model);
            Exchange = new SecurityExchange();
        }
Esempio n. 4
0
 /// <summary>
 /// Temporary convenience constructor
 /// </summary>
 protected Security(SubscriptionDataConfig config,
                    Cash quoteCurrency,
                    SymbolProperties symbolProperties,
                    SecurityExchange exchange,
                    SecurityCache cache,
                    ISecurityPortfolioModel portfolioModel,
                    IFillModel fillModel,
                    IFeeModel feeModel,
                    ISlippageModel slippageModel,
                    ISettlementModel settlementModel,
                    IVolatilityModel volatilityModel,
                    ISecurityMarginModel marginModel,
                    ISecurityDataFilter dataFilter
                    )
     : this(config.Symbol,
            quoteCurrency,
            symbolProperties,
            exchange,
            cache,
            portfolioModel,
            fillModel,
            feeModel,
            slippageModel,
            settlementModel,
            volatilityModel,
            marginModel,
            dataFilter
            )
 {
     SubscriptionsBag.Add(config);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionFilterEnumerator"/> class
 /// </summary>
 /// <param name="enumerator">The source enumerator to be wrapped</param>
 /// <param name="security">The security containing an exchange and data filter</param>
 /// <param name="endTime">The end time of the subscription</param>
 public SubscriptionFilterEnumerator(IEnumerator <BaseData> enumerator, Security security, DateTime endTime)
 {
     _enumerator = enumerator;
     _security   = security;
     _endTime    = endTime;
     _exchange   = _security.Exchange;
     _dataFilter = _security.DataFilter;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscriptionFilterEnumerator"/> class
 /// </summary>
 /// <param name="enumerator">The source enumerator to be wrapped</param>
 /// <param name="security">The security containing an exchange and data filter</param>
 /// <param name="endTime">The end time of the subscription</param>
 /// <param name="extendedMarketHours">True if extended market hours are enabled</param>
 /// <param name="liveMode">True if live mode</param>
 /// <param name="securityExchangeHours">The security exchange hours instance to use</param>
 public SubscriptionFilterEnumerator(IEnumerator <BaseData> enumerator, Security security, DateTime endTime, bool extendedMarketHours, bool liveMode, SecurityExchangeHours securityExchangeHours)
 {
     _liveMode            = liveMode;
     _enumerator          = enumerator;
     _security            = security;
     _endTime             = endTime;
     _exchangeHours       = securityExchangeHours;
     _dataFilter          = _security.DataFilter;
     _extendedMarketHours = extendedMarketHours;
 }
Esempio n. 7
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        public Security(SecurityExchangeHours exchangeHours, SubscriptionDataConfig config, decimal leverage)
        {
            _config = config;

            Cache            = new SecurityCache();
            Exchange         = new SecurityExchange(exchangeHours);
            DataFilter       = new SecurityDataFilter();
            PortfolioModel   = new SecurityPortfolioModel();
            TransactionModel = new SecurityTransactionModel();
            MarginModel      = new SecurityMarginModel(leverage);
            Holdings         = new SecurityHolding(this);
        }
Esempio n. 8
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        protected Security(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
                           )
        {
            if (symbolProperties == null)
            {
                throw new ArgumentNullException(nameof(symbolProperties), "Security requires a valid SymbolProperties instance.");
            }

            if (symbolProperties.QuoteCurrency != quoteCurrency.Symbol)
            {
                throw new ArgumentException("symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol");
            }

            this._currencyConverter = currencyConverter;

            Symbol              = symbol;
            SubscriptionsBag    = new ConcurrentBag <SubscriptionDataConfig>();
            QuoteCurrency       = quoteCurrency;
            SymbolProperties    = symbolProperties;
            IsTradable          = true;
            Cache               = cache;
            Exchange            = exchange;
            DataFilter          = dataFilter;
            PriceVariationModel = priceVariationModel;
            PortfolioModel      = portfolioModel;
            BuyingPowerModel    = buyingPowerModel;
            FillModel           = fillModel;
            FeeModel            = feeModel;
            SlippageModel       = slippageModel;
            SettlementModel     = settlementModel;
            VolatilityModel     = volatilityModel;
            Holdings            = new SecurityHolding(this, currencyConverter);
            Data              = new DynamicSecurityData(registeredTypesProvider);
            Cache.DataStored += (sender, args) => Data.StoreData(args.DataType, args.Data);

            UpdateSubscriptionProperties();
        }
Esempio n. 9
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        public Security(SecurityExchangeHours exchangeHours, SubscriptionDataConfig config, decimal leverage, bool isDynamicallyLoadedData = false)
        {
            _config = config;
            _symbol = config.Symbol;
            _isDynamicallyLoadedData = isDynamicallyLoadedData;

            Cache            = new SecurityCache();
            Exchange         = new SecurityExchange(exchangeHours);
            DataFilter       = new SecurityDataFilter();
            PortfolioModel   = new SecurityPortfolioModel();
            TransactionModel = new SecurityTransactionModel();
            MarginModel      = new SecurityMarginModel(leverage);
            Holdings         = new SecurityHolding(this);
        }
Esempio n. 10
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        protected Security(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
                           )
        {
            if (symbolProperties == null)
            {
                throw new ArgumentNullException("symbolProperties", "Security requires a valid SymbolProperties instance.");
            }

            if (symbolProperties.QuoteCurrency != quoteCurrency.Symbol)
            {
                throw new ArgumentException("symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol");
            }

            Symbol              = symbol;
            SubscriptionsBag    = new ConcurrentBag <SubscriptionDataConfig>();
            QuoteCurrency       = quoteCurrency;
            SymbolProperties    = symbolProperties;
            IsTradable          = true;
            Cache               = cache;
            Exchange            = exchange;
            DataFilter          = dataFilter;
            PriceVariationModel = priceVariationModel;
            PortfolioModel      = portfolioModel;
            BuyingPowerModel    = buyingPowerModel;
            FillModel           = fillModel;
            FeeModel            = feeModel;
            SlippageModel       = slippageModel;
            SettlementModel     = settlementModel;
            VolatilityModel     = volatilityModel;
            Holdings            = new SecurityHolding(this);

            UpdateSubscriptionProperties();
        }
Esempio n. 11
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. 12
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        protected Security(SubscriptionDataConfig config,
                           Cash quoteCurrency,
                           SymbolProperties symbolProperties,
                           SecurityExchange exchange,
                           SecurityCache cache,
                           ISecurityPortfolioModel portfolioModel,
                           IFillModel fillModel,
                           IFeeModel feeModel,
                           ISlippageModel slippageModel,
                           ISettlementModel settlementModel,
                           IVolatilityModel volatilityModel,
                           ISecurityMarginModel marginModel,
                           ISecurityDataFilter dataFilter
                           )
        {
            if (symbolProperties == null)
            {
                throw new ArgumentNullException("symbolProperties", "Security requires a valid SymbolProperties instance.");
            }

            if (symbolProperties.QuoteCurrency != quoteCurrency.Symbol)
            {
                throw new ArgumentException("symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol");
            }

            _config          = config;
            QuoteCurrency    = quoteCurrency;
            SymbolProperties = symbolProperties;
            IsTradable       = !config.IsInternalFeed;
            Cache            = cache;
            Exchange         = exchange;
            DataFilter       = dataFilter;
            PortfolioModel   = portfolioModel;
            MarginModel      = marginModel;
            FillModel        = fillModel;
            FeeModel         = feeModel;
            SlippageModel    = slippageModel;
            SettlementModel  = settlementModel;
            VolatilityModel  = volatilityModel;
            Holdings         = new SecurityHolding(this);
        }
Esempio n. 13
0
 /// <summary>
 /// Construct a new security vehicle based on the user options.
 /// </summary>
 protected Security(SubscriptionDataConfig config,
                    SecurityExchange exchange,
                    SecurityCache cache,
                    ISecurityPortfolioModel portfolioModel,
                    IFillModel fillModel,
                    IFeeModel feeModel,
                    ISlippageModel slippageModel,
                    ISettlementModel settlementModel,
                    ISecurityMarginModel marginModel,
                    ISecurityDataFilter dataFilter
                    )
 {
     _config         = config;
     Cache           = cache;
     Exchange        = exchange;
     DataFilter      = dataFilter;
     PortfolioModel  = portfolioModel;
     MarginModel     = marginModel;
     FillModel       = fillModel;
     FeeModel        = feeModel;
     SlippageModel   = slippageModel;
     SettlementModel = settlementModel;
     Holdings        = new SecurityHolding(this);
 }
Esempio n. 14
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        protected Security(SubscriptionDataConfig config,
            Cash quoteCurrency,
            SymbolProperties symbolProperties,
            SecurityExchange exchange,
            SecurityCache cache,
            ISecurityPortfolioModel portfolioModel,
            IFillModel fillModel,
            IFeeModel feeModel,
            ISlippageModel slippageModel,
            ISettlementModel settlementModel,
            ISecurityMarginModel marginModel,
            ISecurityDataFilter dataFilter
            )
        {

            if (symbolProperties == null)
            {
                throw new ArgumentNullException("symbolProperties", "Security requires a valid SymbolProperties instance.");
            }

            if (symbolProperties.QuoteCurrency != quoteCurrency.Symbol)
            {
                throw new ArgumentException("symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol");
            }

            _config = config;
            QuoteCurrency = quoteCurrency;
            SymbolProperties = symbolProperties;
            Cache = cache;
            Exchange = exchange;
            DataFilter = dataFilter;
            PortfolioModel = portfolioModel;
            MarginModel = marginModel;
            FillModel = fillModel;
            FeeModel = feeModel;
            SlippageModel = slippageModel;
            SettlementModel = settlementModel;
            Holdings = new SecurityHolding(this);
        }
Esempio n. 15
0
        /******************************************************** 
        * CONSTRUCTOR/DELEGATE DEFINITIONS
        *********************************************************/
        /// <summary>
        /// Construct the Market Vehicle
        /// </summary>
        public Security(string symbol, SecurityType type, Resolution resolution, bool fillDataForward, decimal leverage, bool extendedMarketHours, bool useQuantConnectData = false) 
        {
            //Set Basics:
            this._symbol = symbol;
            this._type = type;
            this._resolution = resolution;
            this._isFillDataForward = fillDataForward;
            this._leverage = leverage;
            this._isExtendedMarketHours = extendedMarketHours;
            this._isQuantConnectData = useQuantConnectData;

            //Setup Transaction Model for this Asset
            switch (type) 
            { 
                case SecurityType.Equity:
                    Model = new EquityTransactionModel();
                    DataFilter = new EquityDataFilter();
                    break;
                case SecurityType.Forex:
                    Model = new ForexTransactionModel();
                    DataFilter = new ForexDataFilter();
                    break;
                case SecurityType.Base:
                    Model = new SecurityTransactionModel();
                    DataFilter = new SecurityDataFilter();
                    break;
            }

            //Holdings for new Vehicle:
            Cache = new SecurityCache();
            Holdings = new SecurityHolding(symbol, Model);
            Exchange = new SecurityExchange();
        }
Esempio n. 16
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        public Security(SecurityExchangeHours exchangeHours, SubscriptionDataConfig config, decimal leverage) 
        {
            _config = config;

            Cache = new SecurityCache();
            Exchange = new SecurityExchange(exchangeHours);
            DataFilter = new SecurityDataFilter();
            PortfolioModel = new SecurityPortfolioModel();
            TransactionModel = new SecurityTransactionModel();
            MarginModel = new SecurityMarginModel(leverage);
            SettlementModel = new ImmediateSettlementModel();
            Holdings = new SecurityHolding(this);
        }
Esempio n. 17
0
 /// <summary>
 /// Construct a new security vehicle based on the user options.
 /// </summary>
 protected Security(SubscriptionDataConfig config,
     SecurityExchange exchange,
     SecurityCache cache,
     ISecurityPortfolioModel portfolioModel,
     IFillModel fillModel,
     IFeeModel feeModel,
     ISlippageModel slippageModel,
     ISettlementModel settlementModel,
     ISecurityMarginModel marginModel,
     ISecurityDataFilter dataFilter
     )
 {
     _config = config;
     Cache = cache;
     Exchange = exchange;
     DataFilter = dataFilter;
     PortfolioModel = portfolioModel;
     MarginModel = marginModel;
     FillModel = fillModel;
     FeeModel = feeModel;
     SlippageModel = slippageModel;
     SettlementModel = settlementModel;
     Holdings = new SecurityHolding(this);
 }
Esempio n. 18
0
 /// <summary>
 /// Temporary convenience constructor
 /// </summary>
 protected Security(SubscriptionDataConfig config,
     Cash quoteCurrency,
     SymbolProperties symbolProperties,
     SecurityExchange exchange,
     SecurityCache cache,
     ISecurityPortfolioModel portfolioModel,
     IFillModel fillModel,
     IFeeModel feeModel,
     ISlippageModel slippageModel,
     ISettlementModel settlementModel,
     IVolatilityModel volatilityModel,
     ISecurityMarginModel marginModel,
     ISecurityDataFilter dataFilter
     )
     : this(config.Symbol,
         quoteCurrency,
         symbolProperties,
         exchange,
         cache,
         portfolioModel,
         fillModel,
         feeModel,
         slippageModel,
         settlementModel,
         volatilityModel,
         marginModel,
         dataFilter
         )
 {
     SubscriptionsBag.Add(config);
 }
Esempio n. 19
0
        /// <summary>
        /// Construct a new security vehicle based on the user options.
        /// </summary>
        protected Security(Symbol symbol,
            Cash quoteCurrency,
            SymbolProperties symbolProperties,
            SecurityExchange exchange,
            SecurityCache cache,
            ISecurityPortfolioModel portfolioModel,
            IFillModel fillModel,
            IFeeModel feeModel,
            ISlippageModel slippageModel,
            ISettlementModel settlementModel,
            IVolatilityModel volatilityModel,
            ISecurityMarginModel marginModel,
            ISecurityDataFilter dataFilter,
            IPriceVariationModel priceVariationModel
            )
        {

            if (symbolProperties == null)
            {
                throw new ArgumentNullException("symbolProperties", "Security requires a valid SymbolProperties instance.");
            }

            if (symbolProperties.QuoteCurrency != quoteCurrency.Symbol)
            {
                throw new ArgumentException("symbolProperties.QuoteCurrency must match the quoteCurrency.Symbol");
            }

            _symbol = symbol;
            SubscriptionsBag = new ConcurrentBag<SubscriptionDataConfig>();
            QuoteCurrency = quoteCurrency;
            SymbolProperties = symbolProperties;
            IsTradable = true;
            Cache = cache;
            Exchange = exchange;
            DataFilter = dataFilter;
            PriceVariationModel = priceVariationModel;
            PortfolioModel = portfolioModel;
            MarginModel = marginModel;
            FillModel = fillModel;
            FeeModel = feeModel;
            SlippageModel = slippageModel;
            SettlementModel = settlementModel;
            VolatilityModel = volatilityModel;
            Holdings = new SecurityHolding(this);
        }