1c3d849ad5
* Reconcile duplicated code * Add License header * CS0219 Fixes: Value assigned, but never used * CA1507: Use nameof in place of string literals * CS0108 : Hides Inherited Member; Use new keyword to overwrite formally * CS0114: Hides inherited member; use override keyword * CS0168: Variable is declared but never used * Tests CS1062; using obsolete implicit Symbol -> String; fix via .ToString() * CS0472: Non Nullable Obj getting Null Checked * CS0067 Member not used; ignore all cases for future use * CS00162 : Unreachable code; either removed or ignored for debugging and test cases * CS0169 Remove non-used fields; ignore those that may be used in future * CS0414; Field is assigned but never used. * CS0618; Obsolete properties and members; Only fixes simple ones, rest will have to broken up * CS0649; Field never assigned too * CS0659 & CS0661 ; Overwrite operators and equals but not hashcode; I don't really override it but just call base * Small comment fix * Cleanup pragma statement
91 lines
3.2 KiB
C#
91 lines
3.2 KiB
C#
/*
|
|
* 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.
|
|
*/
|
|
|
|
namespace QuantConnect.Securities
|
|
{
|
|
/// <summary>
|
|
/// Represents a cash amount which can be converted to account currency using a currency converter
|
|
/// </summary>
|
|
public struct CashAmount
|
|
{
|
|
/// <summary>
|
|
/// The amount of cash
|
|
/// </summary>
|
|
public decimal Amount { get; }
|
|
|
|
/// <summary>
|
|
/// The currency in which the cash amount is denominated
|
|
/// </summary>
|
|
public string Currency { get; }
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CashAmount"/> class
|
|
/// </summary>
|
|
/// <param name="amount">The amount</param>
|
|
/// <param name="currency">The currency</param>
|
|
public CashAmount(decimal amount, string currency)
|
|
{
|
|
Amount = amount;
|
|
Currency = currency;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Will determine if two <see cref="CashAmount"/> instances are equal
|
|
/// Useful to compare against the default instance
|
|
/// </summary>
|
|
/// <returns>True if <see cref="Currency"/> and <see cref="Amount"/> are equal</returns>
|
|
public static bool operator ==(CashAmount lhs, CashAmount rhs)
|
|
{
|
|
return Equals(lhs, rhs);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Will determine if two <see cref="CashAmount"/> instances are different
|
|
/// Useful to compare against the default instance
|
|
/// </summary>
|
|
/// <returns>True if <see cref="Currency"/> or <see cref="Amount"/> are different</returns>
|
|
public static bool operator !=(CashAmount lhs, CashAmount rhs)
|
|
{
|
|
return !Equals(lhs, rhs);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Used to compare two <see cref="CashAmount"/> instances.
|
|
/// Useful to compare against the default instance
|
|
/// </summary>
|
|
/// <param name="obj">The other object to compare with</param>
|
|
/// <returns>True if <see cref="Currency"/> and <see cref="Amount"/> are equal</returns>
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj is CashAmount)
|
|
{
|
|
var cashAmountObj = (CashAmount) obj;
|
|
return Amount == cashAmountObj.Amount
|
|
&& Currency == cashAmountObj.Currency;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get Hash Code for this Object
|
|
/// </summary>
|
|
/// <returns>Integer Hash Code</returns>
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
}
|