58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using mbts;
|
|
|
|
namespace bts.security_model
|
|
{
|
|
internal partial class Security
|
|
{
|
|
public override int GetHashCode() {
|
|
return (int)security_key;
|
|
}
|
|
|
|
public override bool Equals(object obj) {
|
|
if (obj == null) return false;
|
|
return obj.GetHashCode() == this.GetHashCode();
|
|
}
|
|
|
|
public static bool operator == (Security a, Security b) {
|
|
if ((object)a == null && (object)b == null) return true;
|
|
if ((object)a == null || (object)b == null) return false;
|
|
return a.GetHashCode() == b.GetHashCode();
|
|
}
|
|
|
|
public static bool operator !=(Security a, Security b) {
|
|
return !(a == b);
|
|
}
|
|
|
|
public string symbol { get {
|
|
switch (security_type) {
|
|
case SecurityType.type.STOCK:
|
|
return stock.symbol;
|
|
case SecurityType.type.FUTURE:
|
|
return future.symbol;
|
|
case SecurityType.type.OPTION:
|
|
return option.symbol;
|
|
case SecurityType.type.SPREAD:
|
|
return spread.symbol;
|
|
default:
|
|
return string.Empty;
|
|
}
|
|
}
|
|
}
|
|
public DateTime expiration {
|
|
get {
|
|
switch (security_type) {
|
|
case SecurityType.type.FUTURE: return new DateTime((int)future.expiration_year, (int)future.expiration_month, (int)future.expiration_day);
|
|
case SecurityType.type.OPTION: return new DateTime((int)option.expiration_year, (int)option.expiration_month, (int)option.expiration_day);
|
|
default: return DateTime.MinValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|