Price class: comparison operators
The Price class overloads common comparison operators that allow you to compare prices with one another in a variety of formats.
public static bool operator <(double lhs, Price rhs)
public static bool operator <(int lhs, Price rhs)
public static bool operator <(Price lhs, double rhs)
public static bool operator <(Price lhs, int rhs)
public static bool operator <(Price lhs, Price rhs)
public static bool operator <=(double lhs, Price rhs)
public static bool operator <=(int lhs, Price rhs)
public static bool operator <=(Price lhs, double rhs)
public static bool operator <=(Price lhs, int rhs)
public static bool operator <=(Price lhs, Price rhs)
public static bool operator ==(double lhs, Price rhs)
public static bool operator ==(int lhs, Price rhs)
public static bool operator ==(Price lhs, double rhs)
public static bool operator ==(Price lhs, int rhs)
public static bool operator ==(Price lhs, Price rhs)
public static bool operator >(double lhs, Price rhs)
public static bool operator >(int lhs, Price rhs)
public static bool operator >(Price lhs, double rhs)
public static bool operator >(Price lhs, int rhs)
public static bool operator >(Price lhs, Price rhs)
public static bool operator >=(double lhs, Price rhs)
public static bool operator >=(int lhs, Price rhs)
public static bool operator >=(Price lhs, double rhs)
public static bool operator >=(Price lhs, int rhs)
public static bool operator >=(Price lhs, Price rhs)
For example, assume that the variable inst represents a valid InstrumentDetails instance for the Eurex FGBL-Mar20 futures contract. You could use the overloaded == operator to indicate whether two prices are equal:
Price p1 = Price.FromString(inst,"114.73");
if (p1 == 11473)
{
Console.WriteLine("These are equal.");
}
else
{
Console.WriteLine("These are not equal.");
}
In this example, the price on the left-hand-side (lhs) of the comparison operator is a Price object and the price on the right-hand-side (rhs) of the comparison operator is in ticks format (an integer). Therefore, TT .NET SDK calls:
bool operator ==(Price lhs, int rhs)
which produces the following result:
These are equal.