/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using QuantConnect.Python; using System; namespace QuantConnect.Data.Market { /// /// Defines a base for a single contract, like an option or future contract /// public abstract class BaseContract : ISymbolProvider { /// /// Gets the contract's symbol /// [PandasIgnore] public Symbol Symbol { get; set; } /// /// The security identifier of the symbol /// [PandasIgnore] public SecurityIdentifier ID => Symbol.ID; /// /// Gets the underlying security's symbol /// public Symbol UnderlyingSymbol => Symbol.Underlying; /// /// Gets the expiration date /// public DateTime Expiry => Symbol.ID.Date; /// /// Gets the local date time this contract's data was last updated /// [PandasIgnore] public DateTime Time { get; set; } /// /// Gets the open interest /// public virtual decimal OpenInterest { get; set; } /// /// Gets the last price this contract traded at /// public virtual decimal LastPrice { get; set; } /// /// Gets the last volume this contract traded at /// public virtual long Volume { get; set; } /// /// Gets the current bid price /// public virtual decimal BidPrice { get; set; } /// /// Get the current bid size /// public virtual long BidSize { get; set; } /// /// Gets the ask price /// public virtual decimal AskPrice { get; set; } /// /// Gets the current ask size /// public virtual long AskSize { get; set; } /// /// Initializes a new instance of the class /// /// The contract symbol protected BaseContract(Symbol symbol) { Symbol = symbol; } /// /// Returns a string that represents the current object. /// /// /// A string that represents the current object. /// public override string ToString() => Symbol.Value; /// /// Updates the contract with the new data, which can be a or or /// internal abstract void Update(BaseData data); } }