/* * 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 ProtoBuf; namespace QuantConnect.Securities { /// /// Represents a cash amount which can be converted to account currency using a currency converter /// [ProtoContract(SkipConstructor = true)] public struct CashAmount { /// /// The amount of cash /// [ProtoMember(1)] public decimal Amount { get; } /// /// The currency in which the cash amount is denominated /// [ProtoMember(2)] public string Currency { get; } /// /// Initializes a new instance of the class /// /// The amount /// The currency public CashAmount(decimal amount, string currency) { Amount = amount; Currency = currency; } /// /// Will determine if two instances are equal /// Useful to compare against the default instance /// /// True if and are equal public static bool operator ==(CashAmount lhs, CashAmount rhs) { return Equals(lhs, rhs); } /// /// Will determine if two instances are different /// Useful to compare against the default instance /// /// True if or are different public static bool operator !=(CashAmount lhs, CashAmount rhs) { return !Equals(lhs, rhs); } /// /// Used to compare two instances. /// Useful to compare against the default instance /// /// The other object to compare with /// True if and are equal public override bool Equals(object obj) { if (obj is CashAmount) { var cashAmountObj = (CashAmount) obj; return Amount == cashAmountObj.Amount && Currency == cashAmountObj.Currency; } return false; } /// /// Get Hash Code for this Object /// /// Integer Hash Code public override int GetHashCode() { return base.GetHashCode(); } } }